From 3d305816576b2ada04e700cb29ee445ae61f814a Mon Sep 17 00:00:00 2001 From: Oleg A Date: Thu, 30 Dec 2021 16:07:09 +0300 Subject: [PATCH 1/8] 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 2/8] 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 3/8] 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 4/8] 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 5/8] 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 6/8] 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 7/8] 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 8/8] 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 = {"<": "<", ">": ">", "&": "&", '"': """}