idk what's this (a lot of time ago)

This commit is contained in:
zemf4you 2024-08-22 09:59:38 +07:00
parent 7bd8f64630
commit fa1b891386
187 changed files with 914 additions and 915 deletions

View file

@ -21,6 +21,7 @@ import aiofiles
from aiogram.utils.token import extract_bot_id, validate_token
from ..enums import ParseMode
from ..methods import (
AddStickerToSet,
AnswerCallbackQuery,
@ -233,7 +234,7 @@ from ..types import (
UserProfilePhotos,
WebhookInfo,
)
from .default import Default, DefaultBotProperties
from .default import DefaultBotProperties
from .session.aiohttp import AiohttpSession
from .session.base import BaseSession
@ -274,8 +275,10 @@ class Bot:
if default is None:
default = DefaultBotProperties(
parse_mode=parse_mode,
link_preview_is_disabled=disable_web_page_preview,
protect_content=protect_content,
link_preview_options=LinkPreviewOptions(
is_disabled=disable_web_page_preview,
),
)
self.session = session
@ -311,11 +314,15 @@ class Bot:
def disable_web_page_preview(self) -> Optional[bool]:
warnings.warn(
"Accessing `disable_web_page_preview` from Bot instance is deprecated. This attribute will be removed in 3.5.0 version\n"
"Use `bot.default.link_preview_is_disabled` instead.",
"Use `bot.default.link_preview_options.is_disabled` instead.",
category=DeprecationWarning,
stacklevel=2,
)
return self.default.link_preview_is_disabled
return (
self.default.link_preview_options.is_disabled
if self.default.link_preview_options
else None
)
@property
def protect_content(self) -> Optional[bool]:
@ -856,10 +863,10 @@ class Bot:
message_id: int,
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1353,7 +1360,7 @@ class Bot:
message_id: Optional[int] = None,
inline_message_id: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
request_timeout: Optional[int] = None,
@ -1502,13 +1509,11 @@ class Bot:
chat_id: Optional[Union[int, str]] = None,
message_id: Optional[int] = None,
inline_message_id: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
entities: Optional[List[MessageEntity]] = None,
link_preview_options: Optional[LinkPreviewOptions] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
disable_web_page_preview: Optional[Union[bool, Default]] = Default(
"link_preview_is_disabled"
),
disable_web_page_preview: Optional[bool] = None,
request_timeout: Optional[int] = None,
) -> Union[Message, bool]:
"""
@ -1571,7 +1576,7 @@ class Bot:
message_id: int,
message_thread_id: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
request_timeout: Optional[int] = None,
) -> Message:
"""
@ -2190,11 +2195,11 @@ class Bot:
height: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2256,14 +2261,14 @@ class Bot:
audio: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
performer: Optional[str] = None,
title: Optional[str] = None,
thumbnail: Optional[InputFile] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2357,7 +2362,7 @@ class Bot:
last_name: Optional[str] = None,
vcard: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2409,7 +2414,7 @@ class Bot:
message_thread_id: Optional[int] = None,
emoji: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2456,11 +2461,11 @@ class Bot:
message_thread_id: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
disable_content_type_detection: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2516,7 +2521,7 @@ class Bot:
game_short_name: str,
message_thread_id: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
allow_sending_without_reply: Optional[bool] = None,
@ -2580,7 +2585,7 @@ class Bot:
send_email_to_provider: Optional[bool] = None,
is_flexible: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
allow_sending_without_reply: Optional[bool] = None,
@ -2669,7 +2674,7 @@ class Bot:
heading: Optional[int] = None,
proximity_alert_radius: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2725,7 +2730,7 @@ class Bot:
media: List[Union[InputMediaAudio, InputMediaDocument, InputMediaPhoto, InputMediaVideo]],
message_thread_id: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
allow_sending_without_reply: Optional[bool] = None,
reply_to_message_id: Optional[int] = None,
@ -2765,21 +2770,17 @@ class Bot:
chat_id: Union[int, str],
text: str,
message_thread_id: Optional[int] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
entities: Optional[List[MessageEntity]] = None,
link_preview_options: Optional[Union[LinkPreviewOptions, Default]] = Default(
"link_preview"
),
link_preview_options: Optional[LinkPreviewOptions] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None,
allow_sending_without_reply: Optional[bool] = None,
disable_web_page_preview: Optional[Union[bool, Default]] = Default(
"link_preview_is_disabled"
),
disable_web_page_preview: Optional[bool] = None,
reply_to_message_id: Optional[int] = None,
request_timeout: Optional[int] = None,
) -> Message:
@ -2828,11 +2829,11 @@ class Bot:
photo: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2891,13 +2892,13 @@ class Bot:
allows_multiple_answers: Optional[bool] = None,
correct_option_id: Optional[int] = None,
explanation: Optional[str] = None,
explanation_parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
explanation_parse_mode: Optional[ParseMode] = None,
explanation_entities: Optional[List[MessageEntity]] = None,
open_period: Optional[int] = None,
close_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None,
is_closed: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2966,7 +2967,7 @@ class Bot:
message_thread_id: Optional[int] = None,
emoji: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -3021,7 +3022,7 @@ class Bot:
google_place_id: Optional[str] = None,
google_place_type: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -3085,12 +3086,12 @@ class Bot:
height: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
supports_streaming: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -3157,7 +3158,7 @@ class Bot:
length: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -3209,11 +3210,11 @@ class Bot:
voice: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -1,46 +1,22 @@
from __future__ import annotations
import warnings
from typing import Optional
import sys
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, Dict, Optional
from pydantic import BaseModel, ConfigDict
if TYPE_CHECKING:
from aiogram.types import LinkPreviewOptions
from aiogram.enums import ParseMode
from aiogram.types import LinkPreviewOptions
# @dataclass ??
class Default:
# Is not a dataclass because of JSON serialization.
__slots__ = ("_name",)
def __init__(self, name: str) -> None:
self._name = name
@property
def name(self) -> str:
return self._name
def __str__(self) -> str:
return f"Default({self._name!r})"
def __repr__(self) -> str:
return f"<{self}>"
_dataclass_properties: Dict[str, Any] = {}
if sys.version_info >= (3, 10):
# Speedup attribute access for dataclasses in Python 3.10+
_dataclass_properties.update({"slots": True, "kw_only": True})
@dataclass(**_dataclass_properties)
class DefaultBotProperties:
class DefaultBotProperties(BaseModel):
"""
Default bot properties.
"""
parse_mode: Optional[str] = None
model_config = ConfigDict(
frozen=True,
)
parse_mode: Optional[ParseMode] = None
"""Default parse mode for messages."""
disable_notification: Optional[bool] = None
"""Sends the message silently. Users will receive a notification with no sound."""
@ -48,36 +24,60 @@ class DefaultBotProperties:
"""Protects content from copying."""
allow_sending_without_reply: Optional[bool] = None
"""Allows to send messages without reply."""
link_preview: Optional[LinkPreviewOptions] = None
link_preview_options: Optional[LinkPreviewOptions] = None
"""Link preview settings."""
link_preview_is_disabled: Optional[bool] = None
"""Disables link preview."""
link_preview_prefer_small_media: Optional[bool] = None
"""Prefer small media in link preview."""
link_preview_prefer_large_media: Optional[bool] = None
"""Prefer large media in link preview."""
link_preview_show_above_text: Optional[bool] = None
"""Show link preview above text."""
def __post_init__(self) -> None:
has_any_link_preview_option = any(
(
self.link_preview_is_disabled,
self.link_preview_prefer_small_media,
self.link_preview_prefer_large_media,
self.link_preview_show_above_text,
)
@property
def is_empty(self) -> bool:
return all(
getattr(self, field_name) == field_info.default
for field_name, field_info in self.model_fields.items()
)
if has_any_link_preview_option and self.link_preview is None:
from ..types import LinkPreviewOptions
self.link_preview = LinkPreviewOptions(
is_disabled=self.link_preview_is_disabled,
prefer_small_media=self.link_preview_prefer_small_media,
prefer_large_media=self.link_preview_prefer_large_media,
show_above_text=self.link_preview_show_above_text,
def __init__(
self,
*,
parse_mode: Optional[ParseMode] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[bool] = None,
allow_sending_without_reply: Optional[bool] = None,
link_preview: Optional[LinkPreviewOptions] = None,
link_preview_options: Optional[LinkPreviewOptions] = None,
link_preview_is_disabled: Optional[bool] = None,
link_preview_prefer_small_media: Optional[bool] = None,
link_preview_prefer_large_media: Optional[bool] = None,
link_preview_show_above_text: Optional[bool] = None,
):
has_any_link_preview_option = any(
(
link_preview_is_disabled,
link_preview_prefer_small_media,
link_preview_prefer_large_media,
link_preview_show_above_text,
)
def __getitem__(self, item: str) -> Any:
return getattr(self, item, None)
)
if has_any_link_preview_option:
warnings.warn(
"Passing `link_preview_is_disabled`, `link_preview_prefer_small_media`, "
"`link_preview_prefer_large_media`, and `link_preview_show_above_text` "
"to DefaultBotProperties initializer is deprecated. "
"These arguments will be removed in 3.7.0 version\n"
"Use `link_preview` instead.",
category=DeprecationWarning,
stacklevel=2,
)
if link_preview:
warnings.warn(
"Passing `link_preview` to DefaultBotProperties initializer is deprecated. "
"This argument will be removed in 3.7.0 version\n"
"Use `link_preview_options` instead.",
category=DeprecationWarning,
stacklevel=2,
)
super().__init__(
parse_mode=parse_mode,
disable_notification=disable_notification,
protect_content=protect_content,
allow_sending_without_reply=allow_sending_without_reply,
link_preview_options=link_preview_options or link_preview,
)

View file

@ -1,62 +1,90 @@
from __future__ import annotations
import secrets
import typing
from typing import Any, Dict, Optional, Tuple
from typing import TYPE_CHECKING, Any, Dict, List, Tuple
from pydantic import BaseModel
from pydantic_core import to_json
from aiogram.client.default import DefaultBotProperties
from aiogram.default_annotations import get_default_prop_name, is_default_prop
from aiogram.types import InputFile
M = typing.TypeVar("M", bound=BaseModel)
if TYPE_CHECKING:
from aiogram import Bot
def _extract_files(value: Any) -> Tuple[Any, Dict[str, InputFile]]:
files = {}
# Handle input file
def extract_files_from_any(value: Any) -> Tuple[Any, Dict[str, InputFile]]:
if isinstance(value, InputFile):
token = secrets.token_urlsafe(10)
files[token] = value
return f"attach://{token}", files
# Handle nested models
return f"attach://{token}", {token: value}
if isinstance(value, BaseModel):
modified_nested_model, nested_files = extract_files(value, files)
files.update(nested_files)
return modified_nested_model, files
return value, files
return extract_files_from_model(value)
if isinstance(value, list):
return extract_files_from_list(value)
if isinstance(value, dict):
return extract_files_from_dict(value)
# TODO: add more collections if needed
return value, {}
def extract_files(
model: M,
files: Optional[Dict[str, InputFile]] = None,
) -> Tuple[M, Dict[str, InputFile]]:
if files is None:
files = {}
def extract_files_from_list(_list: List) -> Tuple[List, Dict[str, InputFile]]:
modified_list = []
list_files = {}
for item in _list:
modified_item, item_files = extract_files_from_any(item)
modified_list.append(modified_item)
list_files.update(item_files)
return modified_list, list_files
def extract_files_from_dict(_dict: Dict) -> Tuple[Dict, Dict[str, InputFile]]:
modified_dict = {}
dict_files = {}
for key, value in _dict.items():
modified_value, value_files = extract_files_from_any(value)
modified_dict[key] = modified_value
dict_files.update(value_files)
return modified_dict, dict_files
def extract_files_from_model(model: BaseModel) -> Tuple[BaseModel, Dict[str, InputFile]]:
model_files = {}
update = {}
for field_name, field_value in model:
modified_field_value, nested_files = _extract_files(field_value)
update[field_name] = modified_field_value
files.update(nested_files)
# Handle nested models inside of lists (media groups)
if isinstance(field_value, list):
update[field_name] = []
for item in field_value:
modified_item, nested_item_files = _extract_files(item)
update[field_name].append(modified_item)
files.update(nested_item_files)
continue
modified_value, field_files = extract_files_from_any(field_value)
if field_files:
model_files.update(field_files)
update[field_name] = modified_value
modified_model = model.model_copy(update=update)
return modified_model, files
return modified_model, model_files
def form_serialize(value: Any) -> str:
def replace_default_props(model: BaseModel, *, props: DefaultBotProperties) -> BaseModel:
if props.is_empty:
return model
update = {}
for field_name, field_info in model.model_fields.items():
field_value = getattr(model, field_name)
if is_default_prop(field_info):
default_name = get_default_prop_name(field_info)
default_value = getattr(props, default_name)
if field_value is None and default_value is not None:
update[field_name] = default_value
# TODO
return model.model_copy(update=update)
def construct_form_data(model: BaseModel, bot: Bot) -> Tuple[Dict[str, str], Dict[str, InputFile]]:
form_data = {}
model, files = extract_files_from_model(model)
model = replace_default_props(model, props=bot.default)
for key, value in model.model_dump(exclude_none=True).items():
form_data[key] = serialize_form_value(value)
return form_data, files
def serialize_form_value(value: Any) -> str:
"""
Prepare jsonable value to send
"""

View file

@ -26,7 +26,7 @@ from aiogram.methods import TelegramMethod
from ...exceptions import TelegramNetworkError
from ...methods.base import TelegramType
from ..form import extract_files, form_serialize
from ..form import construct_form_data
from .base import BaseSession
if TYPE_CHECKING:
@ -144,10 +144,9 @@ class AiohttpSession(BaseSession):
def build_form_data(self, bot: Bot, method: TelegramMethod[TelegramType]) -> FormData:
form = FormData(quote_fields=False)
modified_method, files = extract_files(method)
for key, value in modified_method.model_dump(mode="json", exclude_none=True).items():
form.add_field(key, form_serialize(value))
data, files = construct_form_data(method, bot=bot)
for key, value in data.items():
form.add_field(key, value)
for key, file in files.items():
form.add_field(
key,

View file

@ -77,7 +77,8 @@ class BaseSession(abc.ABC):
warnings.warn(
"Custom json de/serializers are no longer supported.\n"
"Using pydantic_core.to_json and pydantic_core.from_json instead.",
DeprecationWarning,
category=DeprecationWarning,
stacklevel=2,
)
def check_response(

View file

@ -0,0 +1,31 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Annotated, ForwardRef, Optional
from pydantic.fields import FieldInfo
from aiogram.enums import ParseMode
if TYPE_CHECKING:
from aiogram.types import LinkPreviewOptions as _LinkPreviewOptions
else:
_LinkPreviewOptions = ForwardRef("LinkPreviewOptions") # noqa
DefaultParseMode = Annotated[Optional[ParseMode], "default", "parse_mode"]
DefaultDisableNotification = Annotated[Optional[bool], "default", "disable_notification"]
DefaultProtectContent = Annotated[Optional[bool], "default", "protect_content"]
DefaultAllowSendingWithoutReply = Annotated[
Optional[bool], "default", "allow_sending_without_reply"
]
DefaultLinkPreviewOptions = Annotated[
Optional[_LinkPreviewOptions], "default", "link_preview_options"
]
def is_default_prop(info: FieldInfo) -> bool:
return "default" in info.metadata
def get_default_prop_name(info: FieldInfo) -> str:
name_index = info.metadata.index("default") + 1
return info.metadata[name_index]

View file

@ -7,7 +7,7 @@ from aiogram.dispatcher.middlewares.manager import MiddlewareManager
from ...exceptions import UnsupportedKeywordArgument
from ...filters.base import Filter
from ...types import TelegramObject
from .bases import REJECTED, UNHANDLED, MiddlewareType, SkipHandler
from .bases import UNHANDLED, MiddlewareType, SkipHandler
from .handler import CallbackType, FilterObject, HandlerObject
if TYPE_CHECKING:

View file

@ -12,7 +12,7 @@ from typing import (
TypeVar,
)
from pydantic import BaseModel, ConfigDict
from pydantic import BaseModel
from ..types import InputFile, ResponseParameters
from ..types.base import MutableTelegramObject
@ -24,8 +24,6 @@ TelegramType = TypeVar("TelegramType", bound=Any)
class Request(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True)
method: str
data: Dict[str, Optional[Any]]

View file

@ -4,7 +4,13 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultParseMode,
DefaultProtectContent,
)
from ..enums import ParseMode
from ..types import (
ForceReply,
InlineKeyboardMarkup,
@ -37,13 +43,13 @@ class CopyMessage(TelegramMethod[MessageId]):
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
caption: Optional[str] = None
"""New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""Mode for parsing entities in the new caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""A JSON-serialized list of special entities that appear in the new caption, which can be specified instead of *parse_mode*"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -76,10 +82,10 @@ class CopyMessage(TelegramMethod[MessageId]):
message_id: int,
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -1,5 +1,10 @@
from typing import TYPE_CHECKING, Any, List, Optional, Union
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultProtectContent,
)
from ..types import MessageId
from .base import TelegramMethod
@ -22,9 +27,9 @@ class CopyMessages(TelegramMethod[List[MessageId]]):
"""Identifiers of 1-100 messages in the chat *from_chat_id* to copy. The identifiers must be specified in a strictly increasing order."""
message_thread_id: Optional[int] = None
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the messages `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[bool] = None
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent messages from forwarding and saving"""
remove_caption: Optional[bool] = None
"""Pass :code:`True` to copy the messages without their captions"""

View file

@ -2,8 +2,10 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Optional, Union
from ..client.default import Default
from ..types import UNSET_PARSE_MODE, InlineKeyboardMarkup, Message, MessageEntity
from aiogram.default_annotations import DefaultParseMode
from ..enums import ParseMode
from ..types import InlineKeyboardMarkup, Message, MessageEntity
from .base import TelegramMethod
@ -25,7 +27,7 @@ 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[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""Mode for parsing entities in the message caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -43,7 +45,7 @@ class EditMessageCaption(TelegramMethod[Union[Message, bool]]):
message_id: Optional[int] = None,
inline_message_id: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
**__pydantic_kwargs: Any,

View file

@ -4,14 +4,10 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from ..types import (
UNSET_PARSE_MODE,
InlineKeyboardMarkup,
LinkPreviewOptions,
Message,
MessageEntity,
)
from aiogram.default_annotations import DefaultLinkPreviewOptions, DefaultParseMode
from ..enums import ParseMode
from ..types import InlineKeyboardMarkup, LinkPreviewOptions, Message, MessageEntity
from .base import TelegramMethod
@ -33,17 +29,15 @@ 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[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""Mode for parsing entities in the message text. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
entities: Optional[List[MessageEntity]] = None
"""A JSON-serialized list of special entities that appear in message text, which can be specified instead of *parse_mode*"""
link_preview_options: Optional[LinkPreviewOptions] = None
link_preview_options: DefaultLinkPreviewOptions = None
"""Link preview generation options for the message"""
reply_markup: Optional[InlineKeyboardMarkup] = None
"""A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots/features#inline-keyboards>`_."""
disable_web_page_preview: Optional[Union[bool, Default]] = Field(
Default("link_preview_is_disabled"), json_schema_extra={"deprecated": True}
)
disable_web_page_preview: Optional[bool] = Field(None, json_schema_extra={"deprecated": True})
"""Disables link previews for links in this message
.. deprecated:: API:7.0
@ -60,13 +54,10 @@ class EditMessageText(TelegramMethod[Union[Message, bool]]):
chat_id: Optional[Union[int, str]] = None,
message_id: Optional[int] = None,
inline_message_id: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
entities: Optional[List[MessageEntity]] = None,
link_preview_options: Optional[LinkPreviewOptions] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
disable_web_page_preview: Optional[Union[bool, Default]] = Default(
"link_preview_is_disabled"
),
**__pydantic_kwargs: Any,
) -> None:
# DO NOT EDIT MANUALLY!!!
@ -82,6 +73,5 @@ class EditMessageText(TelegramMethod[Union[Message, bool]]):
entities=entities,
link_preview_options=link_preview_options,
reply_markup=reply_markup,
disable_web_page_preview=disable_web_page_preview,
**__pydantic_kwargs,
)

View file

@ -2,9 +2,12 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, Optional, Union
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultProtectContent,
)
from ..types import Message
from ..types.base import UNSET_PROTECT_CONTENT
from .base import TelegramMethod
@ -26,9 +29,9 @@ class ForwardMessage(TelegramMethod[Message]):
"""Message identifier in the chat specified in *from_chat_id*"""
message_thread_id: Optional[int] = None
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the forwarded message from forwarding and saving"""
if TYPE_CHECKING:
@ -43,7 +46,7 @@ class ForwardMessage(TelegramMethod[Message]):
message_id: int,
message_thread_id: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
**__pydantic_kwargs: Any,
) -> None:
# DO NOT EDIT MANUALLY!!!

View file

@ -1,5 +1,10 @@
from typing import TYPE_CHECKING, Any, List, Optional, Union
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultProtectContent,
)
from ..types import MessageId
from .base import TelegramMethod
@ -22,9 +27,9 @@ class ForwardMessages(TelegramMethod[List[MessageId]]):
"""Identifiers of 1-100 messages in the chat *from_chat_id* to forward. The identifiers must be specified in a strictly increasing order."""
message_thread_id: Optional[int] = None
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the messages `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[bool] = None
protect_content: DefaultProtectContent = None
"""Protects the contents of the forwarded messages from forwarding and saving"""
if TYPE_CHECKING:

View file

@ -2,6 +2,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, Optional, Union
from ..default_annotations import DefaultDisableNotification
from .base import TelegramMethod
@ -19,7 +20,7 @@ class PinChatMessage(TelegramMethod[bool]):
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
message_id: int
"""Identifier of a message to pin"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Pass :code:`True` if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels and private chats."""
if TYPE_CHECKING:

View file

@ -4,9 +4,14 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultParseMode,
DefaultProtectContent,
)
from ..enums import ParseMode
from ..types import (
UNSET_PARSE_MODE,
ForceReply,
InlineKeyboardMarkup,
InputFile,
@ -45,15 +50,15 @@ class SendAnimation(TelegramMethod[Message]):
"""Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More information on Sending Files » <sending-files>`"""
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[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""Mode for parsing entities in the animation caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
has_spoiler: Optional[bool] = None
"""Pass :code:`True` if the animation needs to be covered with a spoiler animation"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -89,11 +94,11 @@ class SendAnimation(TelegramMethod[Message]):
height: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -4,7 +4,13 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultParseMode,
DefaultProtectContent,
)
from ..enums import ParseMode
from ..types import (
ForceReply,
InlineKeyboardMarkup,
@ -37,7 +43,7 @@ class SendAudio(TelegramMethod[Message]):
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
caption: Optional[str] = None
"""Audio caption, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""Mode for parsing entities in the audio caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -49,9 +55,9 @@ class SendAudio(TelegramMethod[Message]):
"""Track name"""
thumbnail: Optional[InputFile] = None
"""Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More information on Sending Files » <sending-files>`"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -83,14 +89,14 @@ class SendAudio(TelegramMethod[Message]):
audio: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
performer: Optional[str] = None,
title: Optional[str] = None,
thumbnail: Optional[InputFile] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -4,7 +4,11 @@ from typing import TYPE_CHECKING, Any, Optional, Union
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultProtectContent,
)
from ..types import (
ForceReply,
InlineKeyboardMarkup,
@ -38,9 +42,9 @@ class SendContact(TelegramMethod[Message]):
"""Contact's last name"""
vcard: Optional[str] = None
"""Additional data about the contact in the form of a `vCard <https://en.wikipedia.org/wiki/VCard>`_, 0-2048 bytes"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -75,7 +79,7 @@ class SendContact(TelegramMethod[Message]):
last_name: Optional[str] = None,
vcard: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -4,7 +4,11 @@ from typing import TYPE_CHECKING, Any, Optional, Union
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultProtectContent,
)
from ..types import (
ForceReply,
InlineKeyboardMarkup,
@ -32,9 +36,9 @@ class SendDice(TelegramMethod[Message]):
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
emoji: Optional[str] = None
"""Emoji on which the dice throw animation is based. Currently, must be one of '🎲', '🎯', '🏀', '', '🎳', or '🎰'. Dice can have values 1-6 for '🎲', '🎯' and '🎳', values 1-5 for '🏀' and '', and values 1-64 for '🎰'. Defaults to '🎲'"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent message from forwarding"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -66,7 +70,7 @@ class SendDice(TelegramMethod[Message]):
message_thread_id: Optional[int] = None,
emoji: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -4,9 +4,14 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultParseMode,
DefaultProtectContent,
)
from ..enums import ParseMode
from ..types import (
UNSET_PARSE_MODE,
ForceReply,
InlineKeyboardMarkup,
InputFile,
@ -39,15 +44,15 @@ class SendDocument(TelegramMethod[Message]):
"""Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More information on Sending Files » <sending-files>`"""
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[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""Mode for parsing entities in the document caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
disable_content_type_detection: Optional[bool] = None
"""Disables automatic server-side content type detection for files uploaded using multipart/form-data"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -80,11 +85,11 @@ class SendDocument(TelegramMethod[Message]):
message_thread_id: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
disable_content_type_detection: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -1,10 +1,14 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Optional, Union
from typing import TYPE_CHECKING, Any, Optional
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultProtectContent,
)
from ..types import InlineKeyboardMarkup, Message, ReplyParameters
from .base import TelegramMethod
@ -25,9 +29,9 @@ class SendGame(TelegramMethod[Message]):
"""Short name of the game, serves as the unique identifier for the game. Set up your games via `@BotFather <https://t.me/botfather>`_."""
message_thread_id: Optional[int] = None
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -57,7 +61,7 @@ class SendGame(TelegramMethod[Message]):
game_short_name: str,
message_thread_id: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
allow_sending_without_reply: Optional[bool] = None,

View file

@ -4,7 +4,11 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultProtectContent,
)
from ..types import InlineKeyboardMarkup, LabeledPrice, Message, ReplyParameters
from .base import TelegramMethod
@ -65,9 +69,9 @@ class SendInvoice(TelegramMethod[Message]):
"""Pass :code:`True` if the user's email address should be sent to provider"""
is_flexible: Optional[bool] = None
"""Pass :code:`True` if the final price depends on the shipping method"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -117,7 +121,7 @@ class SendInvoice(TelegramMethod[Message]):
send_email_to_provider: Optional[bool] = None,
is_flexible: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
allow_sending_without_reply: Optional[bool] = None,

View file

@ -4,7 +4,11 @@ from typing import TYPE_CHECKING, Any, Optional, Union
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultProtectContent,
)
from ..types import (
ForceReply,
InlineKeyboardMarkup,
@ -42,9 +46,9 @@ class SendLocation(TelegramMethod[Message]):
"""For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified."""
proximity_alert_radius: Optional[int] = None
"""For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified."""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -81,7 +85,7 @@ class SendLocation(TelegramMethod[Message]):
heading: Optional[int] = None,
proximity_alert_radius: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -4,7 +4,11 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultProtectContent,
)
from ..types import (
InputMediaAudio,
InputMediaDocument,
@ -32,9 +36,9 @@ class SendMediaGroup(TelegramMethod[List[Message]]):
"""A JSON-serialized array describing messages to be sent, must include 2-10 items"""
message_thread_id: Optional[int] = None
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends messages `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent messages from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -64,7 +68,7 @@ class SendMediaGroup(TelegramMethod[List[Message]]):
],
message_thread_id: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
allow_sending_without_reply: Optional[bool] = None,
reply_to_message_id: Optional[int] = None,

View file

@ -4,7 +4,14 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultLinkPreviewOptions,
DefaultParseMode,
DefaultProtectContent,
)
from ..enums import ParseMode
from ..types import (
ForceReply,
InlineKeyboardMarkup,
@ -34,15 +41,15 @@ class SendMessage(TelegramMethod[Message]):
"""Text of the message to be sent, 1-4096 characters after entities parsing"""
message_thread_id: Optional[int] = None
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""Mode for parsing entities in the message text. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
entities: Optional[List[MessageEntity]] = None
"""A JSON-serialized list of special entities that appear in message text, which can be specified instead of *parse_mode*"""
link_preview_options: Optional[Union[LinkPreviewOptions, Default]] = Default("link_preview")
link_preview_options: DefaultLinkPreviewOptions = None
"""Link preview generation options for the message"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -57,9 +64,7 @@ class SendMessage(TelegramMethod[Message]):
.. deprecated:: API:7.0
https://core.telegram.org/bots/api-changelog#december-29-2023"""
disable_web_page_preview: Optional[Union[bool, Default]] = Field(
Default("link_preview_is_disabled"), json_schema_extra={"deprecated": True}
)
disable_web_page_preview: Optional[bool] = Field(None, json_schema_extra={"deprecated": True})
"""Disables link previews for links in this message
.. deprecated:: API:7.0
@ -80,21 +85,17 @@ class SendMessage(TelegramMethod[Message]):
chat_id: Union[int, str],
text: str,
message_thread_id: Optional[int] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
entities: Optional[List[MessageEntity]] = None,
link_preview_options: Optional[Union[LinkPreviewOptions, Default]] = Default(
"link_preview"
),
link_preview_options: Optional[LinkPreviewOptions] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None,
allow_sending_without_reply: Optional[bool] = None,
disable_web_page_preview: Optional[Union[bool, Default]] = Default(
"link_preview_is_disabled"
),
disable_web_page_preview: Optional[bool] = None,
reply_to_message_id: Optional[int] = None,
**__pydantic_kwargs: Any,
) -> None:

View file

@ -4,9 +4,14 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultParseMode,
DefaultProtectContent,
)
from ..enums import ParseMode
from ..types import (
UNSET_PARSE_MODE,
ForceReply,
InlineKeyboardMarkup,
InputFile,
@ -37,15 +42,15 @@ class SendPhoto(TelegramMethod[Message]):
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
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[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""Mode for parsing entities in the photo caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
has_spoiler: Optional[bool] = None
"""Pass :code:`True` if the photo needs to be covered with a spoiler animation"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -77,11 +82,11 @@ class SendPhoto(TelegramMethod[Message]):
photo: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -5,7 +5,13 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultParseMode,
DefaultProtectContent,
)
from ..enums import ParseMode
from ..types import (
DateTime,
ForceReply,
@ -47,7 +53,7 @@ class SendPoll(TelegramMethod[Message]):
"""0-based identifier of the correct answer option, required for polls in quiz mode"""
explanation: Optional[str] = None
"""Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing"""
explanation_parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
explanation_parse_mode: DefaultParseMode = None
"""Mode for parsing entities in the explanation. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
explanation_entities: Optional[List[MessageEntity]] = None
"""A JSON-serialized list of special entities that appear in the poll explanation, which can be specified instead of *parse_mode*"""
@ -57,9 +63,9 @@ class SendPoll(TelegramMethod[Message]):
"""Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can't be used together with *open_period*."""
is_closed: Optional[bool] = None
"""Pass :code:`True` if the poll needs to be immediately closed. This can be useful for poll preview."""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -96,13 +102,13 @@ class SendPoll(TelegramMethod[Message]):
allows_multiple_answers: Optional[bool] = None,
correct_option_id: Optional[int] = None,
explanation: Optional[str] = None,
explanation_parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
explanation_parse_mode: Optional[ParseMode] = None,
explanation_entities: Optional[List[MessageEntity]] = None,
open_period: Optional[int] = None,
close_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None,
is_closed: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -4,7 +4,11 @@ from typing import TYPE_CHECKING, Any, Optional, Union
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultProtectContent,
)
from ..types import (
ForceReply,
InlineKeyboardMarkup,
@ -35,9 +39,9 @@ class SendSticker(TelegramMethod[Message]):
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
emoji: Optional[str] = None
"""Emoji associated with the sticker; only for just uploaded stickers"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -70,7 +74,7 @@ class SendSticker(TelegramMethod[Message]):
message_thread_id: Optional[int] = None,
emoji: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -4,7 +4,11 @@ from typing import TYPE_CHECKING, Any, Optional, Union
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultProtectContent,
)
from ..types import (
ForceReply,
InlineKeyboardMarkup,
@ -46,9 +50,9 @@ class SendVenue(TelegramMethod[Message]):
"""Google Places identifier of the venue"""
google_place_type: Optional[str] = None
"""Google Places type of the venue. (See `supported types <https://developers.google.com/places/web-service/supported_types>`_.)"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -87,7 +91,7 @@ class SendVenue(TelegramMethod[Message]):
google_place_id: Optional[str] = None,
google_place_type: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -4,9 +4,14 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultParseMode,
DefaultProtectContent,
)
from ..enums import ParseMode
from ..types import (
UNSET_PARSE_MODE,
ForceReply,
InlineKeyboardMarkup,
InputFile,
@ -45,7 +50,7 @@ class SendVideo(TelegramMethod[Message]):
"""Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More information on Sending Files » <sending-files>`"""
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[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""Mode for parsing entities in the video caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -53,9 +58,9 @@ class SendVideo(TelegramMethod[Message]):
"""Pass :code:`True` if the video needs to be covered with a spoiler animation"""
supports_streaming: Optional[bool] = None
"""Pass :code:`True` if the uploaded video is suitable for streaming"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -91,12 +96,12 @@ class SendVideo(TelegramMethod[Message]):
height: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
supports_streaming: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -4,7 +4,11 @@ from typing import TYPE_CHECKING, Any, Optional, Union
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultProtectContent,
)
from ..types import (
ForceReply,
InlineKeyboardMarkup,
@ -39,9 +43,9 @@ class SendVideoNote(TelegramMethod[Message]):
"""Video width and height, i.e. diameter of the video message"""
thumbnail: Optional[InputFile] = None
"""Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More information on Sending Files » <sending-files>`"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -76,7 +80,7 @@ class SendVideoNote(TelegramMethod[Message]):
length: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -4,9 +4,14 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import (
DefaultDisableNotification,
DefaultParseMode,
DefaultProtectContent,
)
from ..enums import ParseMode
from ..types import (
UNSET_PARSE_MODE,
ForceReply,
InlineKeyboardMarkup,
InputFile,
@ -37,15 +42,15 @@ class SendVoice(TelegramMethod[Message]):
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
caption: Optional[str] = None
"""Voice message caption, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""Mode for parsing entities in the voice message caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
duration: Optional[int] = None
"""Duration of the voice message in seconds"""
disable_notification: Optional[bool] = None
disable_notification: DefaultDisableNotification = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
protect_content: DefaultProtectContent = None
"""Protects the contents of the sent message from forwarding and saving"""
reply_parameters: Optional[ReplyParameters] = None
"""Description of the message to reply to"""
@ -77,11 +82,11 @@ class SendVoice(TelegramMethod[Message]):
voice: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -2,7 +2,7 @@ from typing import List, Literal, Optional, Union
from .animation import Animation
from .audio import Audio
from .base import UNSET_PARSE_MODE, TelegramObject
from .base import TelegramObject
from .bot_command import BotCommand
from .bot_command_scope import BotCommandScope
from .bot_command_scope_all_chat_administrators import (
@ -367,7 +367,6 @@ __all__ = (
"SwitchInlineQueryChosenChat",
"TelegramObject",
"TextQuote",
"UNSET_PARSE_MODE",
"URLInputFile",
"Update",
"User",

View file

@ -1,16 +1,9 @@
from typing import Any, Dict, Union
from typing import Any, Dict
from unittest.mock import sentinel
from pydantic import (
BaseModel,
ConfigDict,
SerializerFunctionWrapHandler,
model_serializer,
model_validator,
)
from pydantic import BaseModel, ConfigDict, model_validator
from aiogram.client.context_controller import BotContextController
from aiogram.client.default import Default, DefaultBotProperties
class TelegramObject(BotContextController, BaseModel):
@ -20,7 +13,7 @@ class TelegramObject(BotContextController, BaseModel):
validate_assignment=True,
frozen=True,
populate_by_name=True,
arbitrary_types_allowed=True,
arbitrary_types_allowed=False, # Forced!
defer_build=True,
)
@ -39,22 +32,6 @@ class TelegramObject(BotContextController, BaseModel):
return values
return {k: v for k, v in values.items() if not isinstance(v, UNSET_TYPE)}
@model_serializer(mode="wrap", when_used="json")
def json_serialize(
self, serializer: SerializerFunctionWrapHandler
) -> Union[Dict[str, Any], Any]:
"""
Replacing `Default` placeholders with actual values from bot defaults.
Ensures JSON serialization backward compatibility by handling non-standard objects.
"""
if not isinstance(self, TelegramObject):
return serializer(self) # Can be passed when using Union[Any, TelegramObject]
properties = self.bot.default if self.bot else DefaultBotProperties()
default_fields = {
key: properties[value.name] for key, value in self if isinstance(value, Default)
}
return serializer(self.model_copy(update=default_fields))
class MutableTelegramObject(TelegramObject):
model_config = ConfigDict(
@ -65,9 +42,3 @@ class MutableTelegramObject(TelegramObject):
# special sentinel object which used in a situation when None might be a useful value
UNSET: Any = sentinel.UNSET
UNSET_TYPE: Any = type(UNSET)
# Unused constants are needed only for backward compatibility with external
# libraries that a working with framework internals
UNSET_PARSE_MODE: Any = Default("parse_mode")
UNSET_DISABLE_WEB_PAGE_PREVIEW: Any = Default("link_preview_is_disabled")
UNSET_PROTECT_CONTENT: Any = Default("protect_content")

View file

@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from ..enums import ParseMode
from .base import TelegramObject
from .custom import DateTime
@ -158,21 +158,17 @@ class ChatJoinRequest(TelegramObject):
self,
text: str,
message_thread_id: Optional[int] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
entities: Optional[List[MessageEntity]] = None,
link_preview_options: Optional[Union[LinkPreviewOptions, Default]] = Default(
"link_preview"
),
link_preview_options: Optional[LinkPreviewOptions] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None,
allow_sending_without_reply: Optional[bool] = None,
disable_web_page_preview: Optional[Union[bool, Default]] = Default(
"link_preview_is_disabled"
),
disable_web_page_preview: Optional[bool] = None,
reply_to_message_id: Optional[int] = None,
**kwargs: Any,
) -> SendMessage:
@ -226,21 +222,17 @@ class ChatJoinRequest(TelegramObject):
self,
text: str,
message_thread_id: Optional[int] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
entities: Optional[List[MessageEntity]] = None,
link_preview_options: Optional[Union[LinkPreviewOptions, Default]] = Default(
"link_preview"
),
link_preview_options: Optional[LinkPreviewOptions] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None,
allow_sending_without_reply: Optional[bool] = None,
disable_web_page_preview: Optional[Union[bool, Default]] = Default(
"link_preview_is_disabled"
),
disable_web_page_preview: Optional[bool] = None,
reply_to_message_id: Optional[int] = None,
**kwargs: Any,
) -> SendMessage:
@ -299,11 +291,11 @@ class ChatJoinRequest(TelegramObject):
height: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -375,11 +367,11 @@ class ChatJoinRequest(TelegramObject):
height: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -447,14 +439,14 @@ class ChatJoinRequest(TelegramObject):
audio: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
performer: Optional[str] = None,
title: Optional[str] = None,
thumbnail: Optional[InputFile] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -521,14 +513,14 @@ class ChatJoinRequest(TelegramObject):
audio: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
performer: Optional[str] = None,
title: Optional[str] = None,
thumbnail: Optional[InputFile] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -598,7 +590,7 @@ class ChatJoinRequest(TelegramObject):
last_name: Optional[str] = None,
vcard: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -659,7 +651,7 @@ class ChatJoinRequest(TelegramObject):
last_name: Optional[str] = None,
vcard: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -718,11 +710,11 @@ class ChatJoinRequest(TelegramObject):
message_thread_id: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
disable_content_type_detection: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -785,11 +777,11 @@ class ChatJoinRequest(TelegramObject):
message_thread_id: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
disable_content_type_detection: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -851,7 +843,7 @@ class ChatJoinRequest(TelegramObject):
game_short_name: str,
message_thread_id: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
allow_sending_without_reply: Optional[bool] = None,
@ -901,7 +893,7 @@ class ChatJoinRequest(TelegramObject):
game_short_name: str,
message_thread_id: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
allow_sending_without_reply: Optional[bool] = None,
@ -971,7 +963,7 @@ class ChatJoinRequest(TelegramObject):
send_email_to_provider: Optional[bool] = None,
is_flexible: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
allow_sending_without_reply: Optional[bool] = None,
@ -1081,7 +1073,7 @@ class ChatJoinRequest(TelegramObject):
send_email_to_provider: Optional[bool] = None,
is_flexible: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
allow_sending_without_reply: Optional[bool] = None,
@ -1176,7 +1168,7 @@ class ChatJoinRequest(TelegramObject):
heading: Optional[int] = None,
proximity_alert_radius: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1243,7 +1235,7 @@ class ChatJoinRequest(TelegramObject):
heading: Optional[int] = None,
proximity_alert_radius: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1305,7 +1297,7 @@ class ChatJoinRequest(TelegramObject):
media: List[Union[InputMediaAudio, InputMediaDocument, InputMediaPhoto, InputMediaVideo]],
message_thread_id: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
allow_sending_without_reply: Optional[bool] = None,
reply_to_message_id: Optional[int] = None,
@ -1352,7 +1344,7 @@ class ChatJoinRequest(TelegramObject):
media: List[Union[InputMediaAudio, InputMediaDocument, InputMediaPhoto, InputMediaVideo]],
message_thread_id: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
allow_sending_without_reply: Optional[bool] = None,
reply_to_message_id: Optional[int] = None,
@ -1399,11 +1391,11 @@ class ChatJoinRequest(TelegramObject):
photo: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1463,11 +1455,11 @@ class ChatJoinRequest(TelegramObject):
photo: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1532,13 +1524,13 @@ class ChatJoinRequest(TelegramObject):
allows_multiple_answers: Optional[bool] = None,
correct_option_id: Optional[int] = None,
explanation: Optional[str] = None,
explanation_parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
explanation_parse_mode: Optional[ParseMode] = None,
explanation_entities: Optional[List[MessageEntity]] = None,
open_period: Optional[int] = None,
close_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None,
is_closed: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1617,13 +1609,13 @@ class ChatJoinRequest(TelegramObject):
allows_multiple_answers: Optional[bool] = None,
correct_option_id: Optional[int] = None,
explanation: Optional[str] = None,
explanation_parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
explanation_parse_mode: Optional[ParseMode] = None,
explanation_entities: Optional[List[MessageEntity]] = None,
open_period: Optional[int] = None,
close_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None,
is_closed: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1697,7 +1689,7 @@ class ChatJoinRequest(TelegramObject):
message_thread_id: Optional[int] = None,
emoji: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1749,7 +1741,7 @@ class ChatJoinRequest(TelegramObject):
message_thread_id: Optional[int] = None,
emoji: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1802,7 +1794,7 @@ class ChatJoinRequest(TelegramObject):
message_thread_id: Optional[int] = None,
emoji: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1857,7 +1849,7 @@ class ChatJoinRequest(TelegramObject):
message_thread_id: Optional[int] = None,
emoji: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1918,7 +1910,7 @@ class ChatJoinRequest(TelegramObject):
google_place_id: Optional[str] = None,
google_place_type: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1991,7 +1983,7 @@ class ChatJoinRequest(TelegramObject):
google_place_id: Optional[str] = None,
google_place_type: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2061,12 +2053,12 @@ class ChatJoinRequest(TelegramObject):
height: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
supports_streaming: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2140,12 +2132,12 @@ class ChatJoinRequest(TelegramObject):
height: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
supports_streaming: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2218,7 +2210,7 @@ class ChatJoinRequest(TelegramObject):
length: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2279,7 +2271,7 @@ class ChatJoinRequest(TelegramObject):
length: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2337,11 +2329,11 @@ class ChatJoinRequest(TelegramObject):
voice: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2401,11 +2393,11 @@ class ChatJoinRequest(TelegramObject):
voice: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from pydantic import Field
from ..client.default import Default
from ..enums import ParseMode
from .base import TelegramObject
from .custom import DateTime
@ -138,21 +138,17 @@ class ChatMemberUpdated(TelegramObject):
self,
text: str,
message_thread_id: Optional[int] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
entities: Optional[List[MessageEntity]] = None,
link_preview_options: Optional[Union[LinkPreviewOptions, Default]] = Default(
"link_preview"
),
link_preview_options: Optional[LinkPreviewOptions] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None,
allow_sending_without_reply: Optional[bool] = None,
disable_web_page_preview: Optional[Union[bool, Default]] = Default(
"link_preview_is_disabled"
),
disable_web_page_preview: Optional[bool] = None,
reply_to_message_id: Optional[int] = None,
**kwargs: Any,
) -> SendMessage:
@ -211,11 +207,11 @@ class ChatMemberUpdated(TelegramObject):
height: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -283,14 +279,14 @@ class ChatMemberUpdated(TelegramObject):
audio: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
performer: Optional[str] = None,
title: Optional[str] = None,
thumbnail: Optional[InputFile] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -360,7 +356,7 @@ class ChatMemberUpdated(TelegramObject):
last_name: Optional[str] = None,
vcard: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -419,11 +415,11 @@ class ChatMemberUpdated(TelegramObject):
message_thread_id: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
disable_content_type_detection: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -485,7 +481,7 @@ class ChatMemberUpdated(TelegramObject):
game_short_name: str,
message_thread_id: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
allow_sending_without_reply: Optional[bool] = None,
@ -555,7 +551,7 @@ class ChatMemberUpdated(TelegramObject):
send_email_to_provider: Optional[bool] = None,
is_flexible: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
allow_sending_without_reply: Optional[bool] = None,
@ -650,7 +646,7 @@ class ChatMemberUpdated(TelegramObject):
heading: Optional[int] = None,
proximity_alert_radius: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -712,7 +708,7 @@ class ChatMemberUpdated(TelegramObject):
media: List[Union[InputMediaAudio, InputMediaDocument, InputMediaPhoto, InputMediaVideo]],
message_thread_id: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
allow_sending_without_reply: Optional[bool] = None,
reply_to_message_id: Optional[int] = None,
@ -759,11 +755,11 @@ class ChatMemberUpdated(TelegramObject):
photo: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -828,13 +824,13 @@ class ChatMemberUpdated(TelegramObject):
allows_multiple_answers: Optional[bool] = None,
correct_option_id: Optional[int] = None,
explanation: Optional[str] = None,
explanation_parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
explanation_parse_mode: Optional[ParseMode] = None,
explanation_entities: Optional[List[MessageEntity]] = None,
open_period: Optional[int] = None,
close_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None,
is_closed: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -908,7 +904,7 @@ class ChatMemberUpdated(TelegramObject):
message_thread_id: Optional[int] = None,
emoji: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -961,7 +957,7 @@ class ChatMemberUpdated(TelegramObject):
message_thread_id: Optional[int] = None,
emoji: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1022,7 +1018,7 @@ class ChatMemberUpdated(TelegramObject):
google_place_id: Optional[str] = None,
google_place_type: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1092,12 +1088,12 @@ class ChatMemberUpdated(TelegramObject):
height: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
supports_streaming: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1170,7 +1166,7 @@ class ChatMemberUpdated(TelegramObject):
length: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1228,11 +1224,11 @@ class ChatMemberUpdated(TelegramObject):
voice: Union[InputFile, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]

View file

@ -20,6 +20,5 @@ DateTime = Annotated[
PlainSerializer(
func=_serialize_datetime,
return_type=int,
when_used="json-unless-none",
),
]

View file

@ -2,6 +2,8 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any
from pydantic import ConfigDict
from aiogram.types.base import TelegramObject
if TYPE_CHECKING:
@ -15,9 +17,13 @@ class ErrorEvent(TelegramObject):
Source: https://core.telegram.org/bots/api#error-event
"""
model_config = ConfigDict(
arbitrary_types_allowed=True, # FIXME
)
update: Update
"""Received update"""
exception: Exception
exception: Exception # FIXME: cannot believe that TelegramObject may contain Exception
"""Exception"""
if TYPE_CHECKING:

View file

@ -2,6 +2,8 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Optional, Union
from aiogram.default_annotations import DefaultLinkPreviewOptions
from .base import TelegramObject
if TYPE_CHECKING:
@ -46,7 +48,7 @@ class ExternalReplyInfo(TelegramObject):
"""*Optional*. Chat the original message belongs to. Available only if the chat is a supergroup or a channel."""
message_id: Optional[int] = None
"""*Optional*. Unique message identifier inside the original chat. Available only if the original chat is a supergroup or a channel."""
link_preview_options: Optional[LinkPreviewOptions] = None
link_preview_options: DefaultLinkPreviewOptions = None
"""*Optional*. Options used for link preview generation for the original message, if it is a text message"""
animation: Optional[Animation] = None
"""*Optional*. Message is an animation, information about the animation"""

View file

@ -2,8 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InlineQueryResultType
from aiogram.default_annotations import DefaultParseMode
from ..enums import InlineQueryResultType, ParseMode
from .inline_query_result import InlineQueryResult
if TYPE_CHECKING:
@ -33,7 +34,7 @@ class InlineQueryResultAudio(InlineQueryResult):
"""Title"""
caption: Optional[str] = None
"""*Optional*. Caption, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the audio caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -66,7 +67,7 @@ class InlineQueryResultAudio(InlineQueryResult):
audio_url: str,
title: str,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
performer: Optional[str] = None,
audio_duration: Optional[int] = None,

View file

@ -2,8 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InlineQueryResultType
from aiogram.default_annotations import DefaultParseMode
from ..enums import InlineQueryResultType, ParseMode
from .inline_query_result import InlineQueryResult
if TYPE_CHECKING:
@ -31,7 +32,7 @@ class InlineQueryResultCachedAudio(InlineQueryResult):
"""A valid file identifier for the audio file"""
caption: Optional[str] = None
"""*Optional*. Caption, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the audio caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -59,7 +60,7 @@ class InlineQueryResultCachedAudio(InlineQueryResult):
id: str,
audio_file_id: str,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional[

View file

@ -2,8 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InlineQueryResultType
from aiogram.default_annotations import DefaultParseMode
from ..enums import InlineQueryResultType, ParseMode
from .inline_query_result import InlineQueryResult
if TYPE_CHECKING:
@ -35,7 +36,7 @@ class InlineQueryResultCachedDocument(InlineQueryResult):
"""*Optional*. Short description of the result"""
caption: Optional[str] = None
"""*Optional*. Caption of the document to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the document caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -65,7 +66,7 @@ class InlineQueryResultCachedDocument(InlineQueryResult):
document_file_id: str,
description: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional[

View file

@ -2,8 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InlineQueryResultType
from aiogram.default_annotations import DefaultParseMode
from ..enums import InlineQueryResultType, ParseMode
from .inline_query_result import InlineQueryResult
if TYPE_CHECKING:
@ -33,7 +34,7 @@ class InlineQueryResultCachedGif(InlineQueryResult):
"""*Optional*. Title for the result"""
caption: Optional[str] = None
"""*Optional*. Caption of the GIF file to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -62,7 +63,7 @@ class InlineQueryResultCachedGif(InlineQueryResult):
gif_file_id: str,
title: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional[

View file

@ -2,8 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InlineQueryResultType
from aiogram.default_annotations import DefaultParseMode
from ..enums import InlineQueryResultType, ParseMode
from .inline_query_result import InlineQueryResult
if TYPE_CHECKING:
@ -33,7 +34,7 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
"""*Optional*. Title for the result"""
caption: Optional[str] = None
"""*Optional*. Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -62,7 +63,7 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
mpeg4_file_id: str,
title: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional[

View file

@ -2,8 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InlineQueryResultType
from aiogram.default_annotations import DefaultParseMode
from ..enums import InlineQueryResultType, ParseMode
from .inline_query_result import InlineQueryResult
if TYPE_CHECKING:
@ -35,7 +36,7 @@ class InlineQueryResultCachedPhoto(InlineQueryResult):
"""*Optional*. Short description of the result"""
caption: Optional[str] = None
"""*Optional*. Caption of the photo to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the photo caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -65,7 +66,7 @@ class InlineQueryResultCachedPhoto(InlineQueryResult):
title: Optional[str] = None,
description: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional[

View file

@ -2,8 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InlineQueryResultType
from aiogram.default_annotations import DefaultParseMode
from ..enums import InlineQueryResultType, ParseMode
from .inline_query_result import InlineQueryResult
if TYPE_CHECKING:
@ -35,7 +36,7 @@ class InlineQueryResultCachedVideo(InlineQueryResult):
"""*Optional*. Short description of the result"""
caption: Optional[str] = None
"""*Optional*. Caption of the video to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the video caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -65,7 +66,7 @@ class InlineQueryResultCachedVideo(InlineQueryResult):
title: str,
description: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional[

View file

@ -2,8 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InlineQueryResultType
from aiogram.default_annotations import DefaultParseMode
from ..enums import InlineQueryResultType, ParseMode
from .inline_query_result import InlineQueryResult
if TYPE_CHECKING:
@ -33,7 +34,7 @@ class InlineQueryResultCachedVoice(InlineQueryResult):
"""Voice message title"""
caption: Optional[str] = None
"""*Optional*. Caption, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the voice message caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -62,7 +63,7 @@ class InlineQueryResultCachedVoice(InlineQueryResult):
voice_file_id: str,
title: str,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional[

View file

@ -2,8 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InlineQueryResultType
from aiogram.default_annotations import DefaultParseMode
from ..enums import InlineQueryResultType, ParseMode
from .inline_query_result import InlineQueryResult
if TYPE_CHECKING:
@ -35,7 +36,7 @@ class InlineQueryResultDocument(InlineQueryResult):
"""MIME type of the content of the file, either 'application/pdf' or 'application/zip'"""
caption: Optional[str] = None
"""*Optional*. Caption of the document to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the document caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -73,7 +74,7 @@ class InlineQueryResultDocument(InlineQueryResult):
document_url: str,
mime_type: str,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
description: Optional[str] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,

View file

@ -2,9 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InlineQueryResultType
from .base import UNSET_PARSE_MODE
from aiogram.default_annotations import DefaultParseMode
from ..enums import InlineQueryResultType, ParseMode
from .inline_query_result import InlineQueryResult
if TYPE_CHECKING:
@ -44,7 +44,7 @@ class InlineQueryResultGif(InlineQueryResult):
"""*Optional*. Title for the result"""
caption: Optional[str] = None
"""*Optional*. Caption of the GIF file to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -78,7 +78,7 @@ class InlineQueryResultGif(InlineQueryResult):
thumbnail_mime_type: Optional[str] = None,
title: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional[

View file

@ -2,8 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InlineQueryResultType
from aiogram.default_annotations import DefaultParseMode
from ..enums import InlineQueryResultType, ParseMode
from .inline_query_result import InlineQueryResult
if TYPE_CHECKING:
@ -43,7 +44,7 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
"""*Optional*. Title for the result"""
caption: Optional[str] = None
"""*Optional*. Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -77,7 +78,7 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
thumbnail_mime_type: Optional[str] = None,
title: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional[

View file

@ -2,8 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InlineQueryResultType
from aiogram.default_annotations import DefaultParseMode
from ..enums import InlineQueryResultType, ParseMode
from .inline_query_result import InlineQueryResult
if TYPE_CHECKING:
@ -41,7 +42,7 @@ class InlineQueryResultPhoto(InlineQueryResult):
"""*Optional*. Short description of the result"""
caption: Optional[str] = None
"""*Optional*. Caption of the photo to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the photo caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -74,7 +75,7 @@ class InlineQueryResultPhoto(InlineQueryResult):
title: Optional[str] = None,
description: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
input_message_content: Optional[

View file

@ -2,8 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InlineQueryResultType
from aiogram.default_annotations import DefaultParseMode
from ..enums import InlineQueryResultType, ParseMode
from .inline_query_result import InlineQueryResult
if TYPE_CHECKING:
@ -39,7 +40,7 @@ class InlineQueryResultVideo(InlineQueryResult):
"""Title for the result"""
caption: Optional[str] = None
"""*Optional*. Caption of the video to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the video caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -78,7 +79,7 @@ class InlineQueryResultVideo(InlineQueryResult):
thumbnail_url: str,
title: str,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
video_width: Optional[int] = None,
video_height: Optional[int] = None,

View file

@ -2,8 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InlineQueryResultType
from aiogram.default_annotations import DefaultParseMode
from ..enums import InlineQueryResultType, ParseMode
from .inline_query_result import InlineQueryResult
if TYPE_CHECKING:
@ -33,7 +34,7 @@ class InlineQueryResultVoice(InlineQueryResult):
"""Recording title"""
caption: Optional[str] = None
"""*Optional*. Caption, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the voice message caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -64,7 +65,7 @@ class InlineQueryResultVoice(InlineQueryResult):
voice_url: str,
title: str,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
voice_duration: Optional[int] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,

View file

@ -160,10 +160,8 @@ class URLInputFile(BotContextController, InputFile):
self._bot = bot
async def read(self, bot: Optional["Bot"] = None) -> AsyncGenerator[bytes, None]:
bot = self.bot or bot # FIXME: invalid order suspected
if bot is None:
raise AttributeError("There is no default bot. Specify it through param")
async def read(self, bot: "Bot") -> AsyncGenerator[bytes, None]:
bot = self.bot or bot
stream = bot.session.stream_content(
url=self.url,
headers=self.headers,

View file

@ -2,8 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InputMediaType
from aiogram.default_annotations import DefaultParseMode
from ..enums import InputMediaType, ParseMode
from .input_media import InputMedia
if TYPE_CHECKING:
@ -26,7 +27,7 @@ class InputMediaAnimation(InputMedia):
"""*Optional*. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More information on Sending Files » <sending-files>`"""
caption: Optional[str] = None
"""*Optional*. Caption of the animation to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the animation caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -50,7 +51,7 @@ class InputMediaAnimation(InputMedia):
media: Union[str, InputFile],
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
width: Optional[int] = None,
height: Optional[int] = None,

View file

@ -2,8 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InputMediaType
from aiogram.default_annotations import DefaultParseMode
from ..enums import InputMediaType, ParseMode
from .input_media import InputMedia
if TYPE_CHECKING:
@ -26,7 +27,7 @@ class InputMediaAudio(InputMedia):
"""*Optional*. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More information on Sending Files » <sending-files>`"""
caption: Optional[str] = None
"""*Optional*. Caption of the audio to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the audio caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -48,7 +49,7 @@ class InputMediaAudio(InputMedia):
media: Union[str, InputFile],
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
performer: Optional[str] = None,

View file

@ -2,8 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InputMediaType
from aiogram.default_annotations import DefaultParseMode
from ..enums import InputMediaType, ParseMode
from .input_media import InputMedia
if TYPE_CHECKING:
@ -26,7 +27,7 @@ class InputMediaDocument(InputMedia):
"""*Optional*. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More information on Sending Files » <sending-files>`"""
caption: Optional[str] = None
"""*Optional*. Caption of the document to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the document caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -44,7 +45,7 @@ class InputMediaDocument(InputMedia):
media: Union[str, InputFile],
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
disable_content_type_detection: Optional[bool] = None,
**__pydantic_kwargs: Any,

View file

@ -2,8 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InputMediaType
from aiogram.default_annotations import DefaultParseMode
from ..enums import InputMediaType, ParseMode
from .input_media import InputMedia
if TYPE_CHECKING:
@ -24,7 +25,7 @@ class InputMediaPhoto(InputMedia):
"""File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://<file_attach_name>' to upload a new one using multipart/form-data under <file_attach_name> name. :ref:`More information on Sending Files » <sending-files>`"""
caption: Optional[str] = None
"""*Optional*. Caption of the photo to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the photo caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -41,7 +42,7 @@ class InputMediaPhoto(InputMedia):
type: Literal[InputMediaType.PHOTO] = InputMediaType.PHOTO,
media: Union[str, InputFile],
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
**__pydantic_kwargs: Any,

View file

@ -2,8 +2,9 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..client.default import Default
from ..enums import InputMediaType
from aiogram.default_annotations import DefaultParseMode
from ..enums import InputMediaType, ParseMode
from .input_media import InputMedia
if TYPE_CHECKING:
@ -26,7 +27,7 @@ class InputMediaVideo(InputMedia):
"""*Optional*. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More information on Sending Files » <sending-files>`"""
caption: Optional[str] = None
"""*Optional*. Caption of the video to be sent, 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the video caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
@ -52,7 +53,7 @@ class InputMediaVideo(InputMedia):
media: Union[str, InputFile],
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
width: Optional[int] = None,
height: Optional[int] = None,

View file

@ -1,10 +1,12 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Optional, Union
from typing import TYPE_CHECKING, Any, List, Optional
from pydantic import Field
from ..client.default import Default
from aiogram.default_annotations import DefaultLinkPreviewOptions, DefaultParseMode
from ..enums import ParseMode
from .input_message_content import InputMessageContent
if TYPE_CHECKING:
@ -21,15 +23,13 @@ class InputTextMessageContent(InputMessageContent):
message_text: str
"""Text of the message to be sent, 1-4096 characters"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the message text. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in message text, which can be specified instead of *parse_mode*"""
link_preview_options: Optional[LinkPreviewOptions] = None
link_preview_options: DefaultLinkPreviewOptions = None
"""*Optional*. Link preview generation options for the message"""
disable_web_page_preview: Optional[Union[bool, Default]] = Field(
Default("disable_web_page_preview"), json_schema_extra={"deprecated": True}
)
disable_web_page_preview: Optional[bool] = Field(None, json_schema_extra={"deprecated": True})
"""*Optional*. Disables link previews for links in the sent message
.. deprecated:: API:7.0
@ -43,12 +43,10 @@ class InputTextMessageContent(InputMessageContent):
__pydantic__self__,
*,
message_text: str,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
entities: Optional[List[MessageEntity]] = None,
link_preview_options: Optional[LinkPreviewOptions] = None,
disable_web_page_preview: Optional[Union[bool, Default]] = Default(
"disable_web_page_preview"
),
disable_web_page_preview: Optional[bool] = None,
**__pydantic_kwargs: Any,
) -> None:
# DO NOT EDIT MANUALLY!!!

View file

@ -1,6 +1,5 @@
from typing import TYPE_CHECKING, Any, Optional, Union
from typing import TYPE_CHECKING, Any, Optional
from ..client.default import Default
from .base import TelegramObject
@ -11,15 +10,15 @@ class LinkPreviewOptions(TelegramObject):
Source: https://core.telegram.org/bots/api#linkpreviewoptions
"""
is_disabled: Optional[Union[bool, Default]] = Default("link_preview_is_disabled")
is_disabled: Optional[bool] = None
"""*Optional*. :code:`True`, if the link preview is disabled"""
url: Optional[str] = None
"""*Optional*. URL to use for the link preview. If empty, then the first URL found in the message text will be used"""
prefer_small_media: Optional[Union[bool, Default]] = Default("link_preview_prefer_small_media")
prefer_small_media: Optional[bool] = None
"""*Optional*. :code:`True`, if the media in the link preview is supposed to be shrunk; ignored if the URL isn't explicitly specified or media size change isn't supported for the preview"""
prefer_large_media: Optional[Union[bool, Default]] = Default("link_preview_prefer_large_media")
prefer_large_media: Optional[bool] = None
"""*Optional*. :code:`True`, if the media in the link preview is supposed to be enlarged; ignored if the URL isn't explicitly specified or media size change isn't supported for the preview"""
show_above_text: Optional[Union[bool, Default]] = Default("link_preview_show_above_text")
show_above_text: Optional[bool] = None
"""*Optional*. :code:`True`, if the link preview must be shown above the message text; otherwise, the link preview will be shown below the message text"""
if TYPE_CHECKING:
@ -29,17 +28,11 @@ class LinkPreviewOptions(TelegramObject):
def __init__(
__pydantic__self__,
*,
is_disabled: Optional[Union[bool, Default]] = Default("link_preview_is_disabled"),
is_disabled: Optional[bool] = None,
url: Optional[str] = None,
prefer_small_media: Optional[Union[bool, Default]] = Default(
"link_preview_prefer_small_media"
),
prefer_large_media: Optional[Union[bool, Default]] = Default(
"link_preview_prefer_large_media"
),
show_above_text: Optional[Union[bool, Default]] = Default(
"link_preview_show_above_text"
),
prefer_small_media: Optional[bool] = None,
prefer_large_media: Optional[bool] = None,
show_above_text: Optional[bool] = None,
**__pydantic_kwargs: Any,
) -> None:
# DO NOT EDIT MANUALLY!!!

View file

@ -5,14 +5,14 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
from pydantic import Field
from aiogram.default_annotations import DefaultLinkPreviewOptions
from aiogram.utils.text_decorations import (
TextDecoration,
html_decoration,
markdown_decoration,
)
from ..client.default import Default
from ..enums import ContentType
from ..enums import ContentType, ParseMode
from .custom import DateTime
from .maybe_inaccessible_message import MaybeInaccessibleMessage
@ -166,7 +166,7 @@ class Message(MaybeInaccessibleMessage):
"""*Optional*. For text messages, the actual UTF-8 text of the message"""
entities: Optional[List[MessageEntity]] = None
"""*Optional*. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text"""
link_preview_options: Optional[LinkPreviewOptions] = None
link_preview_options: DefaultLinkPreviewOptions = None
"""*Optional*. Options used for link preview generation for the message, if it is a text message and link preview options were changed"""
animation: Optional[Animation] = None
"""*Optional*. Message is an animation, information about the animation. For backward compatibility, when this field is set, the *document* field will also be set"""
@ -640,11 +640,11 @@ class Message(MaybeInaccessibleMessage):
height: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -718,11 +718,11 @@ class Message(MaybeInaccessibleMessage):
height: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -793,14 +793,14 @@ class Message(MaybeInaccessibleMessage):
self,
audio: Union[InputFile, str],
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
performer: Optional[str] = None,
title: Optional[str] = None,
thumbnail: Optional[InputFile] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -869,14 +869,14 @@ class Message(MaybeInaccessibleMessage):
self,
audio: Union[InputFile, str],
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
performer: Optional[str] = None,
title: Optional[str] = None,
thumbnail: Optional[InputFile] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -949,7 +949,7 @@ class Message(MaybeInaccessibleMessage):
last_name: Optional[str] = None,
vcard: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1012,7 +1012,7 @@ class Message(MaybeInaccessibleMessage):
last_name: Optional[str] = None,
vcard: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1074,11 +1074,11 @@ class Message(MaybeInaccessibleMessage):
document: Union[InputFile, str],
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
disable_content_type_detection: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1143,11 +1143,11 @@ class Message(MaybeInaccessibleMessage):
document: Union[InputFile, str],
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
disable_content_type_detection: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1212,7 +1212,7 @@ class Message(MaybeInaccessibleMessage):
self,
game_short_name: str,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
allow_sending_without_reply: Optional[bool] = None,
@ -1264,7 +1264,7 @@ class Message(MaybeInaccessibleMessage):
self,
game_short_name: str,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
allow_sending_without_reply: Optional[bool] = None,
@ -1337,7 +1337,7 @@ class Message(MaybeInaccessibleMessage):
send_email_to_provider: Optional[bool] = None,
is_flexible: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
allow_sending_without_reply: Optional[bool] = None,
@ -1449,7 +1449,7 @@ class Message(MaybeInaccessibleMessage):
send_email_to_provider: Optional[bool] = None,
is_flexible: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
allow_sending_without_reply: Optional[bool] = None,
@ -1547,7 +1547,7 @@ class Message(MaybeInaccessibleMessage):
heading: Optional[int] = None,
proximity_alert_radius: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1616,7 +1616,7 @@ class Message(MaybeInaccessibleMessage):
heading: Optional[int] = None,
proximity_alert_radius: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1681,7 +1681,7 @@ class Message(MaybeInaccessibleMessage):
self,
media: List[Union[InputMediaAudio, InputMediaDocument, InputMediaPhoto, InputMediaVideo]],
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
allow_sending_without_reply: Optional[bool] = None,
**kwargs: Any,
@ -1730,7 +1730,7 @@ class Message(MaybeInaccessibleMessage):
self,
media: List[Union[InputMediaAudio, InputMediaDocument, InputMediaPhoto, InputMediaVideo]],
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
allow_sending_without_reply: Optional[bool] = None,
reply_to_message_id: Optional[int] = None,
@ -1779,21 +1779,17 @@ class Message(MaybeInaccessibleMessage):
def reply(
self,
text: str,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
entities: Optional[List[MessageEntity]] = None,
link_preview_options: Optional[Union[LinkPreviewOptions, Default]] = Default(
"link_preview"
),
link_preview_options: Optional[LinkPreviewOptions] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None,
allow_sending_without_reply: Optional[bool] = None,
disable_web_page_preview: Optional[Union[bool, Default]] = Default(
"link_preview_is_disabled"
),
disable_web_page_preview: Optional[bool] = None,
**kwargs: Any,
) -> SendMessage:
"""
@ -1849,21 +1845,17 @@ class Message(MaybeInaccessibleMessage):
def answer(
self,
text: str,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
entities: Optional[List[MessageEntity]] = None,
link_preview_options: Optional[Union[LinkPreviewOptions, Default]] = Default(
"link_preview"
),
link_preview_options: Optional[LinkPreviewOptions] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None,
allow_sending_without_reply: Optional[bool] = None,
disable_web_page_preview: Optional[Union[bool, Default]] = Default(
"link_preview_is_disabled"
),
disable_web_page_preview: Optional[bool] = None,
reply_to_message_id: Optional[int] = None,
**kwargs: Any,
) -> SendMessage:
@ -1921,11 +1913,11 @@ class Message(MaybeInaccessibleMessage):
self,
photo: Union[InputFile, str],
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -1987,11 +1979,11 @@ class Message(MaybeInaccessibleMessage):
self,
photo: Union[InputFile, str],
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2059,13 +2051,13 @@ class Message(MaybeInaccessibleMessage):
allows_multiple_answers: Optional[bool] = None,
correct_option_id: Optional[int] = None,
explanation: Optional[str] = None,
explanation_parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
explanation_parse_mode: Optional[ParseMode] = None,
explanation_entities: Optional[List[MessageEntity]] = None,
open_period: Optional[int] = None,
close_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None,
is_closed: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2146,13 +2138,13 @@ class Message(MaybeInaccessibleMessage):
allows_multiple_answers: Optional[bool] = None,
correct_option_id: Optional[int] = None,
explanation: Optional[str] = None,
explanation_parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
explanation_parse_mode: Optional[ParseMode] = None,
explanation_entities: Optional[List[MessageEntity]] = None,
open_period: Optional[int] = None,
close_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None,
is_closed: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2229,7 +2221,7 @@ class Message(MaybeInaccessibleMessage):
self,
emoji: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2283,7 +2275,7 @@ class Message(MaybeInaccessibleMessage):
self,
emoji: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2339,7 +2331,7 @@ class Message(MaybeInaccessibleMessage):
sticker: Union[InputFile, str],
emoji: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2396,7 +2388,7 @@ class Message(MaybeInaccessibleMessage):
sticker: Union[InputFile, str],
emoji: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2460,7 +2452,7 @@ class Message(MaybeInaccessibleMessage):
google_place_id: Optional[str] = None,
google_place_type: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2535,7 +2527,7 @@ class Message(MaybeInaccessibleMessage):
google_place_id: Optional[str] = None,
google_place_type: Optional[str] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2608,12 +2600,12 @@ class Message(MaybeInaccessibleMessage):
height: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
supports_streaming: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2689,12 +2681,12 @@ class Message(MaybeInaccessibleMessage):
height: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
supports_streaming: Optional[bool] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2770,7 +2762,7 @@ class Message(MaybeInaccessibleMessage):
length: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2833,7 +2825,7 @@ class Message(MaybeInaccessibleMessage):
length: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2894,11 +2886,11 @@ class Message(MaybeInaccessibleMessage):
self,
voice: Union[InputFile, str],
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -2960,11 +2952,11 @@ class Message(MaybeInaccessibleMessage):
self,
voice: Union[InputFile, str],
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -3209,10 +3201,10 @@ class Message(MaybeInaccessibleMessage):
chat_id: Union[int, str],
message_thread_id: Optional[int] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
reply_parameters: Optional[ReplyParameters] = None,
reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
@ -3275,13 +3267,11 @@ class Message(MaybeInaccessibleMessage):
self,
text: str,
inline_message_id: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
entities: Optional[List[MessageEntity]] = None,
link_preview_options: Optional[LinkPreviewOptions] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
disable_web_page_preview: Optional[Union[bool, Default]] = Default(
"link_preview_is_disabled"
),
disable_web_page_preview: Optional[bool] = None,
**kwargs: Any,
) -> EditMessageText:
"""
@ -3331,7 +3321,7 @@ class Message(MaybeInaccessibleMessage):
chat_id: Union[int, str],
message_thread_id: Optional[int] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
protect_content: Optional[bool] = None,
**kwargs: Any,
) -> ForwardMessage:
"""
@ -3587,7 +3577,7 @@ class Message(MaybeInaccessibleMessage):
self,
inline_message_id: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
reply_markup: Optional[InlineKeyboardMarkup] = None,
**kwargs: Any,

View file

@ -2,7 +2,12 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Optional, Union
from ..client.default import Default
from aiogram.default_annotations import (
DefaultAllowSendingWithoutReply,
DefaultParseMode,
)
from ..enums import ParseMode
from .base import TelegramObject
if TYPE_CHECKING:
@ -20,13 +25,11 @@ class ReplyParameters(TelegramObject):
"""Identifier of the message that will be replied to in the current chat, or in the chat *chat_id* if it is specified"""
chat_id: Optional[Union[int, str]] = None
"""*Optional*. If the message to be replied to is from a different chat, unique identifier for the chat or username of the channel (in the format :code:`@channelusername`)"""
allow_sending_without_reply: Optional[Union[bool, Default]] = Default(
"allow_sending_without_reply"
)
allow_sending_without_reply: DefaultAllowSendingWithoutReply = None
"""*Optional*. Pass :code:`True` if the message should be sent even if the specified message to be replied to is not found; can be used only for replies in the same chat and forum topic."""
quote: Optional[str] = None
"""*Optional*. Quoted part of the message to be replied to; 0-1024 characters after entities parsing. The quote must be an exact substring of the message to be replied to, including *bold*, *italic*, *underline*, *strikethrough*, *spoiler*, and *custom_emoji* entities. The message will fail to send if the quote isn't found in the original message."""
quote_parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
quote_parse_mode: DefaultParseMode = None
"""*Optional*. Mode for parsing entities in the quote. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
quote_entities: Optional[List[MessageEntity]] = None
"""*Optional*. A JSON-serialized list of special entities that appear in the quote. It can be specified instead of *quote_parse_mode*."""
@ -42,11 +45,9 @@ class ReplyParameters(TelegramObject):
*,
message_id: int,
chat_id: Optional[Union[int, str]] = None,
allow_sending_without_reply: Optional[Union[bool, Default]] = Default(
"allow_sending_without_reply"
),
allow_sending_without_reply: Optional[bool] = None,
quote: Optional[str] = None,
quote_parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
quote_parse_mode: Optional[ParseMode] = None,
quote_entities: Optional[List[MessageEntity]] = None,
quote_position: Optional[int] = None,
**__pydantic_kwargs: Any,

View file

@ -1,8 +1,7 @@
from typing import Any, Dict, List, Literal, Optional, Union, overload
from aiogram.enums import InputMediaType
from aiogram.enums import InputMediaType, ParseMode
from aiogram.types import (
UNSET_PARSE_MODE,
InputFile,
InputMedia,
InputMediaAudio,
@ -65,7 +64,7 @@ class MediaGroupBuilder:
type: Literal[InputMediaType.AUDIO],
media: Union[str, InputFile],
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
performer: Optional[str] = None,
@ -81,7 +80,7 @@ class MediaGroupBuilder:
type: Literal[InputMediaType.PHOTO],
media: Union[str, InputFile],
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
**kwargs: Any,
@ -96,7 +95,7 @@ class MediaGroupBuilder:
media: Union[str, InputFile],
thumbnail: Optional[Union[InputFile, str]] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
width: Optional[int] = None,
height: Optional[int] = None,
@ -115,7 +114,7 @@ class MediaGroupBuilder:
media: Union[str, InputFile],
thumbnail: Optional[Union[InputFile, str]] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
disable_content_type_detection: Optional[bool] = None,
**kwargs: Any,
@ -147,7 +146,7 @@ class MediaGroupBuilder:
media: Union[str, InputFile],
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
duration: Optional[int] = None,
performer: Optional[str] = None,
@ -196,7 +195,7 @@ class MediaGroupBuilder:
self,
media: Union[str, InputFile],
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
has_spoiler: Optional[bool] = None,
**kwargs: Any,
@ -236,7 +235,7 @@ class MediaGroupBuilder:
media: Union[str, InputFile],
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
width: Optional[int] = None,
height: Optional[int] = None,
@ -298,7 +297,7 @@ class MediaGroupBuilder:
media: Union[str, InputFile],
thumbnail: Optional[InputFile] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = UNSET_PARSE_MODE,
parse_mode: Optional[ParseMode] = None,
caption_entities: Optional[List[MessageEntity]] = None,
disable_content_type_detection: Optional[bool] = None,
**kwargs: Any,

View file

@ -11,7 +11,7 @@ from aiohttp.web_middlewares import middleware
from pydantic_core import from_json
from aiogram import Bot, Dispatcher, loggers
from aiogram.client.form import extract_files, form_serialize
from aiogram.client.form import construct_form_data, serialize_form_value
from aiogram.methods import TelegramMethod
from aiogram.methods.base import TelegramType
from aiogram.webhook.security import IPFilter
@ -146,7 +146,7 @@ class BaseRequestHandler(ABC):
)
self._background_feed_update_tasks.add(feed_update_task)
feed_update_task.add_done_callback(self._background_feed_update_tasks.discard)
return web.json_response({}, dumps=form_serialize)
return web.json_response({}, dumps=serialize_form_value)
def _build_response_writer(
self, bot: Bot, result: Optional[TelegramMethod[TelegramType]]
@ -161,10 +161,10 @@ class BaseRequestHandler(ABC):
payload = writer.append(result.__api_method__)
payload.set_content_disposition("form-data", name="method")
modified_result, files = extract_files(result)
data, files = construct_form_data(result, bot=bot)
for key, value in modified_result.model_dump(mode="json", exclude_none=True).items():
payload = writer.append(form_serialize(value))
for key, value in data.items():
payload = writer.append(value)
payload.set_content_disposition("form-data", name=key)
for key, value in files.items():

View file

@ -3,7 +3,7 @@ import logging
import sys
from os import getenv
from aiogram import Bot, Dispatcher, Router, types
from aiogram import Bot, Dispatcher, types
from aiogram.enums import ParseMode
from aiogram.filters import CommandStart
from aiogram.types import Message

View file

@ -1,5 +1,4 @@
from aiogram import Router
from aiogram.filters import Command
from aiogram.types import Message
# For each module with handlers we can create a separate router.

View file

@ -10,7 +10,7 @@ from aiogram.fsm.storage.memory import (
MemoryStorage,
SimpleEventIsolation,
)
from aiogram.fsm.storage.redis import RedisEventIsolation, RedisStorage
from aiogram.fsm.storage.redis import RedisStorage
from tests.mocked_bot import MockedBot
DATA_DIR = Path(__file__).parent / "data"

View file

@ -1,68 +1,42 @@
import sys
import pytest
from pydantic import ValidationError
from aiogram.client.default import Default, DefaultBotProperties
from aiogram.client.default import DefaultBotProperties
from aiogram.default_annotations import DefaultLinkPreviewOptions, DefaultParseMode
from aiogram.enums import ParseMode
from aiogram.types import LinkPreviewOptions
from aiogram.types import LinkPreviewOptions, TelegramObject
from tests.mocked_bot import MockedBot
class TestDefault:
def test_init(self):
default = Default("test")
assert default._name == "test"
def test_default_validation(self):
class TestObject(TelegramObject):
parse_mode: DefaultParseMode = None
def test_name_property(self):
default = Default("test")
assert default.name == "test"
obj1 = TestObject()
assert obj1.parse_mode is None
obj2 = TestObject(parse_mode=ParseMode.HTML)
assert obj2.parse_mode == ParseMode.HTML
obj3 = TestObject(parse_mode="HTML")
assert obj3.parse_mode == ParseMode.HTML
with pytest.raises(ValidationError):
TestObject(parse_mode=b"some invalid type")
def test_str(self):
default = Default("test")
assert str(default) == "Default('test')"
def test_remain_value_after_dump_roundtrip(self):
bot = MockedBot(default=DefaultBotProperties())
def test_repr(self):
default = Default("test")
assert repr(default) == "<Default('test')>"
def test_link_preview_options_defined(self):
class TestObject(TelegramObject):
options: DefaultLinkPreviewOptions = None
# won't raise error
TestObject(options=LinkPreviewOptions())
class TestDefaultBotProperties:
def test_post_init_empty(self):
def test_is_empty(self):
default_bot_properties = DefaultBotProperties()
assert default_bot_properties.is_empty
assert default_bot_properties.link_preview is None
def test_post_init_auto_fill_link_preview(self):
default_bot_properties = DefaultBotProperties(
link_preview_is_disabled=True,
link_preview_prefer_small_media=True,
link_preview_prefer_large_media=True,
link_preview_show_above_text=True,
)
assert default_bot_properties.link_preview == LinkPreviewOptions(
is_disabled=True,
prefer_small_media=True,
prefer_large_media=True,
show_above_text=True,
)
def test_getitem(self):
default_bot_properties = DefaultBotProperties(
parse_mode=ParseMode.HTML,
link_preview_is_disabled=True,
link_preview_prefer_small_media=True,
link_preview_prefer_large_media=True,
link_preview_show_above_text=True,
)
assert default_bot_properties["parse_mode"] == ParseMode.HTML
assert default_bot_properties["link_preview_is_disabled"] is True
assert default_bot_properties["link_preview_prefer_small_media"] is True
assert default_bot_properties["link_preview_prefer_large_media"] is True
assert default_bot_properties["link_preview_show_above_text"] is True
@pytest.mark.skipif(sys.version_info < (3, 12), reason="requires python3.11 or higher")
def test_dataclass_creation_3_10_plus(self):
params = DefaultBotProperties.__dataclass_params__
assert params.slots is True
assert params.kw_only is True
default_bot_properties = DefaultBotProperties(protect_content=True)
assert not default_bot_properties.is_empty

View file

@ -16,9 +16,9 @@ from aiohttp import ClientError
from aresponses import ResponsesMockServer
from aiogram import Bot
from aiogram.client.default import Default
from aiogram.client.session import aiohttp
from aiogram.client.session.aiohttp import AiohttpSession
from aiogram.default_annotations import DefaultParseMode
from aiogram.exceptions import TelegramNetworkError
from aiogram.methods import TelegramMethod
from aiogram.types import (
@ -121,7 +121,7 @@ class TestAiohttpSession:
str_: str
int_: int
bool_: bool
unset_: Union[str, Default] = Default("parse_mode")
unset_: DefaultParseMode = None
null_: None
list_: List[str]
dict_: Dict[str, Any]
@ -133,7 +133,6 @@ class TestAiohttpSession:
str_="value",
int_=42,
bool_=True,
unset_=Default("parse_mode"),
null_=None,
list_=["foo"],
dict_={"bar": "baz"},

View file

@ -1,17 +1,16 @@
import datetime
import json
from typing import Any, AsyncContextManager, AsyncGenerator, Dict, Optional, Union
from typing import Any, AsyncContextManager, AsyncGenerator, Dict, Optional
from unittest.mock import AsyncMock, patch
import pytest
from pytz import utc
from aiogram import Bot
from aiogram.client.default import Default, DefaultBotProperties
from aiogram.client.form import form_serialize
from aiogram.client.form import serialize_form_value
from aiogram.client.session.base import BaseSession, TelegramType
from aiogram.client.telegram import PRODUCTION, TelegramAPIServer
from aiogram.enums import ChatType, ParseMode, TopicIconColor
from aiogram.enums import ChatType, TopicIconColor
from aiogram.exceptions import (
ClientDecodeError,
RestartingTelegram,
@ -27,18 +26,8 @@ from aiogram.exceptions import (
TelegramUnauthorizedError,
)
from aiogram.methods import DeleteMessage, GetMe, TelegramMethod
from aiogram.types import (
UNSET_PARSE_MODE,
DateTime,
InputFile,
LinkPreviewOptions,
User,
)
from aiogram.types.base import (
UNSET_DISABLE_WEB_PAGE_PREVIEW,
UNSET_PROTECT_CONTENT,
TelegramObject,
)
from aiogram.types import DateTime, LinkPreviewOptions, User
from aiogram.types.base import TelegramObject
from tests.mocked_bot import MockedBot
@ -105,7 +94,6 @@ class TestBaseSession:
@pytest.mark.parametrize(
"value,result",
[
[None, ...],
["text", "text"],
[ChatType.PRIVATE, "private"],
[TopicIconColor.RED, "16478047"],
@ -123,56 +111,23 @@ class TestBaseSession:
"1494994302",
],
[LinkPreviewOptions(is_disabled=True), '{"is_disabled":true}'],
[Default("parse_mode"), "HTML"],
[Default("protect_content"), "true"],
[Default("link_preview_is_disabled"), "true"],
],
)
def test_form_serialize(self, value: Any, result: str):
bot = MockedBot(
default=DefaultBotProperties(
parse_mode=ParseMode.HTML,
protect_content=True,
link_preview_is_disabled=True,
)
)
def test_serialize_form_value(self, value: Any, result: str):
# TODO: move
# pydantic model roundtrip is needed (DateTime has custom serialization, exclude_none=True)
field_type = type(value)
if issubclass(field_type, (datetime.datetime, datetime.timedelta)):
field_type = DateTime
elif issubclass(field_type, InputFile):
field_type = Union[InputFile, str]
elif issubclass(field_type, Default):
field_type = Optional[Union[Any, Default]]
class TestObject(TelegramObject):
field: field_type
obj = TestObject.model_validate({"field": value}, context={"bot": bot})
serialized_obj = obj.model_dump(mode="json", exclude_none=True)
if value is None:
assert "field" not in serialized_obj
else:
value = serialized_obj["field"]
assert form_serialize(value) == result
obj = TestObject(field=value)
serialized_obj = obj.model_dump(exclude_none=True)
value = serialized_obj["field"]
@pytest.mark.parametrize(
"default",
[
UNSET_PARSE_MODE,
UNSET_DISABLE_WEB_PAGE_PREVIEW,
UNSET_PROTECT_CONTENT,
],
)
def test_default_unset(self, default: Default):
bot = MockedBot()
class TestObject(TelegramObject):
field: Optional[Union[Any, Default]]
obj = TestObject.model_validate({"field": default}, context={"bot": bot})
serialized_obj = obj.model_dump(mode="json")
assert serialized_obj["field"] is None
assert serialize_form_value(value) == result
@pytest.mark.parametrize(
"status_code,content,error",

View file

@ -1,4 +1,4 @@
from aiogram.methods import AnswerCallbackQuery, Request
from aiogram.methods import AnswerCallbackQuery
from tests.mocked_bot import MockedBot

View file

@ -1,11 +1,5 @@
from aiogram import Bot
from aiogram.methods import AnswerInlineQuery, Request
from aiogram.types import (
InlineQueryResult,
InlineQueryResultArticle,
InlineQueryResultPhoto,
InputTextMessageContent,
)
from aiogram.methods import AnswerInlineQuery
from aiogram.types import InlineQueryResultArticle, InputTextMessageContent
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import AnswerPreCheckoutQuery, Request
from aiogram.methods import AnswerPreCheckoutQuery
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import AnswerShippingQuery, Request
from aiogram.methods import AnswerShippingQuery
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import ApproveChatJoinRequest, Request
from aiogram.methods import ApproveChatJoinRequest
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import BanChatMember, Request
from aiogram.methods import BanChatMember
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import BanChatSenderChat, Request
from aiogram.methods import BanChatSenderChat
from tests.mocked_bot import MockedBot

View file

@ -1,11 +1,9 @@
from typing import Any, Dict
from unittest.mock import sentinel
import pytest
from aiogram.client.default import Default
from aiogram.methods import GetMe, SendMessage, TelegramMethod
from aiogram.types import LinkPreviewOptions, TelegramObject, User
from aiogram.methods import GetMe, TelegramMethod
from aiogram.types import TelegramObject, User
from tests.mocked_bot import MockedBot
@ -29,22 +27,24 @@ class TestTelegramMethodRemoveUnset:
class TestTelegramMethodModelDumpJson:
@pytest.mark.parametrize(
"obj",
[
SendMessage(
chat_id=1,
text="test",
),
LinkPreviewOptions(),
],
)
def test_model_dump_json(self, obj):
def has_defaults(dump: Dict[str, Any]) -> bool:
return any(isinstance(value, Default) for value in dump.values())
assert has_defaults(obj.model_dump())
assert not has_defaults(obj.model_dump(mode="json"))
...
# TODO
# @pytest.mark.parametrize(
# "obj",
# [
# SendMessage(
# chat_id=1,
# text="test",
# ),
# LinkPreviewOptions(),
# ],
# )
# def test_model_dump_json(self, obj):
# def has_defaults(dump: Dict[str, Any]) -> bool:
# return any(isinstance(value, Default) for value in dump.values())
#
# assert has_defaults(obj.model_dump())
# assert not has_defaults(obj.model_dump(mode="json"))
class TestTelegramMethodCall:

View file

@ -1,4 +1,4 @@
from aiogram.methods import Close, Request
from aiogram.methods import Close
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import CloseForumTopic, Request
from aiogram.methods import CloseForumTopic
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import CloseGeneralForumTopic, Request
from aiogram.methods import CloseGeneralForumTopic
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import CopyMessage, Request
from aiogram.methods import CopyMessage
from aiogram.types import MessageId
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import CreateChatInviteLink, Request
from aiogram.methods import CreateChatInviteLink
from aiogram.types import ChatInviteLink, User
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import CreateForumTopic, Request
from aiogram.methods import CreateForumTopic
from aiogram.types import ForumTopic
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import CreateInvoiceLink, Request
from aiogram.methods import CreateInvoiceLink
from aiogram.types import LabeledPrice
from tests.mocked_bot import MockedBot

View file

@ -1,5 +1,5 @@
from aiogram.enums import StickerFormat
from aiogram.methods import CreateNewStickerSet, Request
from aiogram.methods import CreateNewStickerSet
from aiogram.types import FSInputFile, InputSticker
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import DeclineChatJoinRequest, Request
from aiogram.methods import DeclineChatJoinRequest
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import DeleteChatPhoto, Request
from aiogram.methods import DeleteChatPhoto
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import DeleteChatStickerSet, Request
from aiogram.methods import DeleteChatStickerSet
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import DeleteForumTopic, Request
from aiogram.methods import DeleteForumTopic
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import DeleteMessage, Request
from aiogram.methods import DeleteMessage
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import DeleteMyCommands, Request
from aiogram.methods import DeleteMyCommands
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import DeleteStickerFromSet, Request
from aiogram.methods import DeleteStickerFromSet
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import DeleteStickerSet, Request
from aiogram.methods import DeleteStickerSet
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import DeleteWebhook, Request
from aiogram.methods import DeleteWebhook
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import EditChatInviteLink, Request
from aiogram.methods import EditChatInviteLink
from aiogram.types import ChatInviteLink, User
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import EditForumTopic, Request
from aiogram.methods import EditForumTopic
from tests.mocked_bot import MockedBot

View file

@ -1,4 +1,4 @@
from aiogram.methods import EditGeneralForumTopic, Request
from aiogram.methods import EditGeneralForumTopic
from tests.mocked_bot import MockedBot

View file

@ -1,7 +1,7 @@
import datetime
from typing import Union
from aiogram.methods import EditMessageCaption, Request
from aiogram.methods import EditMessageCaption
from aiogram.types import Chat, Message
from tests.mocked_bot import MockedBot

Some files were not shown because too many files have changed in this diff Show more