mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 18:19:34 +00:00
Merge branch 'dev-3.x-unset_parse_mode' of https://github.com/b0g3r/aiogram into b0g3r-dev-3.x-unset_parse_mode
# Conflicts: # aiogram/api/methods/base.py # aiogram/api/methods/edit_message_caption.py # aiogram/api/methods/edit_message_text.py # aiogram/api/methods/send_animation.py # aiogram/api/methods/send_audio.py # aiogram/api/methods/send_document.py # aiogram/api/methods/send_message.py # aiogram/api/methods/send_photo.py # aiogram/api/methods/send_video.py # aiogram/api/methods/send_voice.py # aiogram/api/types/__init__.py # aiogram/api/types/inline_query_result_audio.py # aiogram/api/types/inline_query_result_cached_audio.py # aiogram/api/types/inline_query_result_cached_document.py # aiogram/api/types/inline_query_result_cached_gif.py # aiogram/api/types/inline_query_result_cached_mpeg4_gif.py # aiogram/api/types/inline_query_result_cached_photo.py # aiogram/api/types/inline_query_result_cached_video.py # aiogram/api/types/inline_query_result_cached_voice.py # aiogram/api/types/inline_query_result_document.py # aiogram/api/types/inline_query_result_gif.py # aiogram/api/types/inline_query_result_mpeg4_gif.py # aiogram/api/types/inline_query_result_photo.py # aiogram/api/types/inline_query_result_video.py # aiogram/api/types/inline_query_result_voice.py # aiogram/api/types/input_media_animation.py # aiogram/api/types/input_media_audio.py # aiogram/api/types/input_media_document.py # aiogram/api/types/input_media_photo.py # aiogram/api/types/input_media_video.py # aiogram/api/types/input_text_message_content.py
This commit is contained in:
commit
b78f1cdb17
34 changed files with 166 additions and 87 deletions
|
|
@ -95,6 +95,7 @@ from ..methods import (
|
|||
UploadStickerFile,
|
||||
)
|
||||
from ..types import (
|
||||
UNSET,
|
||||
BotCommand,
|
||||
Chat,
|
||||
ChatMember,
|
||||
|
|
@ -440,7 +441,7 @@ class Bot(ContextInstanceMixin["Bot"]):
|
|||
self,
|
||||
chat_id: Union[int, str],
|
||||
text: str,
|
||||
parse_mode: Optional[str] = None,
|
||||
parse_mode: Optional[str] = UNSET,
|
||||
disable_web_page_preview: Optional[bool] = None,
|
||||
disable_notification: Optional[bool] = None,
|
||||
reply_to_message_id: Optional[int] = None,
|
||||
|
|
@ -512,7 +513,7 @@ class Bot(ContextInstanceMixin["Bot"]):
|
|||
chat_id: Union[int, str],
|
||||
photo: Union[InputFile, str],
|
||||
caption: Optional[str] = None,
|
||||
parse_mode: Optional[str] = None,
|
||||
parse_mode: Optional[str] = UNSET,
|
||||
disable_notification: Optional[bool] = None,
|
||||
reply_to_message_id: Optional[int] = None,
|
||||
reply_markup: Optional[
|
||||
|
|
@ -558,7 +559,7 @@ class Bot(ContextInstanceMixin["Bot"]):
|
|||
chat_id: Union[int, str],
|
||||
audio: Union[InputFile, str],
|
||||
caption: Optional[str] = None,
|
||||
parse_mode: Optional[str] = None,
|
||||
parse_mode: Optional[str] = UNSET,
|
||||
duration: Optional[int] = None,
|
||||
performer: Optional[str] = None,
|
||||
title: Optional[str] = None,
|
||||
|
|
@ -626,7 +627,7 @@ class Bot(ContextInstanceMixin["Bot"]):
|
|||
document: Union[InputFile, str],
|
||||
thumb: Optional[Union[InputFile, str]] = None,
|
||||
caption: Optional[str] = None,
|
||||
parse_mode: Optional[str] = None,
|
||||
parse_mode: Optional[str] = UNSET,
|
||||
disable_notification: Optional[bool] = None,
|
||||
reply_to_message_id: Optional[int] = None,
|
||||
reply_markup: Optional[
|
||||
|
|
@ -686,7 +687,7 @@ class Bot(ContextInstanceMixin["Bot"]):
|
|||
height: Optional[int] = None,
|
||||
thumb: Optional[Union[InputFile, str]] = None,
|
||||
caption: Optional[str] = None,
|
||||
parse_mode: Optional[str] = None,
|
||||
parse_mode: Optional[str] = UNSET,
|
||||
supports_streaming: Optional[bool] = None,
|
||||
disable_notification: Optional[bool] = None,
|
||||
reply_to_message_id: Optional[int] = None,
|
||||
|
|
@ -755,7 +756,7 @@ class Bot(ContextInstanceMixin["Bot"]):
|
|||
height: Optional[int] = None,
|
||||
thumb: Optional[Union[InputFile, str]] = None,
|
||||
caption: Optional[str] = None,
|
||||
parse_mode: Optional[str] = None,
|
||||
parse_mode: Optional[str] = UNSET,
|
||||
disable_notification: Optional[bool] = None,
|
||||
reply_to_message_id: Optional[int] = None,
|
||||
reply_markup: Optional[
|
||||
|
|
@ -817,7 +818,7 @@ class Bot(ContextInstanceMixin["Bot"]):
|
|||
chat_id: Union[int, str],
|
||||
voice: Union[InputFile, str],
|
||||
caption: Optional[str] = None,
|
||||
parse_mode: Optional[str] = None,
|
||||
parse_mode: Optional[str] = UNSET,
|
||||
duration: Optional[int] = None,
|
||||
disable_notification: Optional[bool] = None,
|
||||
reply_to_message_id: Optional[int] = None,
|
||||
|
|
@ -1819,7 +1820,7 @@ class Bot(ContextInstanceMixin["Bot"]):
|
|||
chat_id: Optional[Union[int, str]] = None,
|
||||
message_id: Optional[int] = None,
|
||||
inline_message_id: Optional[str] = None,
|
||||
parse_mode: Optional[str] = None,
|
||||
parse_mode: Optional[str] = UNSET,
|
||||
disable_web_page_preview: Optional[bool] = None,
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None,
|
||||
) -> Union[Message, bool]:
|
||||
|
|
@ -1861,7 +1862,7 @@ class Bot(ContextInstanceMixin["Bot"]):
|
|||
message_id: Optional[int] = None,
|
||||
inline_message_id: Optional[str] = None,
|
||||
caption: Optional[str] = None,
|
||||
parse_mode: Optional[str] = None,
|
||||
parse_mode: Optional[str] = UNSET,
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None,
|
||||
) -> Union[Message, bool]:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ import abc
|
|||
import secrets
|
||||
from typing import TYPE_CHECKING, Any, Dict, Generator, Generic, Optional, TypeVar, Union
|
||||
|
||||
from pydantic import BaseConfig, BaseModel, Extra
|
||||
from pydantic import BaseConfig, BaseModel, Extra, root_validator
|
||||
from pydantic.generics import GenericModel
|
||||
|
||||
from ..types import InputFile, ResponseParameters
|
||||
from ..types import UNSET, InputFile, ResponseParameters
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from ..client.bot import Bot
|
||||
|
|
@ -46,6 +46,20 @@ class TelegramMethod(abc.ABC, BaseModel, Generic[T]):
|
|||
arbitrary_types_allowed = True
|
||||
orm_mode = True
|
||||
|
||||
@root_validator(pre=True)
|
||||
def remove_unset(cls, values: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""
|
||||
Remove UNSET from `parse_mode` before fields validation.
|
||||
|
||||
We use UNSET as a sentinel value for `parse_mode` and replace it to real value later.
|
||||
It isn't a problem when it's just default value for a model field, but UNSET might be passing to
|
||||
a model initialization from `Bot.method_name`, so we must take care of it and
|
||||
remove it before fields validation.
|
||||
"""
|
||||
if "parse_mode" in values and values["parse_mode"] is UNSET:
|
||||
values.pop("parse_mode")
|
||||
return values
|
||||
|
||||
@property
|
||||
@abc.abstractmethod
|
||||
def __returning__(self) -> type: # pragma: no cover
|
||||
|
|
@ -116,18 +130,24 @@ def prepare_media_file(data: Dict[str, Any], files: Dict[str, InputFile]) -> Non
|
|||
|
||||
|
||||
def prepare_parse_mode(root: Any, parse_mode_property: str = "parse_mode") -> None:
|
||||
"""
|
||||
Find and set parse_mode with highest priority.
|
||||
|
||||
Developer can manually set parse_mode for each message (or message-like) object,
|
||||
but if parse_mode was unset we should use value from Bot object.
|
||||
|
||||
We can't use None for "unset state", because None itself is the parse_mode option.
|
||||
"""
|
||||
if isinstance(root, list):
|
||||
for item in root:
|
||||
prepare_parse_mode(item, parse_mode_property=parse_mode_property)
|
||||
return
|
||||
|
||||
if root.get(parse_mode_property):
|
||||
return
|
||||
if root.get(parse_mode_property, UNSET) is UNSET:
|
||||
from ..client.bot import Bot
|
||||
|
||||
from ..client.bot import Bot
|
||||
|
||||
bot = Bot.get_current(no_error=True)
|
||||
if bot and bot.parse_mode:
|
||||
root[parse_mode_property] = bot.parse_mode
|
||||
return
|
||||
return
|
||||
bot = Bot.get_current(no_error=True)
|
||||
if bot and bot.parse_mode:
|
||||
root[parse_mode_property] = bot.parse_mode
|
||||
else:
|
||||
root[parse_mode_property] = None
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
from ..types import InlineKeyboardMarkup, Message
|
||||
from ..types import UNSET, InlineKeyboardMarkup, Message
|
||||
from .base import Request, TelegramMethod, prepare_parse_mode
|
||||
|
||||
|
||||
|
|
@ -23,8 +23,9 @@ class EditMessageCaption(TelegramMethod[Union[Message, bool]]):
|
|||
"""Required if chat_id and message_id are not specified. Identifier of the inline message"""
|
||||
caption: Optional[str] = None
|
||||
"""New caption of the message, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the message caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""A JSON-serialized object for an inline keyboard."""
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
from ..types import InlineKeyboardMarkup, Message
|
||||
from ..types import UNSET, InlineKeyboardMarkup, Message
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
|
||||
|
|
@ -23,8 +23,9 @@ class EditMessageText(TelegramMethod[Union[Message, bool]]):
|
|||
"""Required if inline_message_id is not specified. Identifier of the message to edit"""
|
||||
inline_message_id: Optional[str] = None
|
||||
"""Required if chat_id and message_id are not specified. Identifier of the inline message"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the message text. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in your bot's message."""
|
||||
disable_web_page_preview: Optional[bool] = None
|
||||
"""Disables link previews for links in this message"""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
UNSET,
|
||||
ForceReply,
|
||||
InlineKeyboardMarkup,
|
||||
InputFile,
|
||||
|
|
@ -45,9 +46,9 @@ class SendAnimation(TelegramMethod[Message]):
|
|||
caption: Optional[str] = None
|
||||
"""Animation caption (may also be used when resending animation by file_id), 0-1024 characters
|
||||
after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the animation caption. See formatting options for more
|
||||
details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
disable_notification: Optional[bool] = None
|
||||
"""Sends the message silently. Users will receive a notification with no sound."""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
UNSET,
|
||||
ForceReply,
|
||||
InlineKeyboardMarkup,
|
||||
InputFile,
|
||||
|
|
@ -33,8 +34,9 @@ class SendAudio(TelegramMethod[Message]):
|
|||
file from the Internet, or upload a new one using multipart/form-data."""
|
||||
caption: Optional[str] = None
|
||||
"""Audio caption, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the audio caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
duration: Optional[int] = None
|
||||
"""Duration of the audio in seconds"""
|
||||
performer: Optional[str] = None
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
UNSET,
|
||||
ForceReply,
|
||||
InlineKeyboardMarkup,
|
||||
InputFile,
|
||||
|
|
@ -39,8 +40,9 @@ class SendDocument(TelegramMethod[Message]):
|
|||
caption: Optional[str] = None
|
||||
"""Document caption (may also be used when resending documents by file_id), 0-1024 characters
|
||||
after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the document caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
disable_notification: Optional[bool] = None
|
||||
"""Sends the message silently. Users will receive a notification with no sound."""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
UNSET,
|
||||
ForceReply,
|
||||
InlineKeyboardMarkup,
|
||||
Message,
|
||||
|
|
@ -24,8 +25,9 @@ class SendMessage(TelegramMethod[Message]):
|
|||
@channelusername)"""
|
||||
text: str
|
||||
"""Text of the message to be sent, 1-4096 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the message text. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in your bot's message."""
|
||||
disable_web_page_preview: Optional[bool] = None
|
||||
"""Disables link previews for links in this message"""
|
||||
disable_notification: Optional[bool] = None
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
UNSET,
|
||||
ForceReply,
|
||||
InlineKeyboardMarkup,
|
||||
InputFile,
|
||||
|
|
@ -30,8 +31,9 @@ class SendPhoto(TelegramMethod[Message]):
|
|||
caption: Optional[str] = None
|
||||
"""Photo caption (may also be used when resending photos by file_id), 0-1024 characters after
|
||||
entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the photo caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
disable_notification: Optional[bool] = None
|
||||
"""Sends the message silently. Users will receive a notification with no sound."""
|
||||
reply_to_message_id: Optional[int] = None
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
UNSET,
|
||||
ForceReply,
|
||||
InlineKeyboardMarkup,
|
||||
InputFile,
|
||||
|
|
@ -45,8 +46,9 @@ class SendVideo(TelegramMethod[Message]):
|
|||
caption: Optional[str] = None
|
||||
"""Video caption (may also be used when resending videos by file_id), 0-1024 characters after
|
||||
entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the video caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
supports_streaming: Optional[bool] = None
|
||||
"""Pass True, if the uploaded video is suitable for streaming"""
|
||||
disable_notification: Optional[bool] = None
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
from ..types import (
|
||||
UNSET,
|
||||
ForceReply,
|
||||
InlineKeyboardMarkup,
|
||||
InputFile,
|
||||
|
|
@ -33,9 +34,9 @@ class SendVoice(TelegramMethod[Message]):
|
|||
Internet, or upload a new one using multipart/form-data."""
|
||||
caption: Optional[str] = None
|
||||
"""Voice message caption, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the voice message caption. See formatting options for more
|
||||
details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
duration: Optional[int] = None
|
||||
"""Duration of the voice message in seconds"""
|
||||
disable_notification: Optional[bool] = None
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from .animation import Animation
|
||||
from .audio import Audio
|
||||
from .base import TelegramObject
|
||||
from .base import UNSET, TelegramObject
|
||||
from .bot_command import BotCommand
|
||||
from .callback_game import CallbackGame
|
||||
from .callback_query import CallbackQuery
|
||||
|
|
@ -103,6 +103,7 @@ from .webhook_info import WebhookInfo
|
|||
__all__ = (
|
||||
"TelegramObject",
|
||||
"Downloadable",
|
||||
"UNSET",
|
||||
"BufferedInputFile",
|
||||
"FSInputFile",
|
||||
"URLInputFile",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import datetime
|
||||
from typing import Any
|
||||
from unittest.mock import sentinel
|
||||
|
||||
from pydantic import BaseModel, Extra
|
||||
|
||||
|
|
@ -19,3 +21,7 @@ class TelegramObject(ContextInstanceMixin["TelegramObject"], BaseModel):
|
|||
class MutableTelegramObject(TelegramObject):
|
||||
class Config:
|
||||
allow_mutation = True
|
||||
|
||||
|
||||
UNSET: Any = sentinel.UNSET # special sentinel object which used in sutuation when None might be a useful value
|
||||
print(id(UNSET))
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -32,8 +33,9 @@ class InlineQueryResultAudio(InlineQueryResult):
|
|||
"""Title"""
|
||||
caption: Optional[str] = None
|
||||
"""Caption, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the audio caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
performer: Optional[str] = None
|
||||
"""Performer"""
|
||||
audio_duration: Optional[int] = None
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -30,8 +31,9 @@ class InlineQueryResultCachedAudio(InlineQueryResult):
|
|||
"""A valid file identifier for the audio file"""
|
||||
caption: Optional[str] = None
|
||||
"""Caption, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the audio caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""Inline keyboard attached to the message"""
|
||||
input_message_content: Optional[InputMessageContent] = None
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -34,8 +35,9 @@ class InlineQueryResultCachedDocument(InlineQueryResult):
|
|||
"""Short description of the result"""
|
||||
caption: Optional[str] = None
|
||||
"""Caption of the document to be sent, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the document caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""Inline keyboard attached to the message"""
|
||||
input_message_content: Optional[InputMessageContent] = None
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -30,8 +31,9 @@ class InlineQueryResultCachedGif(InlineQueryResult):
|
|||
"""Title for the result"""
|
||||
caption: Optional[str] = None
|
||||
"""Caption of the GIF file to be sent, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""Inline keyboard attached to the message"""
|
||||
input_message_content: Optional[InputMessageContent] = None
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -31,8 +32,9 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
|
|||
"""Title for the result"""
|
||||
caption: Optional[str] = None
|
||||
"""Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""Inline keyboard attached to the message"""
|
||||
input_message_content: Optional[InputMessageContent] = None
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -32,8 +33,9 @@ class InlineQueryResultCachedPhoto(InlineQueryResult):
|
|||
"""Short description of the result"""
|
||||
caption: Optional[str] = None
|
||||
"""Caption of the photo to be sent, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the photo caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""Inline keyboard attached to the message"""
|
||||
input_message_content: Optional[InputMessageContent] = None
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -32,8 +33,9 @@ class InlineQueryResultCachedVideo(InlineQueryResult):
|
|||
"""Short description of the result"""
|
||||
caption: Optional[str] = None
|
||||
"""Caption of the video to be sent, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the video caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""Inline keyboard attached to the message"""
|
||||
input_message_content: Optional[InputMessageContent] = None
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -32,9 +33,9 @@ class InlineQueryResultCachedVoice(InlineQueryResult):
|
|||
"""Voice message title"""
|
||||
caption: Optional[str] = None
|
||||
"""Caption, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the voice message caption. See formatting options for more
|
||||
details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""Inline keyboard attached to the message"""
|
||||
input_message_content: Optional[InputMessageContent] = None
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -35,8 +36,9 @@ class InlineQueryResultDocument(InlineQueryResult):
|
|||
"""Mime type of the content of the file, either 'application/pdf' or 'application/zip'"""
|
||||
caption: Optional[str] = None
|
||||
"""Caption of the document to be sent, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the document caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
description: Optional[str] = None
|
||||
"""Short description of the result"""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -38,8 +39,9 @@ class InlineQueryResultGif(InlineQueryResult):
|
|||
"""Title for the result"""
|
||||
caption: Optional[str] = None
|
||||
"""Caption of the GIF file to be sent, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""Inline keyboard attached to the message"""
|
||||
input_message_content: Optional[InputMessageContent] = None
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -39,8 +40,9 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
|
|||
"""Title for the result"""
|
||||
caption: Optional[str] = None
|
||||
"""Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""Inline keyboard attached to the message"""
|
||||
input_message_content: Optional[InputMessageContent] = None
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -38,8 +39,9 @@ class InlineQueryResultPhoto(InlineQueryResult):
|
|||
"""Short description of the result"""
|
||||
caption: Optional[str] = None
|
||||
"""Caption of the photo to be sent, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the photo caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""Inline keyboard attached to the message"""
|
||||
input_message_content: Optional[InputMessageContent] = None
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -36,8 +37,9 @@ class InlineQueryResultVideo(InlineQueryResult):
|
|||
"""Title for the result"""
|
||||
caption: Optional[str] = None
|
||||
"""Caption of the video to be sent, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the video caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
video_width: Optional[int] = None
|
||||
"""Video width"""
|
||||
video_height: Optional[int] = None
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .inline_query_result import InlineQueryResult
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -33,9 +34,9 @@ class InlineQueryResultVoice(InlineQueryResult):
|
|||
"""Recording title"""
|
||||
caption: Optional[str] = None
|
||||
"""Caption, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the voice message caption. See formatting options for more
|
||||
details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
voice_duration: Optional[int] = None
|
||||
"""Recording duration in seconds"""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional, Union
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .input_media import InputMedia
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -33,9 +34,9 @@ class InputMediaAnimation(InputMedia):
|
|||
multipart/form-data under <file_attach_name>."""
|
||||
caption: Optional[str] = None
|
||||
"""Caption of the animation to be sent, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the animation caption. See formatting options for more
|
||||
details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
width: Optional[int] = None
|
||||
"""Animation width"""
|
||||
height: Optional[int] = None
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional, Union
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .input_media import InputMedia
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -33,8 +34,9 @@ class InputMediaAudio(InputMedia):
|
|||
multipart/form-data under <file_attach_name>."""
|
||||
caption: Optional[str] = None
|
||||
"""Caption of the audio to be sent, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the audio caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
duration: Optional[int] = None
|
||||
"""Duration of the audio in seconds"""
|
||||
performer: Optional[str] = None
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional, Union
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .input_media import InputMedia
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -33,5 +34,6 @@ class InputMediaDocument(InputMedia):
|
|||
multipart/form-data under <file_attach_name>."""
|
||||
caption: Optional[str] = None
|
||||
"""Caption of the document to be sent, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the document caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional, Union
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .input_media import InputMedia
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -26,5 +27,6 @@ class InputMediaPhoto(InputMedia):
|
|||
<file_attach_name> name."""
|
||||
caption: Optional[str] = None
|
||||
"""Caption of the photo to be sent, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the photo caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional, Union
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import UNSET
|
||||
from .input_media import InputMedia
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
@ -33,8 +34,9 @@ class InputMediaVideo(InputMedia):
|
|||
multipart/form-data under <file_attach_name>."""
|
||||
caption: Optional[str] = None
|
||||
"""Caption of the video to be sent, 0-1024 characters after entities parsing"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the video caption. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in the media caption."""
|
||||
width: Optional[int] = None
|
||||
"""Video width"""
|
||||
height: Optional[int] = None
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
|||
|
||||
from typing import Optional
|
||||
|
||||
from .base import UNSET
|
||||
from .input_message_content import InputMessageContent
|
||||
|
||||
|
||||
|
|
@ -14,7 +15,8 @@ class InputTextMessageContent(InputMessageContent):
|
|||
|
||||
message_text: str
|
||||
"""Text of the message to be sent, 1-4096 characters"""
|
||||
parse_mode: Optional[str] = None
|
||||
"""Mode for parsing entities in the message text. See formatting options for more details."""
|
||||
parse_mode: Optional[str] = UNSET
|
||||
"""Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or
|
||||
inline URLs in your bot's message."""
|
||||
disable_web_page_preview: Optional[bool] = None
|
||||
"""Disables link previews for links in the sent message"""
|
||||
|
|
|
|||
|
|
@ -59,4 +59,4 @@ class TestPrepareParseMode:
|
|||
def test_bot_not_in_context(self):
|
||||
data = {}
|
||||
prepare_parse_mode(data)
|
||||
assert "parse_mode" not in data
|
||||
assert data["parse_mode"] is None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue