From 3bca050b8ab125c84ccfcddad4945810678a4af4 Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Sat, 11 Mar 2023 18:29:13 +0200 Subject: [PATCH] Added more default values --- .butcher/methods/copyMessage/replace.yml | 2 + .butcher/methods/editMessageText/replace.yml | 2 + .butcher/methods/forwardMessage/replace.yml | 3 + .butcher/methods/sendAnimation/replace.yml | 2 + .butcher/methods/sendAudio/replace.yml | 2 + .butcher/methods/sendContact/replace.yml | 3 + .butcher/methods/sendDice/replace.yml | 3 + .butcher/methods/sendDocument/replace.yml | 2 + .butcher/methods/sendGame/replace.yml | 3 + .butcher/methods/sendInvoice/replace.yml | 3 + .butcher/methods/sendLocation/replace.yml | 3 + .butcher/methods/sendMediaGroup/replace.yml | 3 + .butcher/methods/sendMessage/replace.yml | 4 + .butcher/methods/sendPhoto/replace.yml | 2 + .butcher/methods/sendPoll/replace.yml | 2 + .butcher/methods/sendSticker/replace.yml | 3 + .butcher/methods/sendVenue/replace.yml | 3 + .butcher/methods/sendVideo/replace.yml | 2 + .butcher/methods/sendVideoNote/replace.yml | 3 + .butcher/methods/sendVoice/replace.yml | 2 + .../types/InputTextMessageContent/replace.yml | 2 + aiogram/client/bot.py | 51 ++++++----- aiogram/client/session/base.py | 13 ++- aiogram/methods/base.py | 15 +--- aiogram/methods/copy_message.py | 3 +- aiogram/methods/edit_message_text.py | 3 +- aiogram/methods/forward_message.py | 3 +- aiogram/methods/send_animation.py | 3 +- aiogram/methods/send_audio.py | 3 +- aiogram/methods/send_contact.py | 3 +- aiogram/methods/send_dice.py | 3 +- aiogram/methods/send_document.py | 3 +- aiogram/methods/send_game.py | 3 +- aiogram/methods/send_invoice.py | 3 +- aiogram/methods/send_location.py | 3 +- aiogram/methods/send_media_group.py | 3 +- aiogram/methods/send_message.py | 5 +- aiogram/methods/send_photo.py | 3 +- aiogram/methods/send_poll.py | 3 +- aiogram/methods/send_sticker.py | 3 +- aiogram/methods/send_venue.py | 3 +- aiogram/methods/send_video.py | 3 +- aiogram/methods/send_video_note.py | 3 +- aiogram/methods/send_voice.py | 3 +- aiogram/types/base.py | 6 +- aiogram/types/input_text_message_content.py | 4 +- aiogram/types/message.py | 85 ++++++++++--------- aiogram/webhook/aiohttp_server.py | 2 +- pyproject.toml | 2 +- 49 files changed, 194 insertions(+), 100 deletions(-) create mode 100644 .butcher/methods/forwardMessage/replace.yml create mode 100644 .butcher/methods/sendContact/replace.yml create mode 100644 .butcher/methods/sendDice/replace.yml create mode 100644 .butcher/methods/sendGame/replace.yml create mode 100644 .butcher/methods/sendInvoice/replace.yml create mode 100644 .butcher/methods/sendLocation/replace.yml create mode 100644 .butcher/methods/sendMediaGroup/replace.yml create mode 100644 .butcher/methods/sendSticker/replace.yml create mode 100644 .butcher/methods/sendVenue/replace.yml create mode 100644 .butcher/methods/sendVideoNote/replace.yml diff --git a/.butcher/methods/copyMessage/replace.yml b/.butcher/methods/copyMessage/replace.yml index e87fb9b3..cc4fe9b2 100644 --- a/.butcher/methods/copyMessage/replace.yml +++ b/.butcher/methods/copyMessage/replace.yml @@ -1,3 +1,5 @@ annotations: parse_mode: value: UNSET_PARSE_MODE + protect_content: + value: UNSET_PROTECT_CONTENT diff --git a/.butcher/methods/editMessageText/replace.yml b/.butcher/methods/editMessageText/replace.yml index e87fb9b3..ebc1d7e9 100644 --- a/.butcher/methods/editMessageText/replace.yml +++ b/.butcher/methods/editMessageText/replace.yml @@ -1,3 +1,5 @@ annotations: parse_mode: value: UNSET_PARSE_MODE + disable_web_page_preview: + value: UNSET_DISABLE_WEB_PAGE_PREVIEW diff --git a/.butcher/methods/forwardMessage/replace.yml b/.butcher/methods/forwardMessage/replace.yml new file mode 100644 index 00000000..39cba814 --- /dev/null +++ b/.butcher/methods/forwardMessage/replace.yml @@ -0,0 +1,3 @@ +annotations: + protect_content: + value: UNSET_PROTECT_CONTENT diff --git a/.butcher/methods/sendAnimation/replace.yml b/.butcher/methods/sendAnimation/replace.yml index e87fb9b3..cc4fe9b2 100644 --- a/.butcher/methods/sendAnimation/replace.yml +++ b/.butcher/methods/sendAnimation/replace.yml @@ -1,3 +1,5 @@ annotations: parse_mode: value: UNSET_PARSE_MODE + protect_content: + value: UNSET_PROTECT_CONTENT diff --git a/.butcher/methods/sendAudio/replace.yml b/.butcher/methods/sendAudio/replace.yml index e87fb9b3..cc4fe9b2 100644 --- a/.butcher/methods/sendAudio/replace.yml +++ b/.butcher/methods/sendAudio/replace.yml @@ -1,3 +1,5 @@ annotations: parse_mode: value: UNSET_PARSE_MODE + protect_content: + value: UNSET_PROTECT_CONTENT diff --git a/.butcher/methods/sendContact/replace.yml b/.butcher/methods/sendContact/replace.yml new file mode 100644 index 00000000..39cba814 --- /dev/null +++ b/.butcher/methods/sendContact/replace.yml @@ -0,0 +1,3 @@ +annotations: + protect_content: + value: UNSET_PROTECT_CONTENT diff --git a/.butcher/methods/sendDice/replace.yml b/.butcher/methods/sendDice/replace.yml new file mode 100644 index 00000000..39cba814 --- /dev/null +++ b/.butcher/methods/sendDice/replace.yml @@ -0,0 +1,3 @@ +annotations: + protect_content: + value: UNSET_PROTECT_CONTENT diff --git a/.butcher/methods/sendDocument/replace.yml b/.butcher/methods/sendDocument/replace.yml index e87fb9b3..cc4fe9b2 100644 --- a/.butcher/methods/sendDocument/replace.yml +++ b/.butcher/methods/sendDocument/replace.yml @@ -1,3 +1,5 @@ annotations: parse_mode: value: UNSET_PARSE_MODE + protect_content: + value: UNSET_PROTECT_CONTENT diff --git a/.butcher/methods/sendGame/replace.yml b/.butcher/methods/sendGame/replace.yml new file mode 100644 index 00000000..39cba814 --- /dev/null +++ b/.butcher/methods/sendGame/replace.yml @@ -0,0 +1,3 @@ +annotations: + protect_content: + value: UNSET_PROTECT_CONTENT diff --git a/.butcher/methods/sendInvoice/replace.yml b/.butcher/methods/sendInvoice/replace.yml new file mode 100644 index 00000000..39cba814 --- /dev/null +++ b/.butcher/methods/sendInvoice/replace.yml @@ -0,0 +1,3 @@ +annotations: + protect_content: + value: UNSET_PROTECT_CONTENT diff --git a/.butcher/methods/sendLocation/replace.yml b/.butcher/methods/sendLocation/replace.yml new file mode 100644 index 00000000..39cba814 --- /dev/null +++ b/.butcher/methods/sendLocation/replace.yml @@ -0,0 +1,3 @@ +annotations: + protect_content: + value: UNSET_PROTECT_CONTENT diff --git a/.butcher/methods/sendMediaGroup/replace.yml b/.butcher/methods/sendMediaGroup/replace.yml new file mode 100644 index 00000000..39cba814 --- /dev/null +++ b/.butcher/methods/sendMediaGroup/replace.yml @@ -0,0 +1,3 @@ +annotations: + protect_content: + value: UNSET_PROTECT_CONTENT diff --git a/.butcher/methods/sendMessage/replace.yml b/.butcher/methods/sendMessage/replace.yml index e87fb9b3..68d7bef9 100644 --- a/.butcher/methods/sendMessage/replace.yml +++ b/.butcher/methods/sendMessage/replace.yml @@ -1,3 +1,7 @@ annotations: parse_mode: value: UNSET_PARSE_MODE + disable_web_page_preview: + value: UNSET_DISABLE_WEB_PAGE_PREVIEW + protect_content: + value: UNSET_PROTECT_CONTENT diff --git a/.butcher/methods/sendPhoto/replace.yml b/.butcher/methods/sendPhoto/replace.yml index e87fb9b3..cc4fe9b2 100644 --- a/.butcher/methods/sendPhoto/replace.yml +++ b/.butcher/methods/sendPhoto/replace.yml @@ -1,3 +1,5 @@ annotations: parse_mode: value: UNSET_PARSE_MODE + protect_content: + value: UNSET_PROTECT_CONTENT diff --git a/.butcher/methods/sendPoll/replace.yml b/.butcher/methods/sendPoll/replace.yml index 7786f4f0..4b39b8ab 100644 --- a/.butcher/methods/sendPoll/replace.yml +++ b/.butcher/methods/sendPoll/replace.yml @@ -1,6 +1,8 @@ annotations: explanation_parse_mode: value: UNSET_PARSE_MODE + protect_content: + value: UNSET_PROTECT_CONTENT close_date: parsed_type: type: union diff --git a/.butcher/methods/sendSticker/replace.yml b/.butcher/methods/sendSticker/replace.yml new file mode 100644 index 00000000..39cba814 --- /dev/null +++ b/.butcher/methods/sendSticker/replace.yml @@ -0,0 +1,3 @@ +annotations: + protect_content: + value: UNSET_PROTECT_CONTENT diff --git a/.butcher/methods/sendVenue/replace.yml b/.butcher/methods/sendVenue/replace.yml new file mode 100644 index 00000000..39cba814 --- /dev/null +++ b/.butcher/methods/sendVenue/replace.yml @@ -0,0 +1,3 @@ +annotations: + protect_content: + value: UNSET_PROTECT_CONTENT diff --git a/.butcher/methods/sendVideo/replace.yml b/.butcher/methods/sendVideo/replace.yml index e87fb9b3..cc4fe9b2 100644 --- a/.butcher/methods/sendVideo/replace.yml +++ b/.butcher/methods/sendVideo/replace.yml @@ -1,3 +1,5 @@ annotations: parse_mode: value: UNSET_PARSE_MODE + protect_content: + value: UNSET_PROTECT_CONTENT diff --git a/.butcher/methods/sendVideoNote/replace.yml b/.butcher/methods/sendVideoNote/replace.yml new file mode 100644 index 00000000..39cba814 --- /dev/null +++ b/.butcher/methods/sendVideoNote/replace.yml @@ -0,0 +1,3 @@ +annotations: + protect_content: + value: UNSET_PROTECT_CONTENT diff --git a/.butcher/methods/sendVoice/replace.yml b/.butcher/methods/sendVoice/replace.yml index e87fb9b3..cc4fe9b2 100644 --- a/.butcher/methods/sendVoice/replace.yml +++ b/.butcher/methods/sendVoice/replace.yml @@ -1,3 +1,5 @@ annotations: parse_mode: value: UNSET_PARSE_MODE + protect_content: + value: UNSET_PROTECT_CONTENT diff --git a/.butcher/types/InputTextMessageContent/replace.yml b/.butcher/types/InputTextMessageContent/replace.yml index e56d9a9b..63741e83 100644 --- a/.butcher/types/InputTextMessageContent/replace.yml +++ b/.butcher/types/InputTextMessageContent/replace.yml @@ -4,3 +4,5 @@ bases: annotations: parse_mode: value: UNSET_PARSE_MODE + disable_web_page_preview: + value: UNSET_DISABLE_WEB_PAGE_PREVIEW diff --git a/aiogram/client/bot.py b/aiogram/client/bot.py index f7bc6170..6f874a88 100644 --- a/aiogram/client/bot.py +++ b/aiogram/client/bot.py @@ -186,6 +186,7 @@ from ..types import ( UserProfilePhotos, WebhookInfo, ) +from ..types.base import UNSET_DISABLE_WEB_PAGE_PREVIEW, UNSET_PROTECT_CONTENT from .session.aiohttp import AiohttpSession from .session.base import BaseSession @@ -198,6 +199,8 @@ class Bot(ContextInstanceMixin["Bot"]): token: str, session: Optional[BaseSession] = None, parse_mode: Optional[str] = None, + disable_web_page_preview: Optional[bool] = None, + protect_content: Optional[bool] = None, ) -> None: """ Bot class @@ -207,6 +210,10 @@ class Bot(ContextInstanceMixin["Bot"]): If not specified it will be automatically created. :param parse_mode: Default parse mode. If specified it will be propagated into the API methods at runtime. + :param disable_web_page_preview: Default disable_web_page_preview mode. + If specified it will be propagated into the API methods at runtime. + :param protect_content: Default protect_content mode. + If specified it will be propagated into the API methods at runtime. :raise TokenValidationError: When token has invalid format this exception will be raised """ @@ -217,6 +224,8 @@ class Bot(ContextInstanceMixin["Bot"]): self.session = session self.parse_mode = parse_mode + self.disable_web_page_preview = disable_web_page_preview + self.protect_content = protect_content self.__token = token self._me: Optional[User] = None @@ -707,7 +716,7 @@ class Bot(ContextInstanceMixin["Bot"]): parse_mode: Optional[str] = UNSET_PARSE_MODE, caption_entities: Optional[List[MessageEntity]] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -1333,7 +1342,7 @@ class Bot(ContextInstanceMixin["Bot"]): inline_message_id: Optional[str] = None, parse_mode: Optional[str] = UNSET_PARSE_MODE, entities: Optional[List[MessageEntity]] = None, - disable_web_page_preview: Optional[bool] = None, + disable_web_page_preview: Optional[bool] = UNSET_DISABLE_WEB_PAGE_PREVIEW, reply_markup: Optional[InlineKeyboardMarkup] = None, request_timeout: Optional[int] = None, ) -> Union[Message, bool]: @@ -1395,7 +1404,7 @@ class Bot(ContextInstanceMixin["Bot"]): message_id: int, message_thread_id: Optional[int] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, request_timeout: Optional[int] = None, ) -> Message: """ @@ -1999,7 +2008,7 @@ class Bot(ContextInstanceMixin["Bot"]): caption_entities: Optional[List[MessageEntity]] = None, has_spoiler: Optional[bool] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -2065,7 +2074,7 @@ class Bot(ContextInstanceMixin["Bot"]): title: Optional[str] = None, thumbnail: Optional[Union[InputFile, str]] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -2156,7 +2165,7 @@ class Bot(ContextInstanceMixin["Bot"]): last_name: Optional[str] = None, vcard: Optional[str] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -2205,7 +2214,7 @@ class Bot(ContextInstanceMixin["Bot"]): message_thread_id: Optional[int] = None, emoji: Optional[str] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -2253,7 +2262,7 @@ class Bot(ContextInstanceMixin["Bot"]): caption_entities: Optional[List[MessageEntity]] = None, disable_content_type_detection: Optional[bool] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -2306,7 +2315,7 @@ class Bot(ContextInstanceMixin["Bot"]): game_short_name: str, message_thread_id: Optional[int] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, @@ -2367,7 +2376,7 @@ class Bot(ContextInstanceMixin["Bot"]): send_email_to_provider: Optional[bool] = None, is_flexible: Optional[bool] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, @@ -2453,7 +2462,7 @@ class Bot(ContextInstanceMixin["Bot"]): heading: Optional[int] = None, proximity_alert_radius: Optional[int] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -2506,7 +2515,7 @@ class Bot(ContextInstanceMixin["Bot"]): media: List[Union[InputMediaAudio, InputMediaDocument, InputMediaPhoto, InputMediaVideo]], message_thread_id: Optional[int] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, request_timeout: Optional[int] = None, @@ -2545,9 +2554,9 @@ class Bot(ContextInstanceMixin["Bot"]): message_thread_id: Optional[int] = None, parse_mode: Optional[str] = UNSET_PARSE_MODE, entities: Optional[List[MessageEntity]] = None, - disable_web_page_preview: Optional[bool] = None, + disable_web_page_preview: Optional[bool] = UNSET_DISABLE_WEB_PAGE_PREVIEW, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -2600,7 +2609,7 @@ class Bot(ContextInstanceMixin["Bot"]): caption_entities: Optional[List[MessageEntity]] = None, has_spoiler: Optional[bool] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -2662,7 +2671,7 @@ class Bot(ContextInstanceMixin["Bot"]): close_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None, is_closed: Optional[bool] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -2728,7 +2737,7 @@ class Bot(ContextInstanceMixin["Bot"]): message_thread_id: Optional[int] = None, emoji: Optional[str] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -2780,7 +2789,7 @@ class Bot(ContextInstanceMixin["Bot"]): google_place_id: Optional[str] = None, google_place_type: Optional[str] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -2846,7 +2855,7 @@ class Bot(ContextInstanceMixin["Bot"]): has_spoiler: Optional[bool] = None, supports_streaming: Optional[bool] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -2910,7 +2919,7 @@ class Bot(ContextInstanceMixin["Bot"]): length: Optional[int] = None, thumbnail: Optional[Union[InputFile, str]] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -2963,7 +2972,7 @@ class Bot(ContextInstanceMixin["Bot"]): caption_entities: Optional[List[MessageEntity]] = None, duration: Optional[int] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ diff --git a/aiogram/client/session/base.py b/aiogram/client/session/base.py index dabd93ee..a66eb7cc 100644 --- a/aiogram/client/session/base.py +++ b/aiogram/client/session/base.py @@ -39,6 +39,7 @@ from aiogram.exceptions import ( from ...methods import Response, TelegramMethod from ...methods.base import TelegramType from ...types import UNSET_PARSE_MODE, InputFile +from ...types.base import UNSET_DISABLE_WEB_PAGE_PREVIEW, UNSET_PROTECT_CONTENT from ..telegram import PRODUCTION, TelegramAPIServer from .middlewares.manager import RequestMiddlewareManager @@ -179,7 +180,17 @@ class BaseSession(abc.ABC): if isinstance(value, str): return value if value is UNSET_PARSE_MODE: - return bot.parse_mode + return self.prepare_value( + bot.parse_mode, bot=bot, files=files, _dumps_json=_dumps_json + ) + if value is UNSET_DISABLE_WEB_PAGE_PREVIEW: + return self.prepare_value( + bot.disable_web_page_preview, bot=bot, files=files, _dumps_json=_dumps_json + ) + if value is UNSET_PROTECT_CONTENT: + return self.prepare_value( + bot.protect_content, bot=bot, files=files, _dumps_json=_dumps_json + ) if isinstance(value, InputFile): key = secrets.token_urlsafe(10) files[key] = value diff --git a/aiogram/methods/base.py b/aiogram/methods/base.py index ca2c3123..33045bf0 100644 --- a/aiogram/methods/base.py +++ b/aiogram/methods/base.py @@ -1,20 +1,13 @@ from __future__ import annotations from abc import ABC, abstractmethod -from typing import ( - TYPE_CHECKING, - Any, - Dict, - Generator, - Generic, - Optional, - TypeVar, -) +from typing import TYPE_CHECKING, Any, Dict, Generator, Generic, Optional, TypeVar from pydantic import BaseConfig, BaseModel, Extra, root_validator from pydantic.generics import GenericModel -from ..types import UNSET_PARSE_MODE, InputFile, ResponseParameters +from ..types import InputFile, ResponseParameters +from ..types.base import UNSET_TYPE if TYPE_CHECKING: from ..client.bot import Bot @@ -59,7 +52,7 @@ class TelegramMethod(ABC, BaseModel, Generic[TelegramType]): but UNSET might be passing to a model initialization from `Bot.method_name`, so we must take care of it and remove it before fields validation. """ - return {k: v for k, v in values.items() if v is not UNSET_PARSE_MODE} + return {k: v for k, v in values.items() if not isinstance(v, UNSET_TYPE)} @property @abstractmethod diff --git a/aiogram/methods/copy_message.py b/aiogram/methods/copy_message.py index e4412904..5e34bb7d 100644 --- a/aiogram/methods/copy_message.py +++ b/aiogram/methods/copy_message.py @@ -11,6 +11,7 @@ from ..types import ( ReplyKeyboardMarkup, ReplyKeyboardRemove, ) +from ..types.base import UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -40,7 +41,7 @@ class CopyMessage(TelegramMethod[MessageId]): """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 """Sends the message `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the sent message from forwarding and saving""" reply_to_message_id: Optional[int] = None """If the message is a reply, ID of the original message""" diff --git a/aiogram/methods/edit_message_text.py b/aiogram/methods/edit_message_text.py index 4ce84891..79887c97 100644 --- a/aiogram/methods/edit_message_text.py +++ b/aiogram/methods/edit_message_text.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import TYPE_CHECKING, List, Optional, Union from ..types import UNSET_PARSE_MODE, InlineKeyboardMarkup, Message, MessageEntity +from ..types.base import UNSET_DISABLE_WEB_PAGE_PREVIEW from .base import TelegramMethod @@ -28,7 +29,7 @@ class EditMessageText(TelegramMethod[Union[Message, bool]]): """Mode for parsing entities in the message text. See `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*""" - disable_web_page_preview: Optional[bool] = None + disable_web_page_preview: Optional[bool] = UNSET_DISABLE_WEB_PAGE_PREVIEW """Disables link previews for links in this message""" reply_markup: Optional[InlineKeyboardMarkup] = None """A JSON-serialized object for an `inline keyboard `_.""" diff --git a/aiogram/methods/forward_message.py b/aiogram/methods/forward_message.py index bf2e3a17..45c084a0 100644 --- a/aiogram/methods/forward_message.py +++ b/aiogram/methods/forward_message.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import TYPE_CHECKING, Optional, Union from ..types import Message +from ..types.base import UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -26,5 +27,5 @@ class ForwardMessage(TelegramMethod[Message]): """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" disable_notification: Optional[bool] = None """Sends the message `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the forwarded message from forwarding and saving""" diff --git a/aiogram/methods/send_animation.py b/aiogram/methods/send_animation.py index 19699f2a..14029d25 100644 --- a/aiogram/methods/send_animation.py +++ b/aiogram/methods/send_animation.py @@ -12,6 +12,7 @@ from ..types import ( ReplyKeyboardMarkup, ReplyKeyboardRemove, ) +from ..types.base import UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -49,7 +50,7 @@ class SendAnimation(TelegramMethod[Message]): """Pass :code:`True` if the animation needs to be covered with a spoiler animation""" disable_notification: Optional[bool] = None """Sends the message `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the sent message from forwarding and saving""" reply_to_message_id: Optional[int] = None """If the message is a reply, ID of the original message""" diff --git a/aiogram/methods/send_audio.py b/aiogram/methods/send_audio.py index f6574ea5..e0f4b900 100644 --- a/aiogram/methods/send_audio.py +++ b/aiogram/methods/send_audio.py @@ -12,6 +12,7 @@ from ..types import ( ReplyKeyboardMarkup, ReplyKeyboardRemove, ) +from ..types.base import UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -48,7 +49,7 @@ class SendAudio(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://' if the thumbnail was uploaded using multipart/form-data under . :ref:`More information on Sending Files ยป `""" disable_notification: Optional[bool] = None """Sends the message `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the sent message from forwarding and saving""" reply_to_message_id: Optional[int] = None """If the message is a reply, ID of the original message""" diff --git a/aiogram/methods/send_contact.py b/aiogram/methods/send_contact.py index 1180fe4f..35473338 100644 --- a/aiogram/methods/send_contact.py +++ b/aiogram/methods/send_contact.py @@ -9,6 +9,7 @@ from ..types import ( ReplyKeyboardMarkup, ReplyKeyboardRemove, ) +from ..types.base import UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -36,7 +37,7 @@ class SendContact(TelegramMethod[Message]): """Additional data about the contact in the form of a `vCard `_, 0-2048 bytes""" disable_notification: Optional[bool] = None """Sends the message `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the sent message from forwarding and saving""" reply_to_message_id: Optional[int] = None """If the message is a reply, ID of the original message""" diff --git a/aiogram/methods/send_dice.py b/aiogram/methods/send_dice.py index 21c4e590..9fa2ce70 100644 --- a/aiogram/methods/send_dice.py +++ b/aiogram/methods/send_dice.py @@ -9,6 +9,7 @@ from ..types import ( ReplyKeyboardMarkup, ReplyKeyboardRemove, ) +from ..types.base import UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -30,7 +31,7 @@ class SendDice(TelegramMethod[Message]): """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 """Sends the message `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the sent message from forwarding""" reply_to_message_id: Optional[int] = None """If the message is a reply, ID of the original message""" diff --git a/aiogram/methods/send_document.py b/aiogram/methods/send_document.py index 9b29c7db..5c83beb3 100644 --- a/aiogram/methods/send_document.py +++ b/aiogram/methods/send_document.py @@ -12,6 +12,7 @@ from ..types import ( ReplyKeyboardMarkup, ReplyKeyboardRemove, ) +from ..types.base import UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -43,7 +44,7 @@ class SendDocument(TelegramMethod[Message]): """Disables automatic server-side content type detection for files uploaded using multipart/form-data""" disable_notification: Optional[bool] = None """Sends the message `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the sent message from forwarding and saving""" reply_to_message_id: Optional[int] = None """If the message is a reply, ID of the original message""" diff --git a/aiogram/methods/send_game.py b/aiogram/methods/send_game.py index 57d6260a..ab55a459 100644 --- a/aiogram/methods/send_game.py +++ b/aiogram/methods/send_game.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import TYPE_CHECKING, Optional from ..types import InlineKeyboardMarkup, Message +from ..types.base import UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -24,7 +25,7 @@ class SendGame(TelegramMethod[Message]): """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" disable_notification: Optional[bool] = None """Sends the message `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the sent message from forwarding and saving""" reply_to_message_id: Optional[int] = None """If the message is a reply, ID of the original message""" diff --git a/aiogram/methods/send_invoice.py b/aiogram/methods/send_invoice.py index 79412156..d08002a9 100644 --- a/aiogram/methods/send_invoice.py +++ b/aiogram/methods/send_invoice.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import TYPE_CHECKING, List, Optional, Union from ..types import InlineKeyboardMarkup, LabeledPrice, Message +from ..types.base import UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -64,7 +65,7 @@ class SendInvoice(TelegramMethod[Message]): """Pass :code:`True` if the final price depends on the shipping method""" disable_notification: Optional[bool] = None """Sends the message `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the sent message from forwarding and saving""" reply_to_message_id: Optional[int] = None """If the message is a reply, ID of the original message""" diff --git a/aiogram/methods/send_location.py b/aiogram/methods/send_location.py index e1086a7b..845b4741 100644 --- a/aiogram/methods/send_location.py +++ b/aiogram/methods/send_location.py @@ -9,6 +9,7 @@ from ..types import ( ReplyKeyboardMarkup, ReplyKeyboardRemove, ) +from ..types.base import UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -40,7 +41,7 @@ class SendLocation(TelegramMethod[Message]): """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 """Sends the message `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the sent message from forwarding and saving""" reply_to_message_id: Optional[int] = None """If the message is a reply, ID of the original message""" diff --git a/aiogram/methods/send_media_group.py b/aiogram/methods/send_media_group.py index 349e4092..fd8dbb25 100644 --- a/aiogram/methods/send_media_group.py +++ b/aiogram/methods/send_media_group.py @@ -9,6 +9,7 @@ from ..types import ( InputMediaVideo, Message, ) +from ..types.base import UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -30,7 +31,7 @@ class SendMediaGroup(TelegramMethod[List[Message]]): """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" disable_notification: Optional[bool] = None """Sends messages `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the sent messages from forwarding and saving""" reply_to_message_id: Optional[int] = None """If the messages are a reply, ID of the original message""" diff --git a/aiogram/methods/send_message.py b/aiogram/methods/send_message.py index 37ddb87a..9b7dae7b 100644 --- a/aiogram/methods/send_message.py +++ b/aiogram/methods/send_message.py @@ -11,6 +11,7 @@ from ..types import ( ReplyKeyboardMarkup, ReplyKeyboardRemove, ) +from ..types.base import UNSET_DISABLE_WEB_PAGE_PREVIEW, UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -34,11 +35,11 @@ class SendMessage(TelegramMethod[Message]): """Mode for parsing entities in the message text. See `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*""" - disable_web_page_preview: Optional[bool] = None + disable_web_page_preview: Optional[bool] = UNSET_DISABLE_WEB_PAGE_PREVIEW """Disables link previews for links in this message""" disable_notification: Optional[bool] = None """Sends the message `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the sent message from forwarding and saving""" reply_to_message_id: Optional[int] = None """If the message is a reply, ID of the original message""" diff --git a/aiogram/methods/send_photo.py b/aiogram/methods/send_photo.py index 425a12bb..236d8710 100644 --- a/aiogram/methods/send_photo.py +++ b/aiogram/methods/send_photo.py @@ -12,6 +12,7 @@ from ..types import ( ReplyKeyboardMarkup, ReplyKeyboardRemove, ) +from ..types.base import UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -41,7 +42,7 @@ class SendPhoto(TelegramMethod[Message]): """Pass :code:`True` if the photo needs to be covered with a spoiler animation""" disable_notification: Optional[bool] = None """Sends the message `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the sent message from forwarding and saving""" reply_to_message_id: Optional[int] = None """If the message is a reply, ID of the original message""" diff --git a/aiogram/methods/send_poll.py b/aiogram/methods/send_poll.py index 0d87cff0..fca3dc58 100644 --- a/aiogram/methods/send_poll.py +++ b/aiogram/methods/send_poll.py @@ -12,6 +12,7 @@ from ..types import ( ReplyKeyboardMarkup, ReplyKeyboardRemove, ) +from ..types.base import UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -55,7 +56,7 @@ class SendPoll(TelegramMethod[Message]): """Pass :code:`True` if the poll needs to be immediately closed. This can be useful for poll preview.""" disable_notification: Optional[bool] = None """Sends the message `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the sent message from forwarding and saving""" reply_to_message_id: Optional[int] = None """If the message is a reply, ID of the original message""" diff --git a/aiogram/methods/send_sticker.py b/aiogram/methods/send_sticker.py index 961280d0..8429b105 100644 --- a/aiogram/methods/send_sticker.py +++ b/aiogram/methods/send_sticker.py @@ -10,6 +10,7 @@ from ..types import ( ReplyKeyboardMarkup, ReplyKeyboardRemove, ) +from ..types.base import UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -33,7 +34,7 @@ class SendSticker(TelegramMethod[Message]): """Emoji associated with the sticker; only for just uploaded stickers""" disable_notification: Optional[bool] = None """Sends the message `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the sent message from forwarding and saving""" reply_to_message_id: Optional[int] = None """If the message is a reply, ID of the original message""" diff --git a/aiogram/methods/send_venue.py b/aiogram/methods/send_venue.py index 388d7cdb..d0859770 100644 --- a/aiogram/methods/send_venue.py +++ b/aiogram/methods/send_venue.py @@ -9,6 +9,7 @@ from ..types import ( ReplyKeyboardMarkup, ReplyKeyboardRemove, ) +from ..types.base import UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -44,7 +45,7 @@ class SendVenue(TelegramMethod[Message]): """Google Places type of the venue. (See `supported types `_.)""" disable_notification: Optional[bool] = None """Sends the message `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the sent message from forwarding and saving""" reply_to_message_id: Optional[int] = None """If the message is a reply, ID of the original message""" diff --git a/aiogram/methods/send_video.py b/aiogram/methods/send_video.py index 8119d60e..a894e335 100644 --- a/aiogram/methods/send_video.py +++ b/aiogram/methods/send_video.py @@ -12,6 +12,7 @@ from ..types import ( ReplyKeyboardMarkup, ReplyKeyboardRemove, ) +from ..types.base import UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -51,7 +52,7 @@ class SendVideo(TelegramMethod[Message]): """Pass :code:`True` if the uploaded video is suitable for streaming""" disable_notification: Optional[bool] = None """Sends the message `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the sent message from forwarding and saving""" reply_to_message_id: Optional[int] = None """If the message is a reply, ID of the original message""" diff --git a/aiogram/methods/send_video_note.py b/aiogram/methods/send_video_note.py index 565dd2e0..761c91a2 100644 --- a/aiogram/methods/send_video_note.py +++ b/aiogram/methods/send_video_note.py @@ -10,6 +10,7 @@ from ..types import ( ReplyKeyboardMarkup, ReplyKeyboardRemove, ) +from ..types.base import UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -37,7 +38,7 @@ class SendVideoNote(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://' if the thumbnail was uploaded using multipart/form-data under . :ref:`More information on Sending Files ยป `""" disable_notification: Optional[bool] = None """Sends the message `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the sent message from forwarding and saving""" reply_to_message_id: Optional[int] = None """If the message is a reply, ID of the original message""" diff --git a/aiogram/methods/send_voice.py b/aiogram/methods/send_voice.py index da4826c8..ae692ad6 100644 --- a/aiogram/methods/send_voice.py +++ b/aiogram/methods/send_voice.py @@ -12,6 +12,7 @@ from ..types import ( ReplyKeyboardMarkup, ReplyKeyboardRemove, ) +from ..types.base import UNSET_PROTECT_CONTENT from .base import TelegramMethod @@ -41,7 +42,7 @@ class SendVoice(TelegramMethod[Message]): """Duration of the voice message in seconds""" disable_notification: Optional[bool] = None """Sends the message `silently `_. Users will receive a notification with no sound.""" - protect_content: Optional[bool] = None + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT """Protects the contents of the sent message from forwarding and saving""" reply_to_message_id: Optional[int] = None """If the message is a reply, ID of the original message""" diff --git a/aiogram/types/base.py b/aiogram/types/base.py index 9d232d1c..707e328c 100644 --- a/aiogram/types/base.py +++ b/aiogram/types/base.py @@ -23,6 +23,8 @@ class MutableTelegramObject(TelegramObject): allow_mutation = True -# special sentinel object which used in sutuation when None might be a useful value -UNSET: Any = sentinel.UNSET +# special sentinel object which used in situation when None might be a useful value UNSET_PARSE_MODE: Any = sentinel.UNSET_PARSE_MODE +UNSET_DISABLE_WEB_PAGE_PREVIEW = sentinel.UNSET_DISABLE_WEB_PAGE_PREVIEW +UNSET_PROTECT_CONTENT = sentinel.UNSET_PROTECT_CONTENT +UNSET_TYPE = type(sentinel.DEFAULT) diff --git a/aiogram/types/input_text_message_content.py b/aiogram/types/input_text_message_content.py index d1351018..697696ce 100644 --- a/aiogram/types/input_text_message_content.py +++ b/aiogram/types/input_text_message_content.py @@ -2,7 +2,7 @@ from __future__ import annotations from typing import TYPE_CHECKING, List, Optional -from .base import UNSET_PARSE_MODE +from .base import UNSET_DISABLE_WEB_PAGE_PREVIEW, UNSET_PARSE_MODE from .input_message_content import InputMessageContent if TYPE_CHECKING: @@ -22,5 +22,5 @@ class InputTextMessageContent(InputMessageContent): """*Optional*. Mode for parsing entities in the message text. See `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*""" - disable_web_page_preview: Optional[bool] = None + disable_web_page_preview: Optional[bool] = UNSET_DISABLE_WEB_PAGE_PREVIEW """*Optional*. Disables link previews for links in the sent message""" diff --git a/aiogram/types/message.py b/aiogram/types/message.py index c5eab1c8..c74ccb97 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -12,7 +12,12 @@ from aiogram.utils.text_decorations import ( ) from ..enums import ContentType -from .base import UNSET_PARSE_MODE, TelegramObject +from .base import ( + UNSET_DISABLE_WEB_PAGE_PREVIEW, + UNSET_PARSE_MODE, + UNSET_PROTECT_CONTENT, + TelegramObject, +) if TYPE_CHECKING: from ..methods import ( @@ -354,7 +359,7 @@ class Message(TelegramObject): caption_entities: Optional[List[MessageEntity]] = None, has_spoiler: Optional[bool] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] @@ -425,7 +430,7 @@ class Message(TelegramObject): caption_entities: Optional[List[MessageEntity]] = None, has_spoiler: Optional[bool] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -496,7 +501,7 @@ class Message(TelegramObject): title: Optional[str] = None, thumbnail: Optional[Union[InputFile, str]] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] @@ -565,7 +570,7 @@ class Message(TelegramObject): title: Optional[str] = None, thumbnail: Optional[Union[InputFile, str]] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -631,7 +636,7 @@ class Message(TelegramObject): last_name: Optional[str] = None, vcard: Optional[str] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] @@ -687,7 +692,7 @@ class Message(TelegramObject): last_name: Optional[str] = None, vcard: Optional[str] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -746,7 +751,7 @@ class Message(TelegramObject): caption_entities: Optional[List[MessageEntity]] = None, disable_content_type_detection: Optional[bool] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] @@ -808,7 +813,7 @@ class Message(TelegramObject): caption_entities: Optional[List[MessageEntity]] = None, disable_content_type_detection: Optional[bool] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -866,7 +871,7 @@ class Message(TelegramObject): self, game_short_name: str, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, **kwargs: Any, @@ -911,7 +916,7 @@ class Message(TelegramObject): self, game_short_name: str, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, @@ -977,7 +982,7 @@ class Message(TelegramObject): send_email_to_provider: Optional[bool] = None, is_flexible: Optional[bool] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, **kwargs: Any, @@ -1082,7 +1087,7 @@ class Message(TelegramObject): send_email_to_provider: Optional[bool] = None, is_flexible: Optional[bool] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, @@ -1173,7 +1178,7 @@ class Message(TelegramObject): heading: Optional[int] = None, proximity_alert_radius: Optional[int] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] @@ -1235,7 +1240,7 @@ class Message(TelegramObject): heading: Optional[int] = None, proximity_alert_radius: Optional[int] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -1293,7 +1298,7 @@ class Message(TelegramObject): self, media: List[Union[InputMediaAudio, InputMediaDocument, InputMediaPhoto, InputMediaVideo]], disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, allow_sending_without_reply: Optional[bool] = None, **kwargs: Any, ) -> SendMediaGroup: @@ -1335,7 +1340,7 @@ class Message(TelegramObject): self, media: List[Union[InputMediaAudio, InputMediaDocument, InputMediaPhoto, InputMediaVideo]], disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, **kwargs: Any, @@ -1379,9 +1384,9 @@ class Message(TelegramObject): text: str, parse_mode: Optional[str] = UNSET_PARSE_MODE, entities: Optional[List[MessageEntity]] = None, - disable_web_page_preview: Optional[bool] = None, + disable_web_page_preview: Optional[bool] = UNSET_DISABLE_WEB_PAGE_PREVIEW, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] @@ -1435,9 +1440,9 @@ class Message(TelegramObject): text: str, parse_mode: Optional[str] = UNSET_PARSE_MODE, entities: Optional[List[MessageEntity]] = None, - disable_web_page_preview: Optional[bool] = None, + disable_web_page_preview: Optional[bool] = UNSET_DISABLE_WEB_PAGE_PREVIEW, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -1495,7 +1500,7 @@ class Message(TelegramObject): caption_entities: Optional[List[MessageEntity]] = None, has_spoiler: Optional[bool] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] @@ -1554,7 +1559,7 @@ class Message(TelegramObject): caption_entities: Optional[List[MessageEntity]] = None, has_spoiler: Optional[bool] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -1621,7 +1626,7 @@ class Message(TelegramObject): close_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None, is_closed: Optional[bool] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] @@ -1701,7 +1706,7 @@ class Message(TelegramObject): close_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None, is_closed: Optional[bool] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -1771,7 +1776,7 @@ class Message(TelegramObject): self, emoji: Optional[str] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] @@ -1818,7 +1823,7 @@ class Message(TelegramObject): self, emoji: Optional[str] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -1867,7 +1872,7 @@ class Message(TelegramObject): sticker: Union[InputFile, str], emoji: Optional[str] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] @@ -1917,7 +1922,7 @@ class Message(TelegramObject): sticker: Union[InputFile, str], emoji: Optional[str] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -1974,7 +1979,7 @@ class Message(TelegramObject): google_place_id: Optional[str] = None, google_place_type: Optional[str] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] @@ -2042,7 +2047,7 @@ class Message(TelegramObject): google_place_id: Optional[str] = None, google_place_type: Optional[str] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -2113,7 +2118,7 @@ class Message(TelegramObject): has_spoiler: Optional[bool] = None, supports_streaming: Optional[bool] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] @@ -2187,7 +2192,7 @@ class Message(TelegramObject): has_spoiler: Optional[bool] = None, supports_streaming: Optional[bool] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -2256,7 +2261,7 @@ class Message(TelegramObject): length: Optional[int] = None, thumbnail: Optional[Union[InputFile, str]] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] @@ -2312,7 +2317,7 @@ class Message(TelegramObject): length: Optional[int] = None, thumbnail: Optional[Union[InputFile, str]] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -2370,7 +2375,7 @@ class Message(TelegramObject): caption_entities: Optional[List[MessageEntity]] = None, duration: Optional[int] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] @@ -2429,7 +2434,7 @@ class Message(TelegramObject): caption_entities: Optional[List[MessageEntity]] = None, duration: Optional[int] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -2627,7 +2632,7 @@ class Message(TelegramObject): parse_mode: Optional[str] = UNSET_PARSE_MODE, caption_entities: Optional[List[MessageEntity]] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, reply_to_message_id: Optional[int] = None, allow_sending_without_reply: Optional[bool] = None, reply_markup: Optional[ @@ -2685,7 +2690,7 @@ class Message(TelegramObject): inline_message_id: Optional[str] = None, parse_mode: Optional[str] = UNSET_PARSE_MODE, entities: Optional[List[MessageEntity]] = None, - disable_web_page_preview: Optional[bool] = None, + disable_web_page_preview: Optional[bool] = UNSET_DISABLE_WEB_PAGE_PREVIEW, reply_markup: Optional[InlineKeyboardMarkup] = None, **kwargs: Any, ) -> EditMessageText: @@ -2730,7 +2735,7 @@ class Message(TelegramObject): chat_id: Union[int, str], message_thread_id: Optional[int] = None, disable_notification: Optional[bool] = None, - protect_content: Optional[bool] = None, + protect_content: Optional[bool] = UNSET_PROTECT_CONTENT, **kwargs: Any, ) -> ForwardMessage: """ diff --git a/aiogram/webhook/aiohttp_server.py b/aiogram/webhook/aiohttp_server.py index ae2da653..4406f1ff 100644 --- a/aiogram/webhook/aiohttp_server.py +++ b/aiogram/webhook/aiohttp_server.py @@ -176,7 +176,7 @@ class BaseRequestHandler(ABC): return writer async def _handle_request(self, bot: Bot, request: web.Request) -> web.Response: - result = await self.dispatcher.feed_webhook_update( + result: Optional[TelegramMethod[Any]] = await self.dispatcher.feed_webhook_update( bot, await request.json(loads=bot.session.json_loads), **self.data, diff --git a/pyproject.toml b/pyproject.toml index b44b9e55..5a203c92 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -148,7 +148,7 @@ features = [ "test", ] extra-dependencies = [ - "butcher @ git+https://github.com/aiogram/butcher.git@v0.1.12" + "butcher @ git+https://github.com/aiogram/butcher.git@v0.1.13" ] [tool.hatch.envs.test]