From 763efb77631de07c563868273b1bd22b15f63be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D1=83=D0=BB=D1=8C=D0=B1=D0=B0?= <81091299+ulbwa@users.noreply.github.com> Date: Sat, 11 Dec 2021 04:00:09 +0500 Subject: [PATCH 01/19] Missing space (#775) --- aiogram/contrib/middlewares/logging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiogram/contrib/middlewares/logging.py b/aiogram/contrib/middlewares/logging.py index 7f21eb41..92ef7252 100644 --- a/aiogram/contrib/middlewares/logging.py +++ b/aiogram/contrib/middlewares/logging.py @@ -92,7 +92,7 @@ class LoggingMiddleware(BaseMiddleware): text = (f"Received callback query [ID:{callback_query.id}] " f"from user [ID:{callback_query.from_user.id}] " f"for message [ID:{message.message_id}] " - f"in chat [{message.chat.type}:{message.chat.id}]" + f"in chat [{message.chat.type}:{message.chat.id}] " f"with data: {callback_query.data}") if message.from_user: From 583f00ce317dfb4c2c6c4df4bd4694c6f0b0bf18 Mon Sep 17 00:00:00 2001 From: Oleg A Date: Wed, 29 Dec 2021 04:38:37 +0300 Subject: [PATCH 02/19] feat: TelegramObject readable representation (#796) --- aiogram/types/base.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/aiogram/types/base.py b/aiogram/types/base.py index 3f8cda60..5bb29472 100644 --- a/aiogram/types/base.py +++ b/aiogram/types/base.py @@ -211,6 +211,15 @@ class TelegramObject(ContextInstanceMixin, metaclass=MetaTelegramObject): """ return self.as_json() + def __repr__(self) -> str: + """ + Return object readable representation. + + Example: + :return: object class name and object data as a string + """ + return f"<{type(self).__name__} {self}>" + def __getitem__(self, item: typing.Union[str, int]) -> typing.Any: """ Item getter (by key) From 3d305816576b2ada04e700cb29ee445ae61f814a Mon Sep 17 00:00:00 2001 From: Oleg A Date: Thu, 30 Dec 2021 16:07:09 +0300 Subject: [PATCH 03/19] docs: bump tg api version --- README.md | 2 +- aiogram/__init__.py | 4 ++-- aiogram/bot/api.py | 2 +- docs/source/index.rst | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f9052665..811ad4c9 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![PyPi status](https://img.shields.io/pypi/status/aiogram.svg?style=flat-square)](https://pypi.python.org/pypi/aiogram) [![Downloads](https://img.shields.io/pypi/dm/aiogram.svg?style=flat-square)](https://pypi.python.org/pypi/aiogram) [![Supported python versions](https://img.shields.io/pypi/pyversions/aiogram.svg?style=flat-square)](https://pypi.python.org/pypi/aiogram) -[![Telegram Bot API](https://img.shields.io/badge/Telegram%20Bot%20API-5.5-blue.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api) +[![Telegram Bot API](https://img.shields.io/badge/Telegram%20Bot%20API-5.6-blue.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api) [![Documentation Status](https://img.shields.io/readthedocs/aiogram?style=flat-square)](http://docs.aiogram.dev/en/latest/?badge=latest) [![Github issues](https://img.shields.io/github/issues/aiogram/aiogram.svg?style=flat-square)](https://github.com/aiogram/aiogram/issues) [![MIT License](https://img.shields.io/pypi/l/aiogram.svg?style=flat-square)](https://opensource.org/licenses/MIT) diff --git a/aiogram/__init__.py b/aiogram/__init__.py index ea77a533..a180b08d 100644 --- a/aiogram/__init__.py +++ b/aiogram/__init__.py @@ -43,5 +43,5 @@ __all__ = ( 'utils', ) -__version__ = '2.17.1' -__api_version__ = '5.5' +__version__ = '2.18.0' +__api_version__ = '5.6' diff --git a/aiogram/bot/api.py b/aiogram/bot/api.py index fca5b738..f95e35b1 100644 --- a/aiogram/bot/api.py +++ b/aiogram/bot/api.py @@ -189,7 +189,7 @@ class Methods(Helper): """ Helper for Telegram API Methods listed on https://core.telegram.org/bots/api - List is updated to Bot API 5.5 + List is updated to Bot API 5.6 """ mode = HelperMode.lowerCamelCase diff --git a/docs/source/index.rst b/docs/source/index.rst index a4ce2354..98bd08ed 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -22,7 +22,7 @@ Welcome to aiogram's documentation! :target: https://pypi.python.org/pypi/aiogram :alt: Supported python versions - .. image:: https://img.shields.io/badge/Telegram%20Bot%20API-5.5-blue.svg?style=flat-square&logo=telegram + .. image:: https://img.shields.io/badge/Telegram%20Bot%20API-5.6-blue.svg?style=flat-square&logo=telegram :target: https://core.telegram.org/bots/api :alt: Telegram Bot API From e0ecbc4ec95a1095179fa3d0ae6ce35394972f2e Mon Sep 17 00:00:00 2001 From: Oleg A Date: Thu, 30 Dec 2021 16:26:31 +0300 Subject: [PATCH 04/19] feat: add protect_content param --- aiogram/bot/bot.py | 112 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 106 insertions(+), 6 deletions(-) diff --git a/aiogram/bot/bot.py b/aiogram/bot/bot.py index 6653cf89..90beb294 100644 --- a/aiogram/bot/bot.py +++ b/aiogram/bot/bot.py @@ -276,6 +276,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, + protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send text messages. @@ -314,6 +315,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -329,7 +334,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): async def forward_message(self, chat_id: typing.Union[base.Integer, base.String], from_chat_id: typing.Union[base.Integer, base.String], message_id: base.Integer, - disable_notification: typing.Optional[base.Boolean] = None) -> types.Message: + disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, + ) -> types.Message: """ Use this method to forward messages of any kind. @@ -343,6 +350,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type disable_notification: :obj:`typing.Optional[base.Boolean]` :param message_id: Message identifier in the chat specified in from_chat_id :type message_id: :obj:`base.Integer` + :param protect_content: Protects the contents of the forwarded + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -365,6 +375,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, + protect_content: typing.Optional[base.Boolean] = None, ) -> types.MessageId: """ Use this method to copy messages of any kind. The method is analogous to the @@ -416,6 +427,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` + :param protect_content: Protects the contents of the sent + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -442,6 +457,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, + protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send photos. @@ -480,6 +496,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` + :param protect_content: Protects the contents of the sent + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -512,6 +532,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, + protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send audio files, if you want Telegram clients to display them in the music player. @@ -565,6 +586,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` + :param protect_content: Protects the contents of the sent + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -597,6 +622,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardRemove, types.ForceReply, None] = None, + protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send general files. On success, the sent Message is @@ -650,6 +676,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply], None]` + :param protect_content: Protects the contents of the sent + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -682,7 +712,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): reply_markup: typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, - types.ForceReply, None] = None) -> types.Message: + types.ForceReply, None] = None, + protect_content: typing.Optional[base.Boolean] = None, + ) -> types.Message: """ Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). @@ -736,6 +768,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` + :param protect_content: Protects the contents of the sent + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -769,6 +805,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply], None] = None, + protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). @@ -826,6 +863,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply], None]` + :param protect_content: Protects the contents of the sent + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -856,6 +897,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, + protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send audio files, if you want Telegram clients to display the file @@ -901,6 +943,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` + :param protect_content: Protects the contents of the sent + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -927,7 +973,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): reply_markup: typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, - types.ForceReply, None] = None) -> types.Message: + types.ForceReply, None] = None, + protect_content: typing.Optional[base.Boolean] = None, + ) -> types.Message: """ As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages. @@ -964,6 +1012,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` + :param protect_content: Protects the contents of the sent + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -982,6 +1034,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): disable_notification: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, ) -> typing.List[types.Message]: """ Use this method to send a group of photos, videos, documents or audios as @@ -1011,6 +1064,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of the sent + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, an array of the sent Messages is returned :rtype: typing.List[types.Message] """ @@ -1042,7 +1099,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): reply_markup: typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, - types.ForceReply, None] = None) -> types.Message: + types.ForceReply, None] = None, + protect_content: typing.Optional[base.Boolean] = None, + ) -> types.Message: """ Use this method to send point on the map. @@ -1088,6 +1147,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` + :param protect_content: Protects the contents of the sent + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -1207,6 +1270,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, + protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send information about a venue. @@ -1261,6 +1325,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` + :param protect_content: Protects the contents of the sent + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -1280,7 +1348,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): reply_markup: typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, - types.ForceReply, None] = None) -> types.Message: + types.ForceReply, None] = None, + protect_content: typing.Optional[base.Boolean] = None, + ) -> types.Message: """ Use this method to send phone contacts. @@ -1316,6 +1386,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` + :param protect_content: Protects the contents of the sent + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -1350,6 +1424,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, + protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send a native poll. On success, the sent Message is @@ -1426,6 +1501,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` + :param protect_content: Protects the contents of the sent + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -1450,6 +1529,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, + protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send an animated emoji that will display a random value. @@ -1484,6 +1564,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` + :param protect_content: Protects the contents of the sent + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -2735,7 +2819,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): reply_markup: typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, - types.ForceReply, None] = None) -> types.Message: + types.ForceReply, None] = None, + protect_content: typing.Optional[base.Boolean] = None, + ) -> types.Message: """ Use this method to send .webp stickers. @@ -2762,6 +2848,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` + :param protect_content: Protects the contents of the sent + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -3049,6 +3139,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None, + protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send invoices. @@ -3156,6 +3247,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button. :type reply_markup: :obj:`typing.Optional[types.InlineKeyboardMarkup]` + :param protect_content: Protects the contents of the sent + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -3268,6 +3363,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None, + protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send a game. @@ -3295,6 +3391,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): If empty, one ‘Play game_title’ button will be shown. If not empty, the first button must launch the game. :type reply_markup: :obj:`typing.Optional[types.InlineKeyboardMarkup]` + :param protect_content: Protects the contents of the sent + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ From 1e86ec064353074a376f2735ef02d977c6160274 Mon Sep 17 00:00:00 2001 From: Oleg A Date: Thu, 30 Dec 2021 16:45:33 +0300 Subject: [PATCH 05/19] feat: add spoiler entities --- aiogram/types/message_entity.py | 13 +++++++++---- aiogram/utils/markdown.py | 27 +++++++++++++++++++++++++++ aiogram/utils/text_decorations.py | 14 ++++++++++++-- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/aiogram/types/message_entity.py b/aiogram/types/message_entity.py index b2aaf425..9788af05 100644 --- a/aiogram/types/message_entity.py +++ b/aiogram/types/message_entity.py @@ -77,6 +77,9 @@ class MessageEntity(base.TelegramObject): if self.type == MessageEntityType.ITALIC: method = markdown.hitalic if as_html else markdown.italic return method(entity_text) + if self.type == MessageEntityType.SPOILER: + method = markdown.spoiler if as_html else markdown.hspoiler + return method(entity_text) if self.type == MessageEntityType.PRE: method = markdown.hpre if as_html else markdown.pre return method(entity_text) @@ -108,10 +111,11 @@ class MessageEntityType(helper.Helper): :key: PHONE_NUMBER :key: BOLD :key: ITALIC - :key: CODE - :key: PRE :key: UNDERLINE :key: STRIKETHROUGH + :key: SPOILER + :key: CODE + :key: PRE :key: TEXT_LINK :key: TEXT_MENTION """ @@ -127,9 +131,10 @@ class MessageEntityType(helper.Helper): PHONE_NUMBER = helper.Item() # phone_number BOLD = helper.Item() # bold - bold text ITALIC = helper.Item() # italic - italic text - CODE = helper.Item() # code - monowidth string - PRE = helper.Item() # pre - monowidth block UNDERLINE = helper.Item() # underline STRIKETHROUGH = helper.Item() # strikethrough + SPOILER = helper.Item() # spoiler + CODE = helper.Item() # code - monowidth string + PRE = helper.Item() # pre - monowidth block TEXT_LINK = helper.Item() # text_link - for clickable text URLs TEXT_MENTION = helper.Item() # text_mention - for users without usernames diff --git a/aiogram/utils/markdown.py b/aiogram/utils/markdown.py index 75f5fea0..3b50ffd4 100644 --- a/aiogram/utils/markdown.py +++ b/aiogram/utils/markdown.py @@ -7,6 +7,7 @@ MD_SYMBOLS = ( (LIST_MD_SYMBOLS[1], LIST_MD_SYMBOLS[1]), (LIST_MD_SYMBOLS[2], LIST_MD_SYMBOLS[2]), (LIST_MD_SYMBOLS[2] * 3 + "\n", "\n" + LIST_MD_SYMBOLS[2] * 3), + ("||", "||"), ("", ""), ("", ""), ("", ""), @@ -113,6 +114,32 @@ def hitalic(*content, sep=" ") -> str: ) +def spoiler(*content, sep=" ") -> str: + """ + Make spoiler text (Markdown) + + :param content: + :param sep: + :return: + """ + return markdown_decoration.spoiler( + value=markdown_decoration.quote(_join(*content, sep=sep)) + ) + + +def hspoiler(*content, sep=" ") -> str: + """ + Make spoiler text (HTML) + + :param content: + :param sep: + :return: + """ + return html_decoration.spoiler( + value=html_decoration.quote(_join(*content, sep=sep)) + ) + + def code(*content, sep=" ") -> str: """ Make mono-width text (Markdown) diff --git a/aiogram/utils/text_decorations.py b/aiogram/utils/text_decorations.py index 40fe296b..ae9af7d4 100644 --- a/aiogram/utils/text_decorations.py +++ b/aiogram/utils/text_decorations.py @@ -27,9 +27,9 @@ class TextDecoration(ABC): :return: """ if entity.type in {"bot_command", "url", "mention", "phone_number"}: - # This entities should not be changed + # These entities should not be changed return text - if entity.type in {"bold", "italic", "code", "underline", "strikethrough"}: + if entity.type in {"bold", "italic", "spoiler", "code", "underline", "strikethrough"}: return cast(str, getattr(self, entity.type)(value=text)) if entity.type == "pre": return ( @@ -115,6 +115,10 @@ class TextDecoration(ABC): def italic(self, value: str) -> str: # pragma: no cover pass + @abstractmethod + def spoiler(self, value: str) -> str: # pragma: no cover + pass + @abstractmethod def code(self, value: str) -> str: # pragma: no cover pass @@ -150,6 +154,9 @@ class HtmlDecoration(TextDecoration): def italic(self, value: str) -> str: return f"{value}" + def spoiler(self, value: str) -> str: + return f'{value}' + def code(self, value: str) -> str: return f"{value}" @@ -181,6 +188,9 @@ class MarkdownDecoration(TextDecoration): def italic(self, value: str) -> str: return f"_\r{value}_\r" + def spoiler(self, value: str) -> str: + return f"||{value}||" + def code(self, value: str) -> str: return f"`{value}`" From 61ef1cc14f00076fea88d299a0013846632255a4 Mon Sep 17 00:00:00 2001 From: Oleg A Date: Fri, 31 Dec 2021 00:49:47 +0300 Subject: [PATCH 06/19] style: reorder methods similar to docs --- aiogram/bot/bot.py | 205 ++++++++++++++++++++++++--------------------- 1 file changed, 108 insertions(+), 97 deletions(-) diff --git a/aiogram/bot/bot.py b/aiogram/bot/bot.py index 90beb294..bf1a6c55 100644 --- a/aiogram/bot/bot.py +++ b/aiogram/bot/bot.py @@ -270,13 +270,13 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): entities: typing.Optional[typing.List[types.MessageEntity]] = None, disable_web_page_preview: typing.Optional[base.Boolean] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, - protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send text messages. @@ -303,6 +303,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Optional[base.Integer]` @@ -315,10 +319,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` - :param protect_content: Protects the contents of sent messages - from forwarding and saving - :type protect_content: :obj:`typing.Optional[base.Boolean]` - :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -332,8 +332,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): result = await self.request(api.Methods.SEND_MESSAGE, payload) return types.Message(**result) - async def forward_message(self, chat_id: typing.Union[base.Integer, base.String], - from_chat_id: typing.Union[base.Integer, base.String], message_id: base.Integer, + async def forward_message(self, + chat_id: typing.Union[base.Integer, base.String], + from_chat_id: typing.Union[base.Integer, base.String], + message_id: base.Integer, disable_notification: typing.Optional[base.Boolean] = None, protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: @@ -342,17 +344,26 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): Source: https://core.telegram.org/bots/api#forwardmessage - :param chat_id: Unique identifier for the target chat or username of the target channel + :param chat_id: Unique identifier for the target chat or + username of the target channel :type chat_id: :obj:`typing.Union[base.Integer, base.String]` - :param from_chat_id: Unique identifier for the chat where the original message was sent + + :param from_chat_id: Unique identifier for the chat where the + original message was sent :type from_chat_id: :obj:`typing.Union[base.Integer, base.String]` - :param disable_notification: Sends the message silently. Users will receive a notification with no sound + + :param disable_notification: Sends the message silently. Users + will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` - :param message_id: Message identifier in the chat specified in from_chat_id - :type message_id: :obj:`base.Integer` + :param protect_content: Protects the contents of the forwarded message from forwarding and saving :type protect_content: :obj:`typing.Optional[base.Boolean]` + + :param message_id: Message identifier in the chat specified in + from_chat_id + :type message_id: :obj:`base.Integer` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -369,13 +380,13 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): parse_mode: typing.Optional[base.String] = None, caption_entities: typing.Optional[typing.List[types.MessageEntity]] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, - protect_content: typing.Optional[base.Boolean] = None, ) -> types.MessageId: """ Use this method to copy messages of any kind. The method is analogous to the @@ -412,6 +423,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Optional[base.Integer]` @@ -427,10 +442,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` - :param protect_content: Protects the contents of the sent - message from forwarding and saving - :type protect_content: :obj:`typing.Optional[base.Boolean]` - :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -451,13 +462,13 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): parse_mode: typing.Optional[base.String] = None, caption_entities: typing.Optional[typing.List[types.MessageEntity]] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, - protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send photos. @@ -484,6 +495,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Optional[base.Integer]` @@ -496,10 +511,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` - :param protect_content: Protects the contents of the sent - message from forwarding and saving - :type protect_content: :obj:`typing.Optional[base.Boolean]` - :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -526,13 +537,13 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): title: typing.Optional[base.String] = None, thumb: typing.Union[base.InputFile, base.String, None] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, - protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send audio files, if you want Telegram clients to display them in the music player. @@ -574,6 +585,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Optional[base.Integer]` @@ -586,10 +601,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` - :param protect_content: Protects the contents of the sent - message from forwarding and saving - :type protect_content: :obj:`typing.Optional[base.Boolean]` - :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -615,6 +626,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): caption_entities: typing.Optional[typing.List[types.MessageEntity]] = None, disable_content_type_detection: typing.Optional[base.Boolean] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[types.InlineKeyboardMarkup, @@ -622,7 +634,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardRemove, types.ForceReply, None] = None, - protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send general files. On success, the sent Message is @@ -661,6 +672,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Optional[base.Integer]` @@ -676,10 +691,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply], None]` - :param protect_content: Protects the contents of the sent - message from forwarding and saving - :type protect_content: :obj:`typing.Optional[base.Boolean]` - :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -707,13 +718,13 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): caption_entities: typing.Optional[typing.List[types.MessageEntity]] = None, supports_streaming: typing.Optional[base.Boolean] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, - protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send video files, Telegram clients support mp4 videos @@ -756,6 +767,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Optional[base.Integer]` @@ -768,10 +783,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` - :param protect_content: Protects the contents of the sent - message from forwarding and saving - :type protect_content: :obj:`typing.Optional[base.Boolean]` - :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -799,13 +810,13 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): parse_mode: typing.Optional[base.String] = None, caption_entities: typing.Optional[typing.List[types.MessageEntity]] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply], None] = None, - protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). @@ -851,6 +862,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Optional[base.Integer]` @@ -863,10 +878,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply], None]` - :param protect_content: Protects the contents of the sent - message from forwarding and saving - :type protect_content: :obj:`typing.Optional[base.Boolean]` - :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -891,13 +902,13 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): caption_entities: typing.Optional[typing.List[types.MessageEntity]] = None, duration: typing.Optional[base.Integer] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, - protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send audio files, if you want Telegram clients to display the file @@ -931,6 +942,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Optional[base.Integer]` @@ -943,10 +958,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` - :param protect_content: Protects the contents of the sent - message from forwarding and saving - :type protect_content: :obj:`typing.Optional[base.Boolean]` - :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -968,13 +979,13 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): length: typing.Optional[base.Integer] = None, thumb: typing.Union[base.InputFile, base.String, None] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, - protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. @@ -1000,6 +1011,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Optional[base.Integer]` @@ -1012,10 +1027,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` - :param protect_content: Protects the contents of the sent - message from forwarding and saving - :type protect_content: :obj:`typing.Optional[base.Boolean]` - :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -1032,9 +1043,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): chat_id: typing.Union[base.Integer, base.String], media: typing.Union[types.MediaGroup, typing.List], disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, - protect_content: typing.Optional[base.Boolean] = None, ) -> typing.List[types.Message]: """ Use this method to send a group of photos, videos, documents or audios as @@ -1056,6 +1067,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): notification with no sound. :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_to_message_id: If the messages are a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Optional[base.Integer]` @@ -1064,10 +1079,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` - :param protect_content: Protects the contents of the sent - message from forwarding and saving - :type protect_content: :obj:`typing.Optional[base.Boolean]` - :return: On success, an array of the sent Messages is returned :rtype: typing.List[types.Message] """ @@ -1094,13 +1105,13 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): heading: typing.Optional[base.Integer] = None, proximity_alert_radius: typing.Optional[base.Integer] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, - protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send point on the map. @@ -1135,6 +1146,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Optional[base.Integer]` @@ -1147,10 +1162,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` - :param protect_content: Protects the contents of the sent - message from forwarding and saving - :type protect_content: :obj:`typing.Optional[base.Boolean]` - :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -1264,13 +1275,13 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): google_place_id: typing.Optional[base.String] = None, google_place_type: typing.Optional[base.String] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, - protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send information about a venue. @@ -1310,6 +1321,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Optional[base.Integer]` @@ -1325,10 +1340,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` - :param protect_content: Protects the contents of the sent - message from forwarding and saving - :type protect_content: :obj:`typing.Optional[base.Boolean]` - :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -1343,13 +1354,13 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): last_name: typing.Optional[base.String] = None, vcard: typing.Optional[base.String] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, - protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send phone contacts. @@ -1374,6 +1385,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Optional[base.Integer]` @@ -1386,10 +1401,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` - :param protect_content: Protects the contents of the sent - message from forwarding and saving - :type protect_content: :obj:`typing.Optional[base.Boolean]` - :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -1418,13 +1429,13 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): None] = None, is_closed: typing.Optional[base.Boolean] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, - protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send a native poll. On success, the sent Message is @@ -1486,6 +1497,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): a notification with no sound. :type disable_notification: :obj:`typing.Optional[Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Optional[Integer]` @@ -1501,10 +1516,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` - :param protect_content: Protects the contents of the sent - message from forwarding and saving - :type protect_content: :obj:`typing.Optional[base.Boolean]` - :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -1522,6 +1533,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): async def send_dice(self, chat_id: typing.Union[base.Integer, base.String], disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, emoji: typing.Optional[base.String] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, @@ -1529,7 +1541,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, - protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send an animated emoji that will display a random value. @@ -1551,6 +1562,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Optional[base.Integer]` @@ -1564,10 +1579,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` - :param protect_content: Protects the contents of the sent - message from forwarding and saving - :type protect_content: :obj:`typing.Optional[base.Boolean]` - :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -2814,13 +2825,13 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): async def send_sticker(self, chat_id: typing.Union[base.Integer, base.String], sticker: typing.Union[base.InputFile, base.String], disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None] = None, - protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send .webp stickers. @@ -2836,6 +2847,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Optional[base.Integer]` @@ -2848,10 +2863,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` - :param protect_content: Protects the contents of the sent - message from forwarding and saving - :type protect_content: :obj:`typing.Optional[base.Boolean]` - :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -3136,10 +3147,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): send_email_to_provider: typing.Optional[base.Boolean] = None, is_flexible: typing.Optional[base.Boolean] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None, - protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send invoices. @@ -3236,6 +3247,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Optional[base.Integer]` @@ -3247,10 +3262,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button. :type reply_markup: :obj:`typing.Optional[types.InlineKeyboardMarkup]` - :param protect_content: Protects the contents of the sent - message from forwarding and saving - :type protect_content: :obj:`typing.Optional[base.Boolean]` - :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ @@ -3360,10 +3371,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): chat_id: base.Integer, game_short_name: base.String, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None, - protect_content: typing.Optional[base.Boolean] = None, ) -> types.Message: """ Use this method to send a game. @@ -3380,6 +3391,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Optional[base.Integer]` @@ -3391,10 +3406,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): If empty, one ‘Play game_title’ button will be shown. If not empty, the first button must launch the game. :type reply_markup: :obj:`typing.Optional[types.InlineKeyboardMarkup]` - :param protect_content: Protects the contents of the sent - message from forwarding and saving - :type protect_content: :obj:`typing.Optional[base.Boolean]` - :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ From 6b15b1977713a9840610d964ace0e5829e8f4cc1 Mon Sep 17 00:00:00 2001 From: Oleg A Date: Fri, 31 Dec 2021 01:19:45 +0300 Subject: [PATCH 07/19] feat: add protect to shortcuts --- aiogram/types/message.py | 206 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 203 insertions(+), 3 deletions(-) diff --git a/aiogram/types/message.py b/aiogram/types/message.py index fa73f2e4..10ef8776 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -315,6 +315,7 @@ class Message(base.TelegramObject): entities: typing.Optional[typing.List[MessageEntity]] = None, disable_web_page_preview: typing.Optional[base.Boolean] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -345,6 +346,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -367,6 +372,7 @@ class Message(base.TelegramObject): entities=entities, disable_web_page_preview=disable_web_page_preview, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -379,6 +385,7 @@ class Message(base.TelegramObject): parse_mode: typing.Optional[base.String] = None, caption_entities: typing.Optional[typing.List[MessageEntity]] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -411,6 +418,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -433,6 +444,7 @@ class Message(base.TelegramObject): parse_mode=parse_mode, caption_entities=caption_entities, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -449,6 +461,7 @@ class Message(base.TelegramObject): title: typing.Optional[base.String] = None, thumb: typing.Union[typing.Union[base.InputFile, base.String], None] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -497,6 +510,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -523,6 +540,7 @@ class Message(base.TelegramObject): title=title, thumb=thumb, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -539,6 +557,7 @@ class Message(base.TelegramObject): parse_mode: typing.Optional[base.String] = None, caption_entities: typing.Optional[typing.List[MessageEntity]] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -589,6 +608,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -615,6 +638,7 @@ class Message(base.TelegramObject): parse_mode=parse_mode, caption_entities=caption_entities, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -629,6 +653,7 @@ class Message(base.TelegramObject): caption_entities: typing.Optional[typing.List[MessageEntity]] = None, disable_content_type_detection: typing.Optional[base.Boolean] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -672,6 +697,10 @@ class Message(base.TelegramObject): notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -698,6 +727,7 @@ class Message(base.TelegramObject): caption_entities=caption_entities, disable_content_type_detection=disable_content_type_detection, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -715,6 +745,7 @@ class Message(base.TelegramObject): caption_entities: typing.Optional[typing.List[MessageEntity]] = None, supports_streaming: typing.Optional[base.Boolean] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -764,6 +795,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -791,6 +826,7 @@ class Message(base.TelegramObject): caption_entities=caption_entities, supports_streaming=supports_streaming, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -804,6 +840,7 @@ class Message(base.TelegramObject): caption_entities: typing.Optional[typing.List[MessageEntity]] = None, duration: typing.Optional[base.Integer] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -843,6 +880,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -866,6 +907,7 @@ class Message(base.TelegramObject): caption_entities=caption_entities, duration=duration, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -878,6 +920,7 @@ class Message(base.TelegramObject): length: typing.Optional[base.Integer] = None, thumb: typing.Union[typing.Union[base.InputFile, base.String], None] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -910,6 +953,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -932,6 +979,7 @@ class Message(base.TelegramObject): length=length, thumb=thumb, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -941,6 +989,7 @@ class Message(base.TelegramObject): self, media: typing.Union[MediaGroup, typing.List], disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply: base.Boolean = False, ) -> typing.List[Message]: @@ -959,6 +1008,10 @@ class Message(base.TelegramObject): a notification with no sound. :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -973,6 +1026,7 @@ class Message(base.TelegramObject): self.chat.id, media=media, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, ) @@ -983,6 +1037,7 @@ class Message(base.TelegramObject): longitude: base.Float, live_period: typing.Optional[base.Integer] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, horizontal_accuracy: typing.Optional[base.Float] = None, heading: typing.Optional[base.Integer] = None, @@ -1026,6 +1081,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -1050,6 +1109,7 @@ class Message(base.TelegramObject): heading=heading, proximity_alert_radius=proximity_alert_radius, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -1066,6 +1126,7 @@ class Message(base.TelegramObject): google_place_id: typing.Optional[base.String] = None, google_place_type: typing.Optional[base.String] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -1110,6 +1171,10 @@ class Message(base.TelegramObject): a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -1138,6 +1203,7 @@ class Message(base.TelegramObject): google_place_id=google_place_id, google_place_type=google_place_type, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -1149,6 +1215,7 @@ class Message(base.TelegramObject): first_name: base.String, last_name: typing.Optional[base.String] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -1176,6 +1243,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -1197,6 +1268,7 @@ class Message(base.TelegramObject): first_name=first_name, last_name=last_name, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -1206,6 +1278,7 @@ class Message(base.TelegramObject): self, sticker: typing.Union[base.InputFile, base.String], disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -1227,6 +1300,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -1246,6 +1323,7 @@ class Message(base.TelegramObject): chat_id=self.chat.id, sticker=sticker, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -1266,6 +1344,7 @@ class Message(base.TelegramObject): close_date: typing.Union[base.Integer, datetime.datetime, datetime.timedelta, None] = None, is_closed: typing.Optional[base.Boolean] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -1332,6 +1411,10 @@ class Message(base.TelegramObject): a notification with no sound. :type disable_notification: :obj:`typing.Optional[Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -1364,6 +1447,7 @@ class Message(base.TelegramObject): close_date=close_date, is_closed=is_closed, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -1373,6 +1457,7 @@ class Message(base.TelegramObject): self, emoji: typing.Optional[base.String] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -1399,6 +1484,10 @@ class Message(base.TelegramObject): a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -1420,6 +1509,7 @@ class Message(base.TelegramObject): chat_id=self.chat.id, emoji=emoji, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -1456,6 +1546,7 @@ class Message(base.TelegramObject): entities: typing.Optional[typing.List[MessageEntity]] = None, disable_web_page_preview: typing.Optional[base.Boolean] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -1486,6 +1577,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -1508,6 +1603,7 @@ class Message(base.TelegramObject): entities=entities, disable_web_page_preview=disable_web_page_preview, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -1520,6 +1616,7 @@ class Message(base.TelegramObject): parse_mode: typing.Optional[base.String] = None, caption_entities: typing.Optional[typing.List[MessageEntity]] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -1552,6 +1649,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -1574,6 +1675,7 @@ class Message(base.TelegramObject): parse_mode=parse_mode, caption_entities=caption_entities, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -1590,6 +1692,7 @@ class Message(base.TelegramObject): title: typing.Optional[base.String] = None, thumb: typing.Union[typing.Union[base.InputFile, base.String], None] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -1638,6 +1741,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -1664,6 +1771,7 @@ class Message(base.TelegramObject): title=title, thumb=thumb, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -1680,6 +1788,7 @@ class Message(base.TelegramObject): parse_mode: typing.Optional[base.String] = None, caption_entities: typing.Optional[typing.List[MessageEntity]] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -1730,6 +1839,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -1756,6 +1869,7 @@ class Message(base.TelegramObject): parse_mode=parse_mode, caption_entities=caption_entities, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -1770,6 +1884,7 @@ class Message(base.TelegramObject): caption_entities: typing.Optional[typing.List[MessageEntity]] = None, disable_content_type_detection: typing.Optional[base.Boolean] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -1813,6 +1928,10 @@ class Message(base.TelegramObject): notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -1839,6 +1958,7 @@ class Message(base.TelegramObject): caption_entities=caption_entities, disable_content_type_detection=disable_content_type_detection, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -1856,6 +1976,7 @@ class Message(base.TelegramObject): caption_entities: typing.Optional[typing.List[MessageEntity]] = None, supports_streaming: typing.Optional[base.Boolean] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -1905,6 +2026,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -1932,6 +2057,7 @@ class Message(base.TelegramObject): caption_entities=caption_entities, supports_streaming=supports_streaming, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -1945,6 +2071,7 @@ class Message(base.TelegramObject): caption_entities: typing.Optional[typing.List[MessageEntity]] = None, duration: typing.Optional[base.Integer] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -1984,6 +2111,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -2007,6 +2138,7 @@ class Message(base.TelegramObject): caption_entities=caption_entities, duration=duration, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -2019,6 +2151,7 @@ class Message(base.TelegramObject): length: typing.Optional[base.Integer] = None, thumb: typing.Union[typing.Union[base.InputFile, base.String], None] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -2051,6 +2184,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -2073,6 +2210,7 @@ class Message(base.TelegramObject): length=length, thumb=thumb, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -2082,6 +2220,7 @@ class Message(base.TelegramObject): self, media: typing.Union[MediaGroup, typing.List], disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply: base.Boolean = True, ) -> typing.List[Message]: @@ -2100,6 +2239,10 @@ class Message(base.TelegramObject): a notification with no sound. :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -2114,6 +2257,7 @@ class Message(base.TelegramObject): self.chat.id, media=media, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, ) @@ -2124,6 +2268,7 @@ class Message(base.TelegramObject): longitude: base.Float, live_period: typing.Optional[base.Integer] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, horizontal_accuracy: typing.Optional[base.Float] = None, heading: typing.Optional[base.Integer] = None, proximity_alert_radius: typing.Optional[base.Integer] = None, @@ -2166,6 +2311,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param reply_markup: Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, @@ -2186,6 +2335,7 @@ class Message(base.TelegramObject): heading=heading, proximity_alert_radius=proximity_alert_radius, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, reply_markup=reply_markup, ) @@ -2201,6 +2351,7 @@ class Message(base.TelegramObject): google_place_id: typing.Optional[base.String] = None, google_place_type: typing.Optional[base.String] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -2245,6 +2396,10 @@ class Message(base.TelegramObject): a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -2273,6 +2428,7 @@ class Message(base.TelegramObject): google_place_id=google_place_id, google_place_type=google_place_type, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -2284,6 +2440,7 @@ class Message(base.TelegramObject): first_name: base.String, last_name: typing.Optional[base.String] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -2311,6 +2468,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -2332,6 +2493,7 @@ class Message(base.TelegramObject): first_name=first_name, last_name=last_name, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -2352,6 +2514,7 @@ class Message(base.TelegramObject): close_date: typing.Union[base.Integer, datetime.datetime, datetime.timedelta, None] = None, is_closed: typing.Optional[base.Boolean] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -2418,6 +2581,10 @@ class Message(base.TelegramObject): a notification with no sound. :type disable_notification: :obj:`typing.Optional[Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -2450,6 +2617,7 @@ class Message(base.TelegramObject): close_date=close_date, is_closed=is_closed, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -2459,6 +2627,7 @@ class Message(base.TelegramObject): self, sticker: typing.Union[base.InputFile, base.String], disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -2480,6 +2649,10 @@ class Message(base.TelegramObject): :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -2499,6 +2672,7 @@ class Message(base.TelegramObject): chat_id=self.chat.id, sticker=sticker, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -2508,6 +2682,7 @@ class Message(base.TelegramObject): self, emoji: typing.Optional[base.String] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[ InlineKeyboardMarkup, @@ -2534,6 +2709,10 @@ class Message(base.TelegramObject): a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + :param protect_content: Protects the contents of sent messages + from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :param allow_sending_without_reply: Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]` @@ -2555,6 +2734,7 @@ class Message(base.TelegramObject): chat_id=self.chat.id, emoji=emoji, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=self.message_id if reply else None, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -2564,6 +2744,7 @@ class Message(base.TelegramObject): self, chat_id: typing.Union[base.Integer, base.String], disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, ) -> Message: """ Forward this message @@ -2572,13 +2753,23 @@ class Message(base.TelegramObject): :param chat_id: Unique identifier for the target chat or username of the target channel :type chat_id: :obj:`typing.Union[base.Integer, base.String]` + :param disable_notification: Sends the message silently. Users will receive a notification with no sound :type disable_notification: :obj:`typing.Optional[base.Boolean]` + + :param protect_content: Protects the contents of the forwarded + message from forwarding and saving + :type protect_content: :obj:`typing.Optional[base.Boolean]` + :return: On success, the sent Message is returned :rtype: :obj:`types.Message` """ return await self.bot.forward_message( - chat_id, self.chat.id, self.message_id, disable_notification + chat_id=chat_id, + from_chat_id=self.chat.id, + message_id=self.message_id, + disable_notification=disable_notification, + protect_content=protect_content, ) async def edit_text( @@ -2795,7 +2986,8 @@ class Message(base.TelegramObject): return await self.bot.delete_message(self.chat.id, self.message_id) async def pin( - self, disable_notification: typing.Optional[base.Boolean] = None, + self, + disable_notification: typing.Optional[base.Boolean] = None, ) -> base.Boolean: """ Use this method to add a message to the list of pinned messages in a chat. @@ -2813,7 +3005,10 @@ class Message(base.TelegramObject): :return: Returns True on success :rtype: :obj:`base.Boolean` """ - return await self.chat.pin_message(self.message_id, disable_notification) + return await self.chat.pin_message( + message_id=self.message_id, + disable_notification=disable_notification, + ) async def unpin(self) -> base.Boolean: """ @@ -2836,6 +3031,7 @@ class Message(base.TelegramObject): self: Message, chat_id: typing.Union[str, int], disable_notification: typing.Optional[bool] = None, + protect_content: typing.Optional[base.Boolean] = None, disable_web_page_preview: typing.Optional[bool] = None, reply_to_message_id: typing.Optional[int] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, @@ -2848,6 +3044,7 @@ class Message(base.TelegramObject): :param chat_id: :param disable_notification: + :param protect_content: :param disable_web_page_preview: for text messages only :param reply_to_message_id: :param allow_sending_without_reply: @@ -2860,6 +3057,7 @@ class Message(base.TelegramObject): "reply_markup": reply_markup or self.reply_markup, "parse_mode": ParseMode.HTML, "disable_notification": disable_notification, + "protect_content": protect_content, "reply_to_message_id": reply_to_message_id, } text = self.html_text if (self.text or self.caption) else None @@ -2956,6 +3154,7 @@ class Message(base.TelegramObject): parse_mode: typing.Optional[base.String] = None, caption_entities: typing.Optional[typing.List[MessageEntity]] = None, disable_notification: typing.Optional[base.Boolean] = None, + protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None, reply_markup: typing.Union[InlineKeyboardMarkup, @@ -2971,6 +3170,7 @@ class Message(base.TelegramObject): parse_mode=parse_mode, caption_entities=caption_entities, disable_notification=disable_notification, + protect_content=protect_content, reply_to_message_id=reply_to_message_id, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup From c61410b5269614f8e26e98362c7d096bb5e843ce Mon Sep 17 00:00:00 2001 From: Oleg A Date: Sat, 1 Jan 2022 13:14:15 +0300 Subject: [PATCH 08/19] fix: add span to MD_SYMBOLS --- aiogram/utils/markdown.py | 1 + 1 file changed, 1 insertion(+) diff --git a/aiogram/utils/markdown.py b/aiogram/utils/markdown.py index 3b50ffd4..1a8b7fa3 100644 --- a/aiogram/utils/markdown.py +++ b/aiogram/utils/markdown.py @@ -12,6 +12,7 @@ MD_SYMBOLS = ( ("", ""), ("", ""), ("
", "
"), + ('', ""), ) HTML_QUOTES_MAP = {"<": "<", ">": ">", "&": "&", '"': """} From c0e8aa34c6fb68af42b05876d23dfa13b81703bd Mon Sep 17 00:00:00 2001 From: Oleg A Date: Sat, 1 Jan 2022 14:41:40 +0300 Subject: [PATCH 09/19] chore: remove redundant part of version Co-authored-by: evgfilim1 --- aiogram/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiogram/__init__.py b/aiogram/__init__.py index a180b08d..3c8f6014 100644 --- a/aiogram/__init__.py +++ b/aiogram/__init__.py @@ -43,5 +43,5 @@ __all__ = ( 'utils', ) -__version__ = '2.18.0' +__version__ = '2.18' __api_version__ = '5.6' From 5cb7ecd4b2b67d77795793f667756b04d338f215 Mon Sep 17 00:00:00 2001 From: Oleg A Date: Sat, 1 Jan 2022 22:59:18 +0300 Subject: [PATCH 10/19] chore: add tag --- aiogram/utils/markdown.py | 1 + 1 file changed, 1 insertion(+) diff --git a/aiogram/utils/markdown.py b/aiogram/utils/markdown.py index 1a8b7fa3..dfce1096 100644 --- a/aiogram/utils/markdown.py +++ b/aiogram/utils/markdown.py @@ -13,6 +13,7 @@ MD_SYMBOLS = ( ("", ""), ("
", "
"), ('', ""), + ("", ""), ) HTML_QUOTES_MAP = {"<": "<", ">": ">", "&": "&", '"': """} From 301a43e26b02297fec20b768ac2ce752e690a4d4 Mon Sep 17 00:00:00 2001 From: samuelfirst Date: Mon, 20 Sep 2021 23:11:38 +0300 Subject: [PATCH 11/19] Set default disable_web_page_preview --- aiogram/bot/base.py | 22 ++++++++++++++++++++++ aiogram/bot/bot.py | 5 ++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/aiogram/bot/base.py b/aiogram/bot/base.py index 600152f6..f885e6dc 100644 --- a/aiogram/bot/base.py +++ b/aiogram/bot/base.py @@ -37,6 +37,7 @@ class BaseBot: proxy_auth: Optional[aiohttp.BasicAuth] = None, validate_token: Optional[base.Boolean] = True, parse_mode: typing.Optional[base.String] = None, + disable_web_page_preview: Optional[base.Boolean] = None, timeout: typing.Optional[typing.Union[base.Integer, base.Float, aiohttp.ClientTimeout]] = None, server: TelegramAPIServer = TELEGRAM_PRODUCTION ): @@ -57,6 +58,8 @@ class BaseBot: :type validate_token: :obj:`bool` :param parse_mode: You can set default parse mode :type parse_mode: :obj:`str` + :param disable_web_page_preview: You can set default disable web page preview parameter + :type disable_web_page_preview: :obj:`bool` :param timeout: Request timeout :type timeout: :obj:`typing.Optional[typing.Union[base.Integer, base.Float, aiohttp.ClientTimeout]]` :param server: Telegram Bot API Server endpoint. @@ -107,6 +110,8 @@ class BaseBot: self.parse_mode = parse_mode + self.disable_web_page_preview = disable_web_page_preview + async def get_new_session(self) -> aiohttp.ClientSession: return aiohttp.ClientSession( connector=self._connector_class(**self._connector_init), @@ -333,5 +338,22 @@ class BaseBot: def parse_mode(self): self.parse_mode = None + @property + def disable_web_page_preview(self): + return getattr(self, '_disable_web_page_preview', None) + + @disable_web_page_preview.setter + def disable_web_page_preview(self, value): + if value is None: + setattr(self, '_disable_web_page_preview', None) + else: + if not isinstance(value, bool): + raise TypeError(f"Disable web page preview must be bool, not {type(value)}") + setattr(self, '_disable_web_page_preview', value) + + @disable_web_page_preview.deleter + def disable_web_page_preview(self): + self.disable_web_page_preview = None + def check_auth_widget(self, data): return check_integrity(self.__token, data) diff --git a/aiogram/bot/bot.py b/aiogram/bot/bot.py index 6653cf89..e5964fa0 100644 --- a/aiogram/bot/bot.py +++ b/aiogram/bot/bot.py @@ -323,6 +323,8 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): payload = generate_payload(**locals()) if self.parse_mode and entities is None: payload.setdefault('parse_mode', self.parse_mode) + if self.disable_web_page_preview: + payload.setdefault('disable_web_page_preview', self.disable_web_page_preview) result = await self.request(api.Methods.SEND_MESSAGE, payload) return types.Message(**result) @@ -422,7 +424,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): reply_markup = prepare_arg(reply_markup) caption_entities = prepare_arg(caption_entities) payload = generate_payload(**locals()) - if self.parse_mode and caption_entities is None: payload.setdefault('parse_mode', self.parse_mode) @@ -2543,6 +2544,8 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): payload = generate_payload(**locals()) if self.parse_mode and entities is None: payload.setdefault('parse_mode', self.parse_mode) + if self.disable_web_page_preview: + payload.setdefault('disable_web_page_preview', self.disable_web_page_preview) result = await self.request(api.Methods.EDIT_MESSAGE_TEXT, payload) if isinstance(result, bool): From 2b1c72c08c7c42a23a39285c3130a26527e90217 Mon Sep 17 00:00:00 2001 From: samuelfirst Date: Mon, 20 Sep 2021 23:11:50 +0300 Subject: [PATCH 12/19] Use global disable_web_page_preview in InputTextMessageContent --- aiogram/types/input_message_content.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/aiogram/types/input_message_content.py b/aiogram/types/input_message_content.py index f0c452cd..8406bd05 100644 --- a/aiogram/types/input_message_content.py +++ b/aiogram/types/input_message_content.py @@ -154,6 +154,12 @@ class InputTextMessageContent(InputMessageContent): except RuntimeError: pass + def safe_get_disable_web_page_preview(self): + try: + return self.bot.disable_web_page_preview + except RuntimeError: + pass + def __init__( self, message_text: base.String, @@ -163,6 +169,8 @@ class InputTextMessageContent(InputMessageContent): ): if parse_mode is None: parse_mode = self.safe_get_parse_mode() + if disable_web_page_preview is None: + disable_web_page_preview = self.safe_get_disable_web_page_preview() super().__init__( message_text=message_text, From 859876bed19a812fd126dc937e91600867b8a2f7 Mon Sep 17 00:00:00 2001 From: samuelfirst Date: Mon, 20 Sep 2021 23:12:05 +0300 Subject: [PATCH 13/19] Use global disable_web_page_preview in SendMessage and EditMessageText classes --- aiogram/dispatcher/webhook.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/aiogram/dispatcher/webhook.py b/aiogram/dispatcher/webhook.py index 11e3238c..92e475ff 100644 --- a/aiogram/dispatcher/webhook.py +++ b/aiogram/dispatcher/webhook.py @@ -435,6 +435,18 @@ class DisableWebPagePreviewMixin: setattr(self, 'disable_web_page_preview', True) return self + @staticmethod + def _global_disable_web_page_preview(): + """ + Detect global disable web page preview value + + :return: + """ + from aiogram import Bot + bot = Bot.get_current() + if bot is not None: + return bot.disable_web_page_preview + class ParseModeMixin: def as_html(self): @@ -506,6 +518,8 @@ class SendMessage(BaseResponse, ReplyToMixin, ParseModeMixin, DisableNotificatio text = '' if parse_mode is None: parse_mode = self._global_parse_mode() + if disable_web_page_preview is None: + disable_web_page_preview = self._global_disable_web_page_preview() self.chat_id = chat_id self.text = text @@ -1591,6 +1605,8 @@ class EditMessageText(BaseResponse, ParseModeMixin, DisableWebPagePreviewMixin): """ if parse_mode is None: parse_mode = self._global_parse_mode() + if disable_web_page_preview is None: + disable_web_page_preview = self._global_disable_web_page_preview() self.chat_id = chat_id self.message_id = message_id From a0510b33b92dda65670d5c20c5bad1020a4e71dd Mon Sep 17 00:00:00 2001 From: Ramzan Bekbulatov Date: Sun, 2 Jan 2022 22:03:07 +0300 Subject: [PATCH 14/19] Remove unused code from fsm.py (#780) --- aiogram/contrib/middlewares/fsm.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/aiogram/contrib/middlewares/fsm.py b/aiogram/contrib/middlewares/fsm.py index e3550a34..d198417f 100644 --- a/aiogram/contrib/middlewares/fsm.py +++ b/aiogram/contrib/middlewares/fsm.py @@ -1,5 +1,4 @@ import copy -import weakref from aiogram.dispatcher.middlewares import LifetimeControllerMiddleware from aiogram.dispatcher.storage import FSMContext @@ -8,10 +7,6 @@ from aiogram.dispatcher.storage import FSMContext class FSMMiddleware(LifetimeControllerMiddleware): skip_patterns = ['error', 'update'] - def __init__(self): - super(FSMMiddleware, self).__init__() - self._proxies = weakref.WeakKeyDictionary() - async def pre_process(self, obj, data, *args): proxy = await FSMSStorageProxy.create(self.manager.dispatcher.current_state()) data['state_data'] = proxy From 4d2d81138681d730270819579f22b3a0001c43a5 Mon Sep 17 00:00:00 2001 From: Oleg A Date: Sun, 2 Jan 2022 23:36:44 +0300 Subject: [PATCH 15/19] docs: bot API version update (#802) --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 6df651a2..0ec4b454 100644 --- a/README.rst +++ b/README.rst @@ -21,7 +21,7 @@ AIOGramBot :target: https://pypi.python.org/pypi/aiogram :alt: Supported python versions -.. image:: https://img.shields.io/badge/Telegram%20Bot%20API-5.3-blue.svg?style=flat-square&logo=telegram +.. image:: https://img.shields.io/badge/Telegram%20Bot%20API-5.6-blue.svg?style=flat-square&logo=telegram :target: https://core.telegram.org/bots/api :alt: Telegram Bot API From c77691d668a56743d74788e1de711547f657da39 Mon Sep 17 00:00:00 2001 From: Kostiantyn Kriuchkov <36363097+Latand@users.noreply.github.com> Date: Wed, 26 Jan 2022 20:24:38 +0200 Subject: [PATCH 16/19] Fixed to Bot API documentation in docstring (#820) --- aiogram/types/chat_join_request.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiogram/types/chat_join_request.py b/aiogram/types/chat_join_request.py index 71ee964a..3f8ce846 100644 --- a/aiogram/types/chat_join_request.py +++ b/aiogram/types/chat_join_request.py @@ -11,7 +11,7 @@ class ChatJoinRequest(base.TelegramObject): """ Represents a join request sent to a chat. - https://core.telegram.org/bots/api#chatinvitelink + https://core.telegram.org/bots/api#chatjoinrequest """ chat: Chat = fields.Field(base=Chat) From dd4cc7fbbb3aed10bdd94a6cd45c8768e9d4831c Mon Sep 17 00:00:00 2001 From: Max Smirnov Date: Wed, 26 Jan 2022 21:25:11 +0300 Subject: [PATCH 17/19] Remove unnecessary `Optional`s (#818) --- aiogram/dispatcher/dispatcher.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/aiogram/dispatcher/dispatcher.py b/aiogram/dispatcher/dispatcher.py index e6160b3e..60aeed49 100644 --- a/aiogram/dispatcher/dispatcher.py +++ b/aiogram/dispatcher/dispatcher.py @@ -222,7 +222,7 @@ class Dispatcher(DataMixin, ContextInstanceMixin): """ await self.bot.get_updates(offset=-1, timeout=1) - async def process_updates(self, updates, fast: typing.Optional[bool] = True): + async def process_updates(self, updates, fast: bool = True): """ Process list of updates @@ -337,7 +337,7 @@ class Dispatcher(DataMixin, ContextInstanceMixin): relax=0.1, limit=None, reset_webhook=None, - fast: typing.Optional[bool] = True, + fast: bool = True, error_sleep: int = 5, allowed_updates: typing.Optional[typing.List[str]] = None): """ @@ -404,7 +404,7 @@ class Dispatcher(DataMixin, ContextInstanceMixin): self._close_waiter.set_result(None) log.warning('Polling is stopped.') - async def _process_polling_updates(self, updates, fast: typing.Optional[bool] = True): + async def _process_polling_updates(self, updates, fast: bool = True): """ Process updates received from long-polling. @@ -949,7 +949,7 @@ class Dispatcher(DataMixin, ContextInstanceMixin): def register_poll_handler(self, callback, *custom_filters, run_task=None, **kwargs): """ Register handler for poll - + Example: .. code-block:: python3 @@ -992,7 +992,7 @@ class Dispatcher(DataMixin, ContextInstanceMixin): def register_poll_answer_handler(self, callback, *custom_filters, run_task=None, **kwargs): """ Register handler for poll_answer - + Example: .. code-block:: python3 From b545a5ff2ed4b6210c4dc1de7d83395b6d3173c5 Mon Sep 17 00:00:00 2001 From: Gabben Date: Thu, 27 Jan 2022 01:25:40 +0400 Subject: [PATCH 18/19] Use hardcoded token as in the other examples (#809) --- examples/separate_api_route_example.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/separate_api_route_example.py b/examples/separate_api_route_example.py index 2f3cc61c..807a3b41 100644 --- a/examples/separate_api_route_example.py +++ b/examples/separate_api_route_example.py @@ -7,7 +7,9 @@ from aiogram.dispatcher.webhook import configure_app from aiohttp import web -bot = Bot(token=config.bot_token) +API_TOKEN = "BOT_TOKEN_HERE" + +bot = Bot(token=API_TOKEN) dp = Dispatcher(bot) From bb7b299b9d0f7c7a4797242b18590aeadc78a631 Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Tue, 1 Feb 2022 02:20:39 +0200 Subject: [PATCH 19/19] Updated to Bot API 5.7 (#824) * Updated to Bot API 5.7 * Updated to Bot API 5.7 Signed-off-by: Alex Root Junior --- README.md | 2 +- README.rst | 2 +- aiogram/__init__.py | 4 ++-- aiogram/bot/api.py | 2 -- aiogram/bot/bot.py | 24 ++++++++++++++++++------ aiogram/types/sticker.py | 1 + aiogram/types/sticker_set.py | 1 + docs/source/index.rst | 2 +- 8 files changed, 25 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 811ad4c9..75736386 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![PyPi status](https://img.shields.io/pypi/status/aiogram.svg?style=flat-square)](https://pypi.python.org/pypi/aiogram) [![Downloads](https://img.shields.io/pypi/dm/aiogram.svg?style=flat-square)](https://pypi.python.org/pypi/aiogram) [![Supported python versions](https://img.shields.io/pypi/pyversions/aiogram.svg?style=flat-square)](https://pypi.python.org/pypi/aiogram) -[![Telegram Bot API](https://img.shields.io/badge/Telegram%20Bot%20API-5.6-blue.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api) +[![Telegram Bot API](https://img.shields.io/badge/Telegram%20Bot%20API-5.7-blue.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api) [![Documentation Status](https://img.shields.io/readthedocs/aiogram?style=flat-square)](http://docs.aiogram.dev/en/latest/?badge=latest) [![Github issues](https://img.shields.io/github/issues/aiogram/aiogram.svg?style=flat-square)](https://github.com/aiogram/aiogram/issues) [![MIT License](https://img.shields.io/pypi/l/aiogram.svg?style=flat-square)](https://opensource.org/licenses/MIT) diff --git a/README.rst b/README.rst index 0ec4b454..47a7cb9d 100644 --- a/README.rst +++ b/README.rst @@ -21,7 +21,7 @@ AIOGramBot :target: https://pypi.python.org/pypi/aiogram :alt: Supported python versions -.. image:: https://img.shields.io/badge/Telegram%20Bot%20API-5.6-blue.svg?style=flat-square&logo=telegram +.. image:: https://img.shields.io/badge/Telegram%20Bot%20API-5.7-blue.svg?style=flat-square&logo=telegram :target: https://core.telegram.org/bots/api :alt: Telegram Bot API diff --git a/aiogram/__init__.py b/aiogram/__init__.py index 3c8f6014..6c8d3f4c 100644 --- a/aiogram/__init__.py +++ b/aiogram/__init__.py @@ -43,5 +43,5 @@ __all__ = ( 'utils', ) -__version__ = '2.18' -__api_version__ = '5.6' +__version__ = '2.19' +__api_version__ = '5.7' diff --git a/aiogram/bot/api.py b/aiogram/bot/api.py index f95e35b1..5f609227 100644 --- a/aiogram/bot/api.py +++ b/aiogram/bot/api.py @@ -188,8 +188,6 @@ def compose_data(params=None, files=None): class Methods(Helper): """ Helper for Telegram API Methods listed on https://core.telegram.org/bots/api - - List is updated to Bot API 5.6 """ mode = HelperMode.lowerCamelCase diff --git a/aiogram/bot/bot.py b/aiogram/bot/bot.py index 596c0a53..91c0b283 100644 --- a/aiogram/bot/bot.py +++ b/aiogram/bot/bot.py @@ -2924,6 +2924,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): emojis: base.String, png_sticker: typing.Union[base.InputFile, base.String] = None, tgs_sticker: base.InputFile = None, + webm_sticker: base.InputFile = None, contains_masks: typing.Optional[base.Boolean] = None, mask_position: typing.Optional[types.MaskPosition] = None) -> base.Boolean: """ @@ -2951,6 +2952,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :param tgs_sticker: TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements :type tgs_sticker: :obj:`base.InputFile` + :param webm_sticker: WEBM video with the sticker, uploaded using multipart/form-data. + See https://core.telegram.org/stickers#video-sticker-requirements for technical requirements + :type webm_sticker: :obj:`base.InputFile` :param emojis: One or more emoji corresponding to the sticker :type emojis: :obj:`base.String` :param contains_masks: Pass True, if a set of mask stickers should be created @@ -2961,11 +2965,12 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :rtype: :obj:`base.Boolean` """ mask_position = prepare_arg(mask_position) - payload = generate_payload(**locals(), exclude=['png_sticker', 'tgs_sticker']) + payload = generate_payload(**locals(), exclude=['png_sticker', 'tgs_sticker', 'webm_sticker']) files = {} prepare_file(payload, files, 'png_sticker', png_sticker) prepare_file(payload, files, 'tgs_sticker', tgs_sticker) + prepare_file(payload, files, 'webm_sticker', webm_sticker) return await self.request(api.Methods.CREATE_NEW_STICKER_SET, payload, files) @@ -2975,6 +2980,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): emojis: base.String, png_sticker: typing.Union[base.InputFile, base.String] = None, tgs_sticker: base.InputFile = None, + webm_sticker: base.InputFile = None, mask_position: typing.Optional[types.MaskPosition] = None) -> base.Boolean: """ Use this method to add a new sticker to a set created by the bot. @@ -2998,6 +3004,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :param tgs_sticker: TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements :type tgs_sticker: :obj:`base.InputFile` + :param webm_sticker: WEBM video with the sticker, uploaded using multipart/form-data. + See https://core.telegram.org/stickers#video-sticker-requirements for technical requirements + :type webm_sticker: :obj:`base.InputFile` :param emojis: One or more emoji corresponding to the sticker :type emojis: :obj:`base.String` :param mask_position: A JSON-serialized object for position where the mask should be placed on faces @@ -3006,11 +3015,12 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :rtype: :obj:`base.Boolean` """ mask_position = prepare_arg(mask_position) - payload = generate_payload(**locals(), exclude=['png_sticker', 'tgs_sticker']) + payload = generate_payload(**locals(), exclude=['png_sticker', 'tgs_sticker', 'webm_sticker']) files = {} prepare_file(payload, files, 'png_sticker', png_sticker) prepare_file(payload, files, 'tgs_sticker', tgs_sticker) + prepare_file(payload, files, 'webm_sticker', webm_sticker) return await self.request(api.Methods.ADD_STICKER_TO_SET, payload, files) @@ -3062,10 +3072,12 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin): :type user_id: :obj:`base.Integer` :param thumb: A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; - see https://core.telegram.org/animated_stickers#technical-requirements for animated sticker technical - requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, - pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using - multipart/form-data. More info on https://core.telegram.org/bots/api#sending-files. + see https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical + requirements, or a WEBM video with the thumbnail up to 32 kilobytes in size; + see https://core.telegram.org/stickers#video-sticker-requirements for video sticker technical requirements. + Pass a file_id as a String to send a file that already exists on the Telegram servers, + pass an HTTP URL as a String for Telegram to get a file from the Internet, + or upload a new one using multipart/form-data. More info on https://core.telegram.org/bots/api#sending-files. Animated sticker set thumbnail can't be uploaded via HTTP URL. :type thumb: :obj:`typing.Union[base.InputFile, base.String]` :return: Returns True on success diff --git a/aiogram/types/sticker.py b/aiogram/types/sticker.py index afaeb31c..20c162e8 100644 --- a/aiogram/types/sticker.py +++ b/aiogram/types/sticker.py @@ -16,6 +16,7 @@ class Sticker(base.TelegramObject, mixins.Downloadable): width: base.Integer = fields.Field() height: base.Integer = fields.Field() is_animated: base.Boolean = fields.Field() + is_video: base.Boolean = fields.Field() thumb: PhotoSize = fields.Field(base=PhotoSize) emoji: base.String = fields.Field() set_name: base.String = fields.Field() diff --git a/aiogram/types/sticker_set.py b/aiogram/types/sticker_set.py index 3b5290c3..dabae5db 100644 --- a/aiogram/types/sticker_set.py +++ b/aiogram/types/sticker_set.py @@ -15,6 +15,7 @@ class StickerSet(base.TelegramObject): name: base.String = fields.Field() title: base.String = fields.Field() is_animated: base.Boolean = fields.Field() + is_video: base.Boolean = fields.Field() contains_masks: base.Boolean = fields.Field() stickers: typing.List[Sticker] = fields.ListField(base=Sticker) thumb: PhotoSize = fields.Field(base=PhotoSize) diff --git a/docs/source/index.rst b/docs/source/index.rst index 98bd08ed..03292fd9 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -22,7 +22,7 @@ Welcome to aiogram's documentation! :target: https://pypi.python.org/pypi/aiogram :alt: Supported python versions - .. image:: https://img.shields.io/badge/Telegram%20Bot%20API-5.6-blue.svg?style=flat-square&logo=telegram + .. image:: https://img.shields.io/badge/Telegram%20Bot%20API-5.7-blue.svg?style=flat-square&logo=telegram :target: https://core.telegram.org/bots/api :alt: Telegram Bot API