diff --git a/aiogram/client/bot.py b/aiogram/client/bot.py index d8762dba..843a3779 100644 --- a/aiogram/client/bot.py +++ b/aiogram/client/bot.py @@ -32,18 +32,22 @@ from ..methods import ( BanChatMember, BanChatSenderChat, Close, + CloseForumTopic, CopyMessage, CreateChatInviteLink, + CreateForumTopic, CreateInvoiceLink, CreateNewStickerSet, DeclineChatJoinRequest, DeleteChatPhoto, DeleteChatStickerSet, + DeleteForumTopic, DeleteMessage, DeleteMyCommands, DeleteStickerFromSet, DeleteWebhook, EditChatInviteLink, + EditForumTopic, EditMessageCaption, EditMessageLiveLocation, EditMessageMedia, @@ -59,6 +63,7 @@ from ..methods import ( GetChatMenuButton, GetCustomEmojiStickers, GetFile, + GetForumTopicIconStickers, GetGameHighScores, GetMe, GetMyCommands, @@ -72,6 +77,7 @@ from ..methods import ( LogOut, PinChatMessage, PromoteChatMember, + ReopenForumTopic, RestrictChatMember, RevokeChatInviteLink, SendAnimation, @@ -112,6 +118,7 @@ from ..methods import ( UnbanChatMember, UnbanChatSenderChat, UnpinAllChatMessages, + UnpinAllForumTopicMessages, UnpinChatMessage, UploadStickerFile, ) @@ -132,6 +139,7 @@ from ..types import ( Downloadable, File, ForceReply, + ForumTopic, GameHighScore, InlineKeyboardMarkup, InlineQueryResult, @@ -143,7 +151,9 @@ from ..types import ( InputMediaVideo, LabeledPrice, MaskPosition, - MenuButton, + MenuButtonCommands, + MenuButtonDefault, + MenuButtonWebApp, Message, MessageEntity, MessageId, @@ -548,6 +558,7 @@ class Bot(ContextInstanceMixin["Bot"]): self, chat_id: Union[int, str], text: str, + message_thread_id: Optional[int] = None, parse_mode: Optional[str] = UNSET, entities: Optional[List[MessageEntity]] = None, disable_web_page_preview: Optional[bool] = None, @@ -567,6 +578,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param text: Text of the message to be sent, 1-4096 characters after entities parsing + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param parse_mode: Mode for parsing entities in the message text. See `formatting options `_ for more details. :param entities: A JSON-serialized list of special entities that appear in message text, which can be specified instead of *parse_mode* :param disable_web_page_preview: Disables link previews for links in this message @@ -574,13 +586,14 @@ class Bot(ContextInstanceMixin["Bot"]): :param protect_content: Protects the contents of the sent message from forwarding and saving :param reply_to_message_id: If the message is a reply, ID of the original message :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found - :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. + :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. :param request_timeout: Request timeout :return: On success, the sent Message is returned. """ call = SendMessage( chat_id=chat_id, text=text, + message_thread_id=message_thread_id, parse_mode=parse_mode, entities=entities, disable_web_page_preview=disable_web_page_preview, @@ -597,6 +610,7 @@ class Bot(ContextInstanceMixin["Bot"]): chat_id: Union[int, str], from_chat_id: Union[int, str], message_id: int, + message_thread_id: Optional[int] = None, disable_notification: Optional[bool] = None, protect_content: Optional[bool] = None, request_timeout: Optional[int] = None, @@ -609,6 +623,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param from_chat_id: Unique identifier for the chat where the original message was sent (or channel username in the format :code:`@channelusername`) :param message_id: Message identifier in the chat specified in *from_chat_id* + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param disable_notification: Sends the message `silently `_. Users will receive a notification with no sound. :param protect_content: Protects the contents of the forwarded message from forwarding and saving :param request_timeout: Request timeout @@ -618,6 +633,7 @@ class Bot(ContextInstanceMixin["Bot"]): chat_id=chat_id, from_chat_id=from_chat_id, message_id=message_id, + message_thread_id=message_thread_id, disable_notification=disable_notification, protect_content=protect_content, ) @@ -628,6 +644,7 @@ class Bot(ContextInstanceMixin["Bot"]): chat_id: Union[int, str], from_chat_id: Union[int, str], message_id: int, + message_thread_id: Optional[int] = None, caption: Optional[str] = None, parse_mode: Optional[str] = UNSET, caption_entities: Optional[List[MessageEntity]] = None, @@ -648,6 +665,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param from_chat_id: Unique identifier for the chat where the original message was sent (or channel username in the format :code:`@channelusername`) :param message_id: Message identifier in the chat specified in *from_chat_id* + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param caption: New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept :param parse_mode: Mode for parsing entities in the new caption. See `formatting options `_ for more details. :param caption_entities: A JSON-serialized list of special entities that appear in the new caption, which can be specified instead of *parse_mode* @@ -655,7 +673,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param protect_content: Protects the contents of the sent message from forwarding and saving :param reply_to_message_id: If the message is a reply, ID of the original message :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found - :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. + :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. :param request_timeout: Request timeout :return: Returns the MessageId of the sent message on success. """ @@ -663,6 +681,7 @@ class Bot(ContextInstanceMixin["Bot"]): chat_id=chat_id, from_chat_id=from_chat_id, message_id=message_id, + message_thread_id=message_thread_id, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities, @@ -678,6 +697,7 @@ class Bot(ContextInstanceMixin["Bot"]): self, chat_id: Union[int, str], photo: Union[InputFile, str], + message_thread_id: Optional[int] = None, caption: Optional[str] = None, parse_mode: Optional[str] = UNSET, caption_entities: Optional[List[MessageEntity]] = None, @@ -697,6 +717,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param photo: Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. :ref:`More information on Sending Files » ` + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param caption: Photo caption (may also be used when resending photos by *file_id*), 0-1024 characters after entities parsing :param parse_mode: Mode for parsing entities in the photo caption. See `formatting options `_ for more details. :param caption_entities: A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode* @@ -704,13 +725,14 @@ class Bot(ContextInstanceMixin["Bot"]): :param protect_content: Protects the contents of the sent message from forwarding and saving :param reply_to_message_id: If the message is a reply, ID of the original message :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found - :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. + :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. :param request_timeout: Request timeout :return: On success, the sent Message is returned. """ call = SendPhoto( chat_id=chat_id, photo=photo, + message_thread_id=message_thread_id, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities, @@ -726,6 +748,7 @@ class Bot(ContextInstanceMixin["Bot"]): self, chat_id: Union[int, str], audio: Union[InputFile, str], + message_thread_id: Optional[int] = None, caption: Optional[str] = None, parse_mode: Optional[str] = UNSET, caption_entities: Optional[List[MessageEntity]] = None, @@ -750,6 +773,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param audio: Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. :ref:`More information on Sending Files » ` + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param caption: Audio caption, 0-1024 characters after entities parsing :param parse_mode: Mode for parsing entities in the audio caption. See `formatting options `_ for more details. :param caption_entities: A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode* @@ -761,13 +785,14 @@ class Bot(ContextInstanceMixin["Bot"]): :param protect_content: Protects the contents of the sent message from forwarding and saving :param reply_to_message_id: If the message is a reply, ID of the original message :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found - :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. + :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. :param request_timeout: Request timeout :return: On success, the sent Message is returned. """ call = SendAudio( chat_id=chat_id, audio=audio, + message_thread_id=message_thread_id, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities, @@ -787,6 +812,7 @@ class Bot(ContextInstanceMixin["Bot"]): self, chat_id: Union[int, str], document: Union[InputFile, str], + message_thread_id: Optional[int] = None, thumb: Optional[Union[InputFile, str]] = None, caption: Optional[str] = None, parse_mode: Optional[str] = UNSET, @@ -808,6 +834,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param document: File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. :ref:`More information on Sending Files » ` + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param thumb: Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under . :ref:`More information on Sending Files » ` :param caption: Document caption (may also be used when resending documents by *file_id*), 0-1024 characters after entities parsing :param parse_mode: Mode for parsing entities in the document caption. See `formatting options `_ for more details. @@ -817,13 +844,14 @@ class Bot(ContextInstanceMixin["Bot"]): :param protect_content: Protects the contents of the sent message from forwarding and saving :param reply_to_message_id: If the message is a reply, ID of the original message :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found - :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. + :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. :param request_timeout: Request timeout :return: On success, the sent Message is returned. """ call = SendDocument( chat_id=chat_id, document=document, + message_thread_id=message_thread_id, thumb=thumb, caption=caption, parse_mode=parse_mode, @@ -841,6 +869,7 @@ class Bot(ContextInstanceMixin["Bot"]): self, chat_id: Union[int, str], video: Union[InputFile, str], + message_thread_id: Optional[int] = None, duration: Optional[int] = None, width: Optional[int] = None, height: Optional[int] = None, @@ -865,6 +894,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param video: Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. :ref:`More information on Sending Files » ` + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param duration: Duration of sent video in seconds :param width: Video width :param height: Video height @@ -877,13 +907,14 @@ class Bot(ContextInstanceMixin["Bot"]): :param protect_content: Protects the contents of the sent message from forwarding and saving :param reply_to_message_id: If the message is a reply, ID of the original message :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found - :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. + :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. :param request_timeout: Request timeout :return: On success, the sent Message is returned. """ call = SendVideo( chat_id=chat_id, video=video, + message_thread_id=message_thread_id, duration=duration, width=width, height=height, @@ -904,6 +935,7 @@ class Bot(ContextInstanceMixin["Bot"]): self, chat_id: Union[int, str], animation: Union[InputFile, str], + message_thread_id: Optional[int] = None, duration: Optional[int] = None, width: Optional[int] = None, height: Optional[int] = None, @@ -927,6 +959,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param animation: Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data. :ref:`More information on Sending Files » ` + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param duration: Duration of sent animation in seconds :param width: Animation width :param height: Animation height @@ -938,13 +971,14 @@ class Bot(ContextInstanceMixin["Bot"]): :param protect_content: Protects the contents of the sent message from forwarding and saving :param reply_to_message_id: If the message is a reply, ID of the original message :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found - :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. + :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. :param request_timeout: Request timeout :return: On success, the sent Message is returned. """ call = SendAnimation( chat_id=chat_id, animation=animation, + message_thread_id=message_thread_id, duration=duration, width=width, height=height, @@ -964,6 +998,7 @@ class Bot(ContextInstanceMixin["Bot"]): self, chat_id: Union[int, str], voice: Union[InputFile, str], + message_thread_id: Optional[int] = None, caption: Optional[str] = None, parse_mode: Optional[str] = UNSET, caption_entities: Optional[List[MessageEntity]] = None, @@ -984,6 +1019,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param voice: Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. :ref:`More information on Sending Files » ` + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param caption: Voice message caption, 0-1024 characters after entities parsing :param parse_mode: Mode for parsing entities in the voice message caption. See `formatting options `_ for more details. :param caption_entities: A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode* @@ -992,13 +1028,14 @@ class Bot(ContextInstanceMixin["Bot"]): :param protect_content: Protects the contents of the sent message from forwarding and saving :param reply_to_message_id: If the message is a reply, ID of the original message :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found - :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. + :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. :param request_timeout: Request timeout :return: On success, the sent Message is returned. """ call = SendVoice( chat_id=chat_id, voice=voice, + message_thread_id=message_thread_id, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities, @@ -1015,6 +1052,7 @@ class Bot(ContextInstanceMixin["Bot"]): self, chat_id: Union[int, str], video_note: Union[InputFile, str], + message_thread_id: Optional[int] = None, duration: Optional[int] = None, length: Optional[int] = None, thumb: Optional[Union[InputFile, str]] = None, @@ -1034,6 +1072,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param video_note: Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. :ref:`More information on Sending Files » `. Sending video notes by a URL is currently unsupported + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param duration: Duration of sent video in seconds :param length: Video width and height, i.e. diameter of the video message :param thumb: Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under . :ref:`More information on Sending Files » ` @@ -1041,13 +1080,14 @@ class Bot(ContextInstanceMixin["Bot"]): :param protect_content: Protects the contents of the sent message from forwarding and saving :param reply_to_message_id: If the message is a reply, ID of the original message :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found - :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. + :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. :param request_timeout: Request timeout :return: On success, the sent Message is returned. """ call = SendVideoNote( chat_id=chat_id, video_note=video_note, + message_thread_id=message_thread_id, duration=duration, length=length, thumb=thumb, @@ -1063,6 +1103,7 @@ class Bot(ContextInstanceMixin["Bot"]): self, chat_id: Union[int, str], media: List[Union[InputMediaAudio, InputMediaDocument, InputMediaPhoto, InputMediaVideo]], + message_thread_id: Optional[int] = None, disable_notification: Optional[bool] = None, protect_content: Optional[bool] = None, reply_to_message_id: Optional[int] = None, @@ -1076,6 +1117,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param media: A JSON-serialized array describing messages to be sent, must include 2-10 items + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param disable_notification: Sends messages `silently `_. Users will receive a notification with no sound. :param protect_content: Protects the contents of the sent messages from forwarding and saving :param reply_to_message_id: If the messages are a reply, ID of the original message @@ -1086,6 +1128,7 @@ class Bot(ContextInstanceMixin["Bot"]): call = SendMediaGroup( chat_id=chat_id, media=media, + message_thread_id=message_thread_id, disable_notification=disable_notification, protect_content=protect_content, reply_to_message_id=reply_to_message_id, @@ -1098,6 +1141,7 @@ class Bot(ContextInstanceMixin["Bot"]): chat_id: Union[int, str], latitude: float, longitude: float, + message_thread_id: Optional[int] = None, horizontal_accuracy: Optional[float] = None, live_period: Optional[int] = None, heading: Optional[int] = None, @@ -1119,6 +1163,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param latitude: Latitude of the location :param longitude: Longitude of the location + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param horizontal_accuracy: The radius of uncertainty for the location, measured in meters; 0-1500 :param live_period: Period in seconds for which the location will be updated (see `Live Locations `_, should be between 60 and 86400. :param heading: For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. @@ -1127,7 +1172,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param protect_content: Protects the contents of the sent message from forwarding and saving :param reply_to_message_id: If the message is a reply, ID of the original message :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found - :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. + :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. :param request_timeout: Request timeout :return: On success, the sent Message is returned. """ @@ -1135,6 +1180,7 @@ class Bot(ContextInstanceMixin["Bot"]): chat_id=chat_id, latitude=latitude, longitude=longitude, + message_thread_id=message_thread_id, horizontal_accuracy=horizontal_accuracy, live_period=live_period, heading=heading, @@ -1173,7 +1219,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param horizontal_accuracy: The radius of uncertainty for the location, measured in meters; 0-1500 :param heading: Direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. :param proximity_alert_radius: The maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified. - :param reply_markup: A JSON-serialized object for a new `inline keyboard `_. + :param reply_markup: A JSON-serialized object for a new `inline keyboard `_. :param request_timeout: Request timeout :return: On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. @@ -1207,7 +1253,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Required if *inline_message_id* is not specified. Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param message_id: Required if *inline_message_id* is not specified. Identifier of the message with live location to stop :param inline_message_id: Required if *chat_id* and *message_id* are not specified. Identifier of the inline message - :param reply_markup: A JSON-serialized object for a new `inline keyboard `_. + :param reply_markup: A JSON-serialized object for a new `inline keyboard `_. :param request_timeout: Request timeout :return: On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned. @@ -1227,6 +1273,7 @@ class Bot(ContextInstanceMixin["Bot"]): longitude: float, title: str, address: str, + message_thread_id: Optional[int] = None, foursquare_id: Optional[str] = None, foursquare_type: Optional[str] = None, google_place_id: Optional[str] = None, @@ -1250,6 +1297,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param longitude: Longitude of the venue :param title: Name of the venue :param address: Address of the venue + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param foursquare_id: Foursquare identifier of the venue :param foursquare_type: Foursquare type of the venue, if known. (For example, 'arts_entertainment/default', 'arts_entertainment/aquarium' or 'food/icecream'.) :param google_place_id: Google Places identifier of the venue @@ -1258,7 +1306,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param protect_content: Protects the contents of the sent message from forwarding and saving :param reply_to_message_id: If the message is a reply, ID of the original message :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found - :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. + :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. :param request_timeout: Request timeout :return: On success, the sent Message is returned. """ @@ -1268,6 +1316,7 @@ class Bot(ContextInstanceMixin["Bot"]): longitude=longitude, title=title, address=address, + message_thread_id=message_thread_id, foursquare_id=foursquare_id, foursquare_type=foursquare_type, google_place_id=google_place_id, @@ -1285,6 +1334,7 @@ class Bot(ContextInstanceMixin["Bot"]): chat_id: Union[int, str], phone_number: str, first_name: str, + message_thread_id: Optional[int] = None, last_name: Optional[str] = None, vcard: Optional[str] = None, disable_notification: Optional[bool] = None, @@ -1304,13 +1354,14 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param phone_number: Contact's phone number :param first_name: Contact's first name + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param last_name: Contact's last name :param vcard: Additional data about the contact in the form of a `vCard `_, 0-2048 bytes :param disable_notification: Sends the message `silently `_. Users will receive a notification with no sound. :param protect_content: Protects the contents of the sent message from forwarding and saving :param reply_to_message_id: If the message is a reply, ID of the original message :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found - :param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard `_, `custom reply keyboard `_, instructions to remove keyboard or to force a reply from the user. + :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. :param request_timeout: Request timeout :return: On success, the sent Message is returned. """ @@ -1318,6 +1369,7 @@ class Bot(ContextInstanceMixin["Bot"]): chat_id=chat_id, phone_number=phone_number, first_name=first_name, + message_thread_id=message_thread_id, last_name=last_name, vcard=vcard, disable_notification=disable_notification, @@ -1333,6 +1385,7 @@ class Bot(ContextInstanceMixin["Bot"]): chat_id: Union[int, str], question: str, options: List[str], + message_thread_id: Optional[int] = None, is_anonymous: Optional[bool] = None, type: Optional[str] = None, allows_multiple_answers: Optional[bool] = None, @@ -1360,6 +1413,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param question: Poll question, 1-300 characters :param options: A JSON-serialized list of answer options, 2-10 strings 1-100 characters each + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param is_anonymous: :code:`True`, if the poll needs to be anonymous, defaults to :code:`True` :param type: Poll type, 'quiz' or 'regular', defaults to 'regular' :param allows_multiple_answers: :code:`True`, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to :code:`False` @@ -1374,7 +1428,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param protect_content: Protects the contents of the sent message from forwarding and saving :param reply_to_message_id: If the message is a reply, ID of the original message :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found - :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. + :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. :param request_timeout: Request timeout :return: On success, the sent Message is returned. """ @@ -1382,6 +1436,7 @@ class Bot(ContextInstanceMixin["Bot"]): chat_id=chat_id, question=question, options=options, + message_thread_id=message_thread_id, is_anonymous=is_anonymous, type=type, allows_multiple_answers=allows_multiple_answers, @@ -1403,6 +1458,7 @@ class Bot(ContextInstanceMixin["Bot"]): async def send_dice( self, chat_id: Union[int, str], + message_thread_id: Optional[int] = None, emoji: Optional[str] = None, disable_notification: Optional[bool] = None, protect_content: Optional[bool] = None, @@ -1419,17 +1475,19 @@ class Bot(ContextInstanceMixin["Bot"]): Source: https://core.telegram.org/bots/api#senddice :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param emoji: Emoji on which the dice throw animation is based. Currently, must be one of '🎲', '🎯', '🏀', '⚽', '🎳', or '🎰'. Dice can have values 1-6 for '🎲', '🎯' and '🎳', values 1-5 for '🏀' and '⚽', and values 1-64 for '🎰'. Defaults to '🎲' :param disable_notification: Sends the message `silently `_. Users will receive a notification with no sound. :param protect_content: Protects the contents of the sent message from forwarding :param reply_to_message_id: If the message is a reply, ID of the original message :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found - :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. + :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. :param request_timeout: Request timeout :return: On success, the sent Message is returned. """ call = SendDice( chat_id=chat_id, + message_thread_id=message_thread_id, emoji=emoji, disable_notification=disable_notification, protect_content=protect_content, @@ -1641,6 +1699,7 @@ class Bot(ContextInstanceMixin["Bot"]): can_change_info: Optional[bool] = None, can_invite_users: Optional[bool] = None, can_pin_messages: Optional[bool] = None, + can_manage_topics: Optional[bool] = None, request_timeout: Optional[int] = None, ) -> bool: """ @@ -1661,6 +1720,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param can_change_info: Pass :code:`True` if the administrator can change chat title, photo and other settings :param can_invite_users: Pass :code:`True` if the administrator can invite new users to the chat :param can_pin_messages: Pass :code:`True` if the administrator can pin messages, supergroups only + :param can_manage_topics: Pass :code:`True` if the user is allowed to create, rename, close, and reopen forum topics, supergroups only :param request_timeout: Request timeout :return: Returns True on success. """ @@ -1678,6 +1738,7 @@ class Bot(ContextInstanceMixin["Bot"]): can_change_info=can_change_info, can_invite_users=can_invite_users, can_pin_messages=can_pin_messages, + can_manage_topics=can_manage_topics, ) return await self(call, request_timeout=request_timeout) @@ -1977,7 +2038,7 @@ class Bot(ContextInstanceMixin["Bot"]): Source: https://core.telegram.org/bots/api#setchattitle :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) - :param title: New chat title, 1-255 characters + :param title: New chat title, 1-128 characters :param request_timeout: Request timeout :return: Returns True on success. """ @@ -2255,6 +2316,165 @@ class Bot(ContextInstanceMixin["Bot"]): ) return await self(call, request_timeout=request_timeout) + async def get_forum_topic_icon_stickers( + self, + request_timeout: Optional[int] = None, + ) -> List[Sticker]: + """ + Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires no parameters. Returns an Array of :class:`aiogram.types.sticker.Sticker` objects. + + Source: https://core.telegram.org/bots/api#getforumtopiciconstickers + + :param request_timeout: Request timeout + :return: Returns an Array of Sticker objects. + """ + call = GetForumTopicIconStickers() + return await self(call, request_timeout=request_timeout) + + async def create_forum_topic( + self, + chat_id: Union[int, str], + name: str, + icon_color: Optional[int] = None, + icon_custom_emoji_id: Optional[str] = None, + request_timeout: Optional[int] = None, + ) -> ForumTopic: + """ + Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the *can_manage_topics* administrator rights. Returns information about the created topic as a :class:`aiogram.types.forum_topic.ForumTopic` object. + + Source: https://core.telegram.org/bots/api#createforumtopic + + :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`) + :param name: Topic name, 1-128 characters + :param icon_color: Color of the topic icon in RGB format. Currently, must be one of 0x6FB9F0, 0xFFD67E, 0xCB86DB, 0x8EEE98, 0xFF93B2, or 0xFB6F5F + :param icon_custom_emoji_id: Unique identifier of the custom emoji shown as the topic icon. Use :class:`aiogram.methods.get_forum_topic_icon_stickers.GetForumTopicIconStickers` to get all allowed custom emoji identifiers. + :param request_timeout: Request timeout + :return: Returns information about the created topic as a ForumTopic object. + """ + call = CreateForumTopic( + chat_id=chat_id, + name=name, + icon_color=icon_color, + icon_custom_emoji_id=icon_custom_emoji_id, + ) + return await self(call, request_timeout=request_timeout) + + async def edit_forum_topic( + self, + chat_id: Union[int, str], + message_thread_id: int, + name: str, + icon_custom_emoji_id: str, + request_timeout: Optional[int] = None, + ) -> bool: + """ + Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have *can_manage_topics* administrator rights, unless it is the creator of the topic. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#editforumtopic + + :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`) + :param message_thread_id: Unique identifier for the target message thread of the forum topic + :param name: New topic name, 1-128 characters + :param icon_custom_emoji_id: New unique identifier of the custom emoji shown as the topic icon. Use :class:`aiogram.methods.get_forum_topic_icon_stickers.GetForumTopicIconStickers` to get all allowed custom emoji identifiers + :param request_timeout: Request timeout + :return: Returns True on success. + """ + call = EditForumTopic( + chat_id=chat_id, + message_thread_id=message_thread_id, + name=name, + icon_custom_emoji_id=icon_custom_emoji_id, + ) + return await self(call, request_timeout=request_timeout) + + async def close_forum_topic( + self, + chat_id: Union[int, str], + message_thread_id: int, + request_timeout: Optional[int] = None, + ) -> bool: + """ + Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the *can_manage_topics* administrator rights, unless it is the creator of the topic. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#closeforumtopic + + :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`) + :param message_thread_id: Unique identifier for the target message thread of the forum topic + :param request_timeout: Request timeout + :return: Returns True on success. + """ + call = CloseForumTopic( + chat_id=chat_id, + message_thread_id=message_thread_id, + ) + return await self(call, request_timeout=request_timeout) + + async def reopen_forum_topic( + self, + chat_id: Union[int, str], + message_thread_id: int, + request_timeout: Optional[int] = None, + ) -> bool: + """ + Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the *can_manage_topics* administrator rights, unless it is the creator of the topic. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#reopenforumtopic + + :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`) + :param message_thread_id: Unique identifier for the target message thread of the forum topic + :param request_timeout: Request timeout + :return: Returns True on success. + """ + call = ReopenForumTopic( + chat_id=chat_id, + message_thread_id=message_thread_id, + ) + return await self(call, request_timeout=request_timeout) + + async def delete_forum_topic( + self, + chat_id: Union[int, str], + message_thread_id: int, + request_timeout: Optional[int] = None, + ) -> bool: + """ + Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the *can_delete_messages* administrator rights. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#deleteforumtopic + + :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`) + :param message_thread_id: Unique identifier for the target message thread of the forum topic + :param request_timeout: Request timeout + :return: Returns True on success. + """ + call = DeleteForumTopic( + chat_id=chat_id, + message_thread_id=message_thread_id, + ) + return await self(call, request_timeout=request_timeout) + + async def unpin_all_forum_topic_messages( + self, + chat_id: Union[int, str], + message_thread_id: int, + request_timeout: Optional[int] = None, + ) -> bool: + """ + Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the *can_pin_messages* administrator right in the supergroup. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#unpinallforumtopicmessages + + :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`) + :param message_thread_id: Unique identifier for the target message thread of the forum topic + :param request_timeout: Request timeout + :return: Returns True on success. + """ + call = UnpinAllForumTopicMessages( + chat_id=chat_id, + message_thread_id=message_thread_id, + ) + return await self(call, request_timeout=request_timeout) + async def answer_callback_query( self, callback_query_id: str, @@ -2265,7 +2485,7 @@ class Bot(ContextInstanceMixin["Bot"]): request_timeout: Optional[int] = None, ) -> bool: """ - Use this method to send answers to callback queries sent from `inline keyboards `_. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, :code:`True` is returned. + Use this method to send answers to callback queries sent from `inline keyboards `_. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, :code:`True` is returned. Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via `@BotFather `_ and accept the terms. Otherwise, you may use links like :code:`t.me/your_bot?start=XXXX` that open your bot with a parameter. @@ -2296,7 +2516,7 @@ class Bot(ContextInstanceMixin["Bot"]): request_timeout: Optional[int] = None, ) -> bool: """ - Use this method to change the list of the bot's commands. See `https://core.telegram.org/bots#commands `_`https://core.telegram.org/bots#commands `_ for more details about bot commands. Returns :code:`True` on success. + Use this method to change the list of the bot's commands. See `this manual `_ for more details about bot commands. Returns :code:`True` on success. Source: https://core.telegram.org/bots/api#setmycommands @@ -2361,7 +2581,9 @@ class Bot(ContextInstanceMixin["Bot"]): async def set_chat_menu_button( self, chat_id: Optional[int] = None, - menu_button: Optional[MenuButton] = None, + menu_button: Optional[ + Union[MenuButtonDefault, MenuButtonWebApp, MenuButtonCommands] + ] = None, request_timeout: Optional[int] = None, ) -> bool: """ @@ -2384,7 +2606,7 @@ class Bot(ContextInstanceMixin["Bot"]): self, chat_id: Optional[int] = None, request_timeout: Optional[int] = None, - ) -> MenuButton: + ) -> Union[MenuButtonDefault, MenuButtonWebApp, MenuButtonCommands]: """ Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns :class:`aiogram.types.menu_button.MenuButton` on success. @@ -2469,7 +2691,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param parse_mode: Mode for parsing entities in the message text. See `formatting options `_ for more details. :param entities: A JSON-serialized list of special entities that appear in message text, which can be specified instead of *parse_mode* :param disable_web_page_preview: Disables link previews for links in this message - :param reply_markup: A JSON-serialized object for an `inline keyboard `_. + :param reply_markup: A JSON-serialized object for an `inline keyboard `_. :param request_timeout: Request timeout :return: On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. @@ -2508,7 +2730,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param caption: New caption of the message, 0-1024 characters after entities parsing :param parse_mode: Mode for parsing entities in the message caption. See `formatting options `_ for more details. :param caption_entities: A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode* - :param reply_markup: A JSON-serialized object for an `inline keyboard `_. + :param reply_markup: A JSON-serialized object for an `inline keyboard `_. :param request_timeout: Request timeout :return: On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. @@ -2542,7 +2764,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Required if *inline_message_id* is not specified. Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param message_id: Required if *inline_message_id* is not specified. Identifier of the message to edit :param inline_message_id: Required if *chat_id* and *message_id* are not specified. Identifier of the inline message - :param reply_markup: A JSON-serialized object for a new `inline keyboard `_. + :param reply_markup: A JSON-serialized object for a new `inline keyboard `_. :param request_timeout: Request timeout :return: On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. @@ -2572,7 +2794,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Required if *inline_message_id* is not specified. Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param message_id: Required if *inline_message_id* is not specified. Identifier of the message to edit :param inline_message_id: Required if *chat_id* and *message_id* are not specified. Identifier of the inline message - :param reply_markup: A JSON-serialized object for an `inline keyboard `_. + :param reply_markup: A JSON-serialized object for an `inline keyboard `_. :param request_timeout: Request timeout :return: On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. @@ -2599,7 +2821,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param message_id: Identifier of the original message with the poll - :param reply_markup: A JSON-serialized object for a new message `inline keyboard `_. + :param reply_markup: A JSON-serialized object for a new message `inline keyboard `_. :param request_timeout: Request timeout :return: On success, the stopped Poll is returned. """ @@ -2621,6 +2843,8 @@ class Bot(ContextInstanceMixin["Bot"]): - A message can only be deleted if it was sent less than 48 hours ago. + - Service messages about a supergroup, channel, or forum topic creation can't be deleted. + - A dice message in a private chat can only be deleted if it was sent more than 24 hours ago. - Bots can delete outgoing messages in private chats, groups, and supergroups. @@ -2657,6 +2881,7 @@ class Bot(ContextInstanceMixin["Bot"]): self, chat_id: Union[int, str], sticker: Union[InputFile, str], + message_thread_id: Optional[int] = None, disable_notification: Optional[bool] = None, protect_content: Optional[bool] = None, reply_to_message_id: Optional[int] = None, @@ -2673,17 +2898,19 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param sticker: Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP file from the Internet, or upload a new one using multipart/form-data. :ref:`More information on Sending Files » ` + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param disable_notification: Sends the message `silently `_. Users will receive a notification with no sound. :param protect_content: Protects the contents of the sent message from forwarding and saving :param reply_to_message_id: If the message is a reply, ID of the original message :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found - :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. + :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. :param request_timeout: Request timeout :return: On success, the sent Message is returned. """ call = SendSticker( chat_id=chat_id, sticker=sticker, + message_thread_id=message_thread_id, disable_notification=disable_notification, protect_content=protect_content, reply_to_message_id=reply_to_message_id, @@ -2927,7 +3154,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param is_personal: Pass :code:`True` if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query :param next_offset: Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes. :param switch_pm_text: If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter *switch_pm_parameter* - :param switch_pm_parameter: `Deep-linking `_ parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only :code:`A-Z`, :code:`a-z`, :code:`0-9`, :code:`_` and :code:`-` are allowed. + :param switch_pm_parameter: `Deep-linking `_ parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only :code:`A-Z`, :code:`a-z`, :code:`0-9`, :code:`_` and :code:`-` are allowed. :param request_timeout: Request timeout :return: On success, True is returned. """ @@ -2978,6 +3205,7 @@ class Bot(ContextInstanceMixin["Bot"]): provider_token: str, currency: str, prices: List[LabeledPrice], + message_thread_id: Optional[int] = None, max_tip_amount: Optional[int] = None, suggested_tip_amounts: Optional[List[int]] = None, start_parameter: Optional[str] = None, @@ -3012,6 +3240,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param provider_token: Payment provider token, obtained via `@BotFather `_ :param currency: Three-letter ISO 4217 currency code, see `more on currencies `_ :param prices: Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param max_tip_amount: The maximum accepted amount for tips in the *smallest units* of the currency (integer, **not** float/double). For example, for a maximum tip of :code:`US$ 1.45` pass :code:`max_tip_amount = 145`. See the *exp* parameter in `currencies.json `_, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0 :param suggested_tip_amounts: A JSON-serialized array of suggested amounts of tips in the *smallest units* of the currency (integer, **not** float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed *max_tip_amount*. :param start_parameter: Unique deep-linking parameter. If left empty, **forwarded copies** of the sent message will have a *Pay* button, allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded copies of the sent message will have a *URL* button with a deep link to the bot (instead of a *Pay* button), with the value used as the start parameter @@ -3031,7 +3260,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param protect_content: Protects the contents of the sent message from forwarding and saving :param reply_to_message_id: If the message is a reply, ID of the original message :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found - :param reply_markup: A JSON-serialized object for an `inline keyboard `_. If empty, one 'Pay :code:`total price`' button will be shown. If not empty, the first button must be a Pay button. + :param reply_markup: A JSON-serialized object for an `inline keyboard `_. If empty, one 'Pay :code:`total price`' button will be shown. If not empty, the first button must be a Pay button. :param request_timeout: Request timeout :return: On success, the sent Message is returned. """ @@ -3043,6 +3272,7 @@ class Bot(ContextInstanceMixin["Bot"]): provider_token=provider_token, currency=currency, prices=prices, + message_thread_id=message_thread_id, max_tip_amount=max_tip_amount, suggested_tip_amounts=suggested_tip_amounts, start_parameter=start_parameter, @@ -3234,6 +3464,7 @@ class Bot(ContextInstanceMixin["Bot"]): self, chat_id: int, game_short_name: str, + message_thread_id: Optional[int] = None, disable_notification: Optional[bool] = None, protect_content: Optional[bool] = None, reply_to_message_id: Optional[int] = None, @@ -3248,17 +3479,19 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Unique identifier for the target chat :param game_short_name: Short name of the game, serves as the unique identifier for the game. Set up your games via `@BotFather `_. + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param disable_notification: Sends the message `silently `_. Users will receive a notification with no sound. :param protect_content: Protects the contents of the sent message from forwarding and saving :param reply_to_message_id: If the message is a reply, ID of the original message :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found - :param reply_markup: A JSON-serialized object for an `inline keyboard `_. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game. + :param reply_markup: A JSON-serialized object for an `inline keyboard `_. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game. :param request_timeout: Request timeout :return: On success, the sent Message is returned. """ call = SendGame( chat_id=chat_id, game_short_name=game_short_name, + message_thread_id=message_thread_id, disable_notification=disable_notification, protect_content=protect_content, reply_to_message_id=reply_to_message_id, diff --git a/aiogram/client/session/middlewares/retry_after.py b/aiogram/client/session/middlewares/retry_after.py new file mode 100644 index 00000000..1a3fe2ce --- /dev/null +++ b/aiogram/client/session/middlewares/retry_after.py @@ -0,0 +1,48 @@ +import asyncio +import time + +from aiogram import Bot +from aiogram.client.session.middlewares.base import ( + BaseRequestMiddleware, + NextRequestMiddlewareType, +) +from aiogram.exceptions import TelegramNetworkError, TelegramRetryAfter +from aiogram.methods import GetUpdates, TelegramMethod +from aiogram.methods.base import Response, TelegramType + + +class RetryAfterMiddleware(BaseRequestMiddleware): + def __init__(self, max_retry_timeout: float = 10): + self.max_retry_timeout = max_retry_timeout + + async def __call__( + self, + make_request: NextRequestMiddlewareType[TelegramType], + bot: "Bot", + method: TelegramMethod[TelegramType], + ) -> Response[TelegramType]: + if isinstance(method, GetUpdates): + # Get updates retried in polling process + return await make_request(bot, method) + + start = time.monotonic() + + while True: + try: + result = await make_request(bot, method) + except TelegramRetryAfter as e: + error = e + sleep_interval = e.retry_after + except TelegramNetworkError as e: + error = e + sleep_interval = 1 + else: + break + + request_time = time.monotonic() + sleep_interval + if request_time - start < 0: + raise error + + await asyncio.sleep(sleep_interval) + + return result diff --git a/aiogram/methods/__init__.py b/aiogram/methods/__init__.py index c62577b9..e5aac860 100644 --- a/aiogram/methods/__init__.py +++ b/aiogram/methods/__init__.py @@ -9,18 +9,22 @@ from .ban_chat_member import BanChatMember from .ban_chat_sender_chat import BanChatSenderChat from .base import Request, Response, TelegramMethod from .close import Close +from .close_forum_topic import CloseForumTopic from .copy_message import CopyMessage from .create_chat_invite_link import CreateChatInviteLink +from .create_forum_topic import CreateForumTopic from .create_invoice_link import CreateInvoiceLink from .create_new_sticker_set import CreateNewStickerSet from .decline_chat_join_request import DeclineChatJoinRequest from .delete_chat_photo import DeleteChatPhoto from .delete_chat_sticker_set import DeleteChatStickerSet +from .delete_forum_topic import DeleteForumTopic from .delete_message import DeleteMessage from .delete_my_commands import DeleteMyCommands from .delete_sticker_from_set import DeleteStickerFromSet from .delete_webhook import DeleteWebhook from .edit_chat_invite_link import EditChatInviteLink +from .edit_forum_topic import EditForumTopic from .edit_message_caption import EditMessageCaption from .edit_message_live_location import EditMessageLiveLocation from .edit_message_media import EditMessageMedia @@ -36,6 +40,7 @@ from .get_chat_members_count import GetChatMembersCount from .get_chat_menu_button import GetChatMenuButton from .get_custom_emoji_stickers import GetCustomEmojiStickers from .get_file import GetFile +from .get_forum_topic_icon_stickers import GetForumTopicIconStickers from .get_game_high_scores import GetGameHighScores from .get_me import GetMe from .get_my_commands import GetMyCommands @@ -49,6 +54,7 @@ from .leave_chat import LeaveChat from .log_out import LogOut from .pin_chat_message import PinChatMessage from .promote_chat_member import PromoteChatMember +from .reopen_forum_topic import ReopenForumTopic from .restrict_chat_member import RestrictChatMember from .revoke_chat_invite_link import RevokeChatInviteLink from .send_animation import SendAnimation @@ -88,6 +94,7 @@ from .stop_poll import StopPoll from .unban_chat_member import UnbanChatMember from .unban_chat_sender_chat import UnbanChatSenderChat from .unpin_all_chat_messages import UnpinAllChatMessages +from .unpin_all_forum_topic_messages import UnpinAllForumTopicMessages from .unpin_chat_message import UnpinChatMessage from .upload_sticker_file import UploadStickerFile @@ -153,6 +160,13 @@ __all__ = ( "GetChatMember", "SetChatStickerSet", "DeleteChatStickerSet", + "GetForumTopicIconStickers", + "CreateForumTopic", + "EditForumTopic", + "CloseForumTopic", + "ReopenForumTopic", + "DeleteForumTopic", + "UnpinAllForumTopicMessages", "AnswerCallbackQuery", "SetMyCommands", "DeleteMyCommands", diff --git a/aiogram/methods/answer_callback_query.py b/aiogram/methods/answer_callback_query.py index 3059fc1c..8d932f51 100644 --- a/aiogram/methods/answer_callback_query.py +++ b/aiogram/methods/answer_callback_query.py @@ -10,7 +10,7 @@ if TYPE_CHECKING: class AnswerCallbackQuery(TelegramMethod[bool]): """ - Use this method to send answers to callback queries sent from `inline keyboards `_. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, :code:`True` is returned. + Use this method to send answers to callback queries sent from `inline keyboards `_. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, :code:`True` is returned. Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via `@BotFather `_ and accept the terms. Otherwise, you may use links like :code:`t.me/your_bot?start=XXXX` that open your bot with a parameter. diff --git a/aiogram/methods/answer_inline_query.py b/aiogram/methods/answer_inline_query.py index 39446226..56422180 100644 --- a/aiogram/methods/answer_inline_query.py +++ b/aiogram/methods/answer_inline_query.py @@ -33,7 +33,7 @@ class AnswerInlineQuery(TelegramMethod[bool]): switch_pm_text: Optional[str] = None """If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter *switch_pm_parameter*""" switch_pm_parameter: Optional[str] = None - """`Deep-linking `_ parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only :code:`A-Z`, :code:`a-z`, :code:`0-9`, :code:`_` and :code:`-` are allowed.""" + """`Deep-linking `_ parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only :code:`A-Z`, :code:`a-z`, :code:`0-9`, :code:`_` and :code:`-` are allowed.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/close_forum_topic.py b/aiogram/methods/close_forum_topic.py new file mode 100644 index 00000000..da9eedec --- /dev/null +++ b/aiogram/methods/close_forum_topic.py @@ -0,0 +1,28 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Any, Dict, Union + +from .base import Request, TelegramMethod + +if TYPE_CHECKING: + from ..client.bot import Bot + + +class CloseForumTopic(TelegramMethod[bool]): + """ + Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the *can_manage_topics* administrator rights, unless it is the creator of the topic. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#closeforumtopic + """ + + __returning__ = bool + + chat_id: Union[int, str] + """Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)""" + message_thread_id: int + """Unique identifier for the target message thread of the forum topic""" + + def build_request(self, bot: Bot) -> Request: + data: Dict[str, Any] = self.dict() + + return Request(method="closeForumTopic", data=data) diff --git a/aiogram/methods/copy_message.py b/aiogram/methods/copy_message.py index 0b602d1e..fc30b8fe 100644 --- a/aiogram/methods/copy_message.py +++ b/aiogram/methods/copy_message.py @@ -32,6 +32,8 @@ class CopyMessage(TelegramMethod[MessageId]): """Unique identifier for the chat where the original message was sent (or channel username in the format :code:`@channelusername`)""" message_id: int """Message identifier in the chat specified in *from_chat_id*""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" caption: Optional[str] = None """New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept""" parse_mode: Optional[str] = UNSET @@ -49,7 +51,7 @@ class CopyMessage(TelegramMethod[MessageId]): reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] ] = None - """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.""" + """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.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/create_forum_topic.py b/aiogram/methods/create_forum_topic.py new file mode 100644 index 00000000..13111873 --- /dev/null +++ b/aiogram/methods/create_forum_topic.py @@ -0,0 +1,33 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Any, Dict, Optional, Union + +from ..types import ForumTopic +from .base import Request, TelegramMethod + +if TYPE_CHECKING: + from ..client.bot import Bot + + +class CreateForumTopic(TelegramMethod[ForumTopic]): + """ + Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the *can_manage_topics* administrator rights. Returns information about the created topic as a :class:`aiogram.types.forum_topic.ForumTopic` object. + + Source: https://core.telegram.org/bots/api#createforumtopic + """ + + __returning__ = ForumTopic + + chat_id: Union[int, str] + """Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)""" + name: str + """Topic name, 1-128 characters""" + icon_color: Optional[int] = None + """Color of the topic icon in RGB format. Currently, must be one of 0x6FB9F0, 0xFFD67E, 0xCB86DB, 0x8EEE98, 0xFF93B2, or 0xFB6F5F""" + icon_custom_emoji_id: Optional[str] = None + """Unique identifier of the custom emoji shown as the topic icon. Use :class:`aiogram.methods.get_forum_topic_icon_stickers.GetForumTopicIconStickers` to get all allowed custom emoji identifiers.""" + + def build_request(self, bot: Bot) -> Request: + data: Dict[str, Any] = self.dict() + + return Request(method="createForumTopic", data=data) diff --git a/aiogram/methods/delete_forum_topic.py b/aiogram/methods/delete_forum_topic.py new file mode 100644 index 00000000..acbe8858 --- /dev/null +++ b/aiogram/methods/delete_forum_topic.py @@ -0,0 +1,28 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Any, Dict, Union + +from .base import Request, TelegramMethod + +if TYPE_CHECKING: + from ..client.bot import Bot + + +class DeleteForumTopic(TelegramMethod[bool]): + """ + Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the *can_delete_messages* administrator rights. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#deleteforumtopic + """ + + __returning__ = bool + + chat_id: Union[int, str] + """Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)""" + message_thread_id: int + """Unique identifier for the target message thread of the forum topic""" + + def build_request(self, bot: Bot) -> Request: + data: Dict[str, Any] = self.dict() + + return Request(method="deleteForumTopic", data=data) diff --git a/aiogram/methods/delete_message.py b/aiogram/methods/delete_message.py index 2e01cca4..09279969 100644 --- a/aiogram/methods/delete_message.py +++ b/aiogram/methods/delete_message.py @@ -14,6 +14,8 @@ class DeleteMessage(TelegramMethod[bool]): - A message can only be deleted if it was sent less than 48 hours ago. + - Service messages about a supergroup, channel, or forum topic creation can't be deleted. + - A dice message in a private chat can only be deleted if it was sent more than 24 hours ago. - Bots can delete outgoing messages in private chats, groups, and supergroups. diff --git a/aiogram/methods/edit_forum_topic.py b/aiogram/methods/edit_forum_topic.py new file mode 100644 index 00000000..c10bb6fd --- /dev/null +++ b/aiogram/methods/edit_forum_topic.py @@ -0,0 +1,32 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Any, Dict, Union + +from .base import Request, TelegramMethod + +if TYPE_CHECKING: + from ..client.bot import Bot + + +class EditForumTopic(TelegramMethod[bool]): + """ + Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have *can_manage_topics* administrator rights, unless it is the creator of the topic. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#editforumtopic + """ + + __returning__ = bool + + chat_id: Union[int, str] + """Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)""" + message_thread_id: int + """Unique identifier for the target message thread of the forum topic""" + name: str + """New topic name, 1-128 characters""" + icon_custom_emoji_id: str + """New unique identifier of the custom emoji shown as the topic icon. Use :class:`aiogram.methods.get_forum_topic_icon_stickers.GetForumTopicIconStickers` to get all allowed custom emoji identifiers""" + + def build_request(self, bot: Bot) -> Request: + data: Dict[str, Any] = self.dict() + + return Request(method="editForumTopic", data=data) diff --git a/aiogram/methods/edit_message_caption.py b/aiogram/methods/edit_message_caption.py index 40e4459b..8360ccf5 100644 --- a/aiogram/methods/edit_message_caption.py +++ b/aiogram/methods/edit_message_caption.py @@ -31,7 +31,7 @@ class EditMessageCaption(TelegramMethod[Union[Message, bool]]): caption_entities: Optional[List[MessageEntity]] = None """A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*""" reply_markup: Optional[InlineKeyboardMarkup] = None - """A JSON-serialized object for an `inline keyboard `_.""" + """A JSON-serialized object for an `inline keyboard `_.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/edit_message_live_location.py b/aiogram/methods/edit_message_live_location.py index 52e6acfa..35a72912 100644 --- a/aiogram/methods/edit_message_live_location.py +++ b/aiogram/methods/edit_message_live_location.py @@ -35,7 +35,7 @@ class EditMessageLiveLocation(TelegramMethod[Union[Message, bool]]): proximity_alert_radius: Optional[int] = None """The maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.""" reply_markup: Optional[InlineKeyboardMarkup] = None - """A JSON-serialized object for a new `inline keyboard `_.""" + """A JSON-serialized object for a new `inline keyboard `_.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/edit_message_media.py b/aiogram/methods/edit_message_media.py index 10882e81..b2434105 100644 --- a/aiogram/methods/edit_message_media.py +++ b/aiogram/methods/edit_message_media.py @@ -27,7 +27,7 @@ class EditMessageMedia(TelegramMethod[Union[Message, bool]]): inline_message_id: Optional[str] = None """Required if *chat_id* and *message_id* are not specified. Identifier of the inline message""" reply_markup: Optional[InlineKeyboardMarkup] = None - """A JSON-serialized object for a new `inline keyboard `_.""" + """A JSON-serialized object for a new `inline keyboard `_.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/edit_message_reply_markup.py b/aiogram/methods/edit_message_reply_markup.py index 0304012c..4b871d58 100644 --- a/aiogram/methods/edit_message_reply_markup.py +++ b/aiogram/methods/edit_message_reply_markup.py @@ -25,7 +25,7 @@ class EditMessageReplyMarkup(TelegramMethod[Union[Message, bool]]): inline_message_id: Optional[str] = None """Required if *chat_id* and *message_id* are not specified. Identifier of the inline message""" reply_markup: Optional[InlineKeyboardMarkup] = None - """A JSON-serialized object for an `inline keyboard `_.""" + """A JSON-serialized object for an `inline keyboard `_.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/edit_message_text.py b/aiogram/methods/edit_message_text.py index 92184b90..f47ef15a 100644 --- a/aiogram/methods/edit_message_text.py +++ b/aiogram/methods/edit_message_text.py @@ -33,7 +33,7 @@ class EditMessageText(TelegramMethod[Union[Message, bool]]): disable_web_page_preview: Optional[bool] = None """Disables link previews for links in this message""" reply_markup: Optional[InlineKeyboardMarkup] = None - """A JSON-serialized object for an `inline keyboard `_.""" + """A JSON-serialized object for an `inline keyboard `_.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/forward_message.py b/aiogram/methods/forward_message.py index ec4e7623..c75aac76 100644 --- a/aiogram/methods/forward_message.py +++ b/aiogram/methods/forward_message.py @@ -24,6 +24,8 @@ class ForwardMessage(TelegramMethod[Message]): """Unique identifier for the chat where the original message was sent (or channel username in the format :code:`@channelusername`)""" message_id: int """Message identifier in the chat specified in *from_chat_id*""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" disable_notification: Optional[bool] = None """Sends the message `silently `_. Users will receive a notification with no sound.""" protect_content: Optional[bool] = None diff --git a/aiogram/methods/get_chat_menu_button.py b/aiogram/methods/get_chat_menu_button.py index e2a97134..bdf07c38 100644 --- a/aiogram/methods/get_chat_menu_button.py +++ b/aiogram/methods/get_chat_menu_button.py @@ -2,14 +2,16 @@ from __future__ import annotations from typing import TYPE_CHECKING, Any, Dict, Optional, Union -from ..types import MenuButton, MenuButtonCommands, MenuButtonDefault, MenuButtonWebApp +from ..types import MenuButtonCommands, MenuButtonDefault, MenuButtonWebApp from .base import Request, TelegramMethod if TYPE_CHECKING: from ..client.bot import Bot -class GetChatMenuButton(TelegramMethod[MenuButton]): +class GetChatMenuButton( + TelegramMethod[Union[MenuButtonDefault, MenuButtonWebApp, MenuButtonCommands]] +): """ Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns :class:`aiogram.types.menu_button.MenuButton` on success. diff --git a/aiogram/methods/get_forum_topic_icon_stickers.py b/aiogram/methods/get_forum_topic_icon_stickers.py new file mode 100644 index 00000000..f00a8caa --- /dev/null +++ b/aiogram/methods/get_forum_topic_icon_stickers.py @@ -0,0 +1,24 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Any, Dict, List + +from ..types import Sticker +from .base import Request, TelegramMethod + +if TYPE_CHECKING: + from ..client.bot import Bot + + +class GetForumTopicIconStickers(TelegramMethod[List[Sticker]]): + """ + Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires no parameters. Returns an Array of :class:`aiogram.types.sticker.Sticker` objects. + + Source: https://core.telegram.org/bots/api#getforumtopiciconstickers + """ + + __returning__ = List[Sticker] + + def build_request(self, bot: Bot) -> Request: + data: Dict[str, Any] = self.dict() + + return Request(method="getForumTopicIconStickers", data=data) diff --git a/aiogram/methods/promote_chat_member.py b/aiogram/methods/promote_chat_member.py index 042e0afa..3ae62cf0 100644 --- a/aiogram/methods/promote_chat_member.py +++ b/aiogram/methods/promote_chat_member.py @@ -43,6 +43,8 @@ class PromoteChatMember(TelegramMethod[bool]): """Pass :code:`True` if the administrator can invite new users to the chat""" can_pin_messages: Optional[bool] = None """Pass :code:`True` if the administrator can pin messages, supergroups only""" + can_manage_topics: Optional[bool] = None + """Pass :code:`True` if the user is allowed to create, rename, close, and reopen forum topics, supergroups only""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/reopen_forum_topic.py b/aiogram/methods/reopen_forum_topic.py new file mode 100644 index 00000000..1efa2366 --- /dev/null +++ b/aiogram/methods/reopen_forum_topic.py @@ -0,0 +1,28 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Any, Dict, Union + +from .base import Request, TelegramMethod + +if TYPE_CHECKING: + from ..client.bot import Bot + + +class ReopenForumTopic(TelegramMethod[bool]): + """ + Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the *can_manage_topics* administrator rights, unless it is the creator of the topic. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#reopenforumtopic + """ + + __returning__ = bool + + chat_id: Union[int, str] + """Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)""" + message_thread_id: int + """Unique identifier for the target message thread of the forum topic""" + + def build_request(self, bot: Bot) -> Request: + data: Dict[str, Any] = self.dict() + + return Request(method="reopenForumTopic", data=data) diff --git a/aiogram/methods/send_animation.py b/aiogram/methods/send_animation.py index 6c59bf27..18533414 100644 --- a/aiogram/methods/send_animation.py +++ b/aiogram/methods/send_animation.py @@ -31,6 +31,8 @@ class SendAnimation(TelegramMethod[Message]): """Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)""" animation: Union[InputFile, str] """Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data. :ref:`More information on Sending Files » `""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" duration: Optional[int] = None """Duration of sent animation in seconds""" width: Optional[int] = None @@ -56,7 +58,7 @@ class SendAnimation(TelegramMethod[Message]): reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] ] = None - """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.""" + """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.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict(exclude={"animation", "thumb"}) diff --git a/aiogram/methods/send_audio.py b/aiogram/methods/send_audio.py index 2a687ac2..1786f751 100644 --- a/aiogram/methods/send_audio.py +++ b/aiogram/methods/send_audio.py @@ -32,6 +32,8 @@ class SendAudio(TelegramMethod[Message]): """Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)""" audio: Union[InputFile, str] """Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. :ref:`More information on Sending Files » `""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" caption: Optional[str] = None """Audio caption, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = UNSET @@ -57,7 +59,7 @@ class SendAudio(TelegramMethod[Message]): reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] ] = None - """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.""" + """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.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict(exclude={"audio", "thumb"}) diff --git a/aiogram/methods/send_contact.py b/aiogram/methods/send_contact.py index fafe8177..41e1110b 100644 --- a/aiogram/methods/send_contact.py +++ b/aiogram/methods/send_contact.py @@ -30,6 +30,8 @@ class SendContact(TelegramMethod[Message]): """Contact's phone number""" first_name: str """Contact's first name""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" last_name: Optional[str] = None """Contact's last name""" vcard: Optional[str] = None @@ -45,7 +47,7 @@ class SendContact(TelegramMethod[Message]): reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] ] = None - """Additional interface options. A JSON-serialized object for an `inline keyboard `_, `custom reply keyboard `_, instructions to remove keyboard or to force a reply from the user.""" + """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.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/send_dice.py b/aiogram/methods/send_dice.py index e6ed3004..d898a742 100644 --- a/aiogram/methods/send_dice.py +++ b/aiogram/methods/send_dice.py @@ -26,6 +26,8 @@ class SendDice(TelegramMethod[Message]): chat_id: Union[int, str] """Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" emoji: Optional[str] = None """Emoji on which the dice throw animation is based. Currently, must be one of '🎲', '🎯', '🏀', '⚽', '🎳', or '🎰'. Dice can have values 1-6 for '🎲', '🎯' and '🎳', values 1-5 for '🏀' and '⚽', and values 1-64 for '🎰'. Defaults to '🎲'""" disable_notification: Optional[bool] = None @@ -39,7 +41,7 @@ class SendDice(TelegramMethod[Message]): reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] ] = None - """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.""" + """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.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/send_document.py b/aiogram/methods/send_document.py index b8ced8b1..6f99e756 100644 --- a/aiogram/methods/send_document.py +++ b/aiogram/methods/send_document.py @@ -31,6 +31,8 @@ class SendDocument(TelegramMethod[Message]): """Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)""" document: Union[InputFile, str] """File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. :ref:`More information on Sending Files » `""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" thumb: Optional[Union[InputFile, str]] = None """Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under . :ref:`More information on Sending Files » `""" caption: Optional[str] = None @@ -52,7 +54,7 @@ class SendDocument(TelegramMethod[Message]): reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] ] = None - """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.""" + """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.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict(exclude={"document", "thumb"}) diff --git a/aiogram/methods/send_game.py b/aiogram/methods/send_game.py index 9f538e67..f6301562 100644 --- a/aiogram/methods/send_game.py +++ b/aiogram/methods/send_game.py @@ -22,6 +22,8 @@ class SendGame(TelegramMethod[Message]): """Unique identifier for the target chat""" game_short_name: str """Short name of the game, serves as the unique identifier for the game. Set up your games via `@BotFather `_.""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" disable_notification: Optional[bool] = None """Sends the message `silently `_. Users will receive a notification with no sound.""" protect_content: Optional[bool] = None @@ -31,7 +33,7 @@ class SendGame(TelegramMethod[Message]): allow_sending_without_reply: Optional[bool] = None """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found""" reply_markup: Optional[InlineKeyboardMarkup] = None - """A JSON-serialized object for an `inline keyboard `_. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game.""" + """A JSON-serialized object for an `inline keyboard `_. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/send_invoice.py b/aiogram/methods/send_invoice.py index d5b113a9..9f085fbd 100644 --- a/aiogram/methods/send_invoice.py +++ b/aiogram/methods/send_invoice.py @@ -32,6 +32,8 @@ class SendInvoice(TelegramMethod[Message]): """Three-letter ISO 4217 currency code, see `more on currencies `_""" prices: List[LabeledPrice] """Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" max_tip_amount: Optional[int] = None """The maximum accepted amount for tips in the *smallest units* of the currency (integer, **not** float/double). For example, for a maximum tip of :code:`US$ 1.45` pass :code:`max_tip_amount = 145`. See the *exp* parameter in `currencies.json `_, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0""" suggested_tip_amounts: Optional[List[int]] = None @@ -71,7 +73,7 @@ class SendInvoice(TelegramMethod[Message]): allow_sending_without_reply: Optional[bool] = None """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found""" reply_markup: Optional[InlineKeyboardMarkup] = None - """A JSON-serialized object for an `inline keyboard `_. If empty, one 'Pay :code:`total price`' button will be shown. If not empty, the first button must be a Pay button.""" + """A JSON-serialized object for an `inline keyboard `_. If empty, one 'Pay :code:`total price`' button will be shown. If not empty, the first button must be a Pay button.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/send_location.py b/aiogram/methods/send_location.py index 114f9020..350157b8 100644 --- a/aiogram/methods/send_location.py +++ b/aiogram/methods/send_location.py @@ -30,6 +30,8 @@ class SendLocation(TelegramMethod[Message]): """Latitude of the location""" longitude: float """Longitude of the location""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" horizontal_accuracy: Optional[float] = None """The radius of uncertainty for the location, measured in meters; 0-1500""" live_period: Optional[int] = None @@ -49,7 +51,7 @@ class SendLocation(TelegramMethod[Message]): reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] ] = None - """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.""" + """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.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/send_media_group.py b/aiogram/methods/send_media_group.py index 316a25d4..7d97a665 100644 --- a/aiogram/methods/send_media_group.py +++ b/aiogram/methods/send_media_group.py @@ -29,6 +29,8 @@ class SendMediaGroup(TelegramMethod[List[Message]]): """Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)""" media: List[Union[InputMediaAudio, InputMediaDocument, InputMediaPhoto, InputMediaVideo]] """A JSON-serialized array describing messages to be sent, must include 2-10 items""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" disable_notification: Optional[bool] = None """Sends messages `silently `_. Users will receive a notification with no sound.""" protect_content: Optional[bool] = None diff --git a/aiogram/methods/send_message.py b/aiogram/methods/send_message.py index 95d1d48e..a3c83bad 100644 --- a/aiogram/methods/send_message.py +++ b/aiogram/methods/send_message.py @@ -30,6 +30,8 @@ class SendMessage(TelegramMethod[Message]): """Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)""" text: str """Text of the message to be sent, 1-4096 characters after entities parsing""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" parse_mode: Optional[str] = UNSET """Mode for parsing entities in the message text. See `formatting options `_ for more details.""" entities: Optional[List[MessageEntity]] = None @@ -47,7 +49,7 @@ class SendMessage(TelegramMethod[Message]): reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] ] = None - """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.""" + """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.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/send_photo.py b/aiogram/methods/send_photo.py index 6c50c8c6..0534c841 100644 --- a/aiogram/methods/send_photo.py +++ b/aiogram/methods/send_photo.py @@ -31,6 +31,8 @@ class SendPhoto(TelegramMethod[Message]): """Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)""" photo: Union[InputFile, str] """Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. :ref:`More information on Sending Files » `""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" caption: Optional[str] = None """Photo caption (may also be used when resending photos by *file_id*), 0-1024 characters after entities parsing""" parse_mode: Optional[str] = UNSET @@ -48,7 +50,7 @@ class SendPhoto(TelegramMethod[Message]): reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] ] = None - """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.""" + """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.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict(exclude={"photo"}) diff --git a/aiogram/methods/send_poll.py b/aiogram/methods/send_poll.py index 30ae17b3..be67fcda 100644 --- a/aiogram/methods/send_poll.py +++ b/aiogram/methods/send_poll.py @@ -33,6 +33,8 @@ class SendPoll(TelegramMethod[Message]): """Poll question, 1-300 characters""" options: List[str] """A JSON-serialized list of answer options, 2-10 strings 1-100 characters each""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" is_anonymous: Optional[bool] = None """:code:`True`, if the poll needs to be anonymous, defaults to :code:`True`""" type: Optional[str] = None @@ -64,7 +66,7 @@ class SendPoll(TelegramMethod[Message]): reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] ] = None - """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.""" + """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.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/send_sticker.py b/aiogram/methods/send_sticker.py index 7cb1bc96..81ab698d 100644 --- a/aiogram/methods/send_sticker.py +++ b/aiogram/methods/send_sticker.py @@ -29,6 +29,8 @@ class SendSticker(TelegramMethod[Message]): """Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)""" sticker: Union[InputFile, str] """Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP file from the Internet, or upload a new one using multipart/form-data. :ref:`More information on Sending Files » `""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" disable_notification: Optional[bool] = None """Sends the message `silently `_. Users will receive a notification with no sound.""" protect_content: Optional[bool] = None @@ -40,7 +42,7 @@ class SendSticker(TelegramMethod[Message]): reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] ] = None - """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.""" + """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.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict(exclude={"sticker"}) diff --git a/aiogram/methods/send_venue.py b/aiogram/methods/send_venue.py index 9b0a06e8..b9f3c464 100644 --- a/aiogram/methods/send_venue.py +++ b/aiogram/methods/send_venue.py @@ -34,6 +34,8 @@ class SendVenue(TelegramMethod[Message]): """Name of the venue""" address: str """Address of the venue""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" foursquare_id: Optional[str] = None """Foursquare identifier of the venue""" foursquare_type: Optional[str] = None @@ -53,7 +55,7 @@ class SendVenue(TelegramMethod[Message]): reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] ] = None - """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.""" + """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.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/send_video.py b/aiogram/methods/send_video.py index 02496abe..d30f5fed 100644 --- a/aiogram/methods/send_video.py +++ b/aiogram/methods/send_video.py @@ -31,6 +31,8 @@ class SendVideo(TelegramMethod[Message]): """Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)""" video: Union[InputFile, str] """Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. :ref:`More information on Sending Files » `""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" duration: Optional[int] = None """Duration of sent video in seconds""" width: Optional[int] = None @@ -58,7 +60,7 @@ class SendVideo(TelegramMethod[Message]): reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] ] = None - """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.""" + """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.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict(exclude={"video", "thumb"}) diff --git a/aiogram/methods/send_video_note.py b/aiogram/methods/send_video_note.py index e20960cf..19776e62 100644 --- a/aiogram/methods/send_video_note.py +++ b/aiogram/methods/send_video_note.py @@ -29,6 +29,8 @@ class SendVideoNote(TelegramMethod[Message]): """Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)""" video_note: Union[InputFile, str] """Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. :ref:`More information on Sending Files » `. Sending video notes by a URL is currently unsupported""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" duration: Optional[int] = None """Duration of sent video in seconds""" length: Optional[int] = None @@ -46,7 +48,7 @@ class SendVideoNote(TelegramMethod[Message]): reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] ] = None - """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.""" + """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.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict(exclude={"video_note", "thumb"}) diff --git a/aiogram/methods/send_voice.py b/aiogram/methods/send_voice.py index 0cc1d602..e9bc9a37 100644 --- a/aiogram/methods/send_voice.py +++ b/aiogram/methods/send_voice.py @@ -31,6 +31,8 @@ class SendVoice(TelegramMethod[Message]): """Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)""" voice: Union[InputFile, str] """Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. :ref:`More information on Sending Files » `""" + message_thread_id: Optional[int] = None + """Unique identifier for the target message thread (topic) of the forum; for forum supergroups only""" caption: Optional[str] = None """Voice message caption, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = UNSET @@ -50,7 +52,7 @@ class SendVoice(TelegramMethod[Message]): reply_markup: Optional[ Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] ] = None - """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.""" + """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.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict(exclude={"voice"}) diff --git a/aiogram/methods/set_chat_menu_button.py b/aiogram/methods/set_chat_menu_button.py index 25301431..9a7caaf1 100644 --- a/aiogram/methods/set_chat_menu_button.py +++ b/aiogram/methods/set_chat_menu_button.py @@ -1,8 +1,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Dict, Optional +from typing import TYPE_CHECKING, Any, Dict, Optional, Union -from ..types import MenuButton +from ..types import MenuButtonCommands, MenuButtonDefault, MenuButtonWebApp from .base import Request, TelegramMethod if TYPE_CHECKING: @@ -20,7 +20,7 @@ class SetChatMenuButton(TelegramMethod[bool]): chat_id: Optional[int] = None """Unique identifier for the target private chat. If not specified, default bot's menu button will be changed""" - menu_button: Optional[MenuButton] = None + menu_button: Optional[Union[MenuButtonDefault, MenuButtonWebApp, MenuButtonCommands]] = None """A JSON-serialized object for the bot's new menu button. Defaults to :class:`aiogram.types.menu_button_default.MenuButtonDefault`""" def build_request(self, bot: Bot) -> Request: diff --git a/aiogram/methods/set_chat_title.py b/aiogram/methods/set_chat_title.py index c4793233..edad33cc 100644 --- a/aiogram/methods/set_chat_title.py +++ b/aiogram/methods/set_chat_title.py @@ -20,7 +20,7 @@ class SetChatTitle(TelegramMethod[bool]): chat_id: Union[int, str] """Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)""" title: str - """New chat title, 1-255 characters""" + """New chat title, 1-128 characters""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/set_my_commands.py b/aiogram/methods/set_my_commands.py index 3dcebbb3..98e47aff 100644 --- a/aiogram/methods/set_my_commands.py +++ b/aiogram/methods/set_my_commands.py @@ -11,7 +11,7 @@ if TYPE_CHECKING: class SetMyCommands(TelegramMethod[bool]): """ - Use this method to change the list of the bot's commands. See `https://core.telegram.org/bots#commands `_`https://core.telegram.org/bots#commands `_ for more details about bot commands. Returns :code:`True` on success. + Use this method to change the list of the bot's commands. See `this manual `_ for more details about bot commands. Returns :code:`True` on success. Source: https://core.telegram.org/bots/api#setmycommands """ diff --git a/aiogram/methods/stop_message_live_location.py b/aiogram/methods/stop_message_live_location.py index 7b2ddca4..50297930 100644 --- a/aiogram/methods/stop_message_live_location.py +++ b/aiogram/methods/stop_message_live_location.py @@ -25,7 +25,7 @@ class StopMessageLiveLocation(TelegramMethod[Union[Message, bool]]): inline_message_id: Optional[str] = None """Required if *chat_id* and *message_id* are not specified. Identifier of the inline message""" reply_markup: Optional[InlineKeyboardMarkup] = None - """A JSON-serialized object for a new `inline keyboard `_.""" + """A JSON-serialized object for a new `inline keyboard `_.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/stop_poll.py b/aiogram/methods/stop_poll.py index fa90766a..92662285 100644 --- a/aiogram/methods/stop_poll.py +++ b/aiogram/methods/stop_poll.py @@ -23,7 +23,7 @@ class StopPoll(TelegramMethod[Poll]): message_id: int """Identifier of the original message with the poll""" reply_markup: Optional[InlineKeyboardMarkup] = None - """A JSON-serialized object for a new message `inline keyboard `_.""" + """A JSON-serialized object for a new message `inline keyboard `_.""" def build_request(self, bot: Bot) -> Request: data: Dict[str, Any] = self.dict() diff --git a/aiogram/methods/unpin_all_forum_topic_messages.py b/aiogram/methods/unpin_all_forum_topic_messages.py new file mode 100644 index 00000000..6a94c218 --- /dev/null +++ b/aiogram/methods/unpin_all_forum_topic_messages.py @@ -0,0 +1,28 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Any, Dict, Union + +from .base import Request, TelegramMethod + +if TYPE_CHECKING: + from ..client.bot import Bot + + +class UnpinAllForumTopicMessages(TelegramMethod[bool]): + """ + Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the *can_pin_messages* administrator right in the supergroup. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#unpinallforumtopicmessages + """ + + __returning__ = bool + + chat_id: Union[int, str] + """Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)""" + message_thread_id: int + """Unique identifier for the target message thread of the forum topic""" + + def build_request(self, bot: Bot) -> Request: + data: Dict[str, Any] = self.dict() + + return Request(method="unpinAllForumTopicMessages", data=data) diff --git a/aiogram/types/__init__.py b/aiogram/types/__init__.py index 739882cf..8c262c74 100644 --- a/aiogram/types/__init__.py +++ b/aiogram/types/__init__.py @@ -39,6 +39,10 @@ from .encrypted_credentials import EncryptedCredentials from .encrypted_passport_element import EncryptedPassportElement from .file import File from .force_reply import ForceReply +from .forum_topic import ForumTopic +from .forum_topic_closed import ForumTopicClosed +from .forum_topic_created import ForumTopicCreated +from .forum_topic_reopened import ForumTopicReopened from .game import Game from .game_high_score import GameHighScore from .inline_keyboard_button import InlineKeyboardButton @@ -169,6 +173,9 @@ __all__ = ( "WebAppData", "ProximityAlertTriggered", "MessageAutoDeleteTimerChanged", + "ForumTopicCreated", + "ForumTopicClosed", + "ForumTopicReopened", "VideoChatScheduled", "VideoChatStarted", "VideoChatEnded", @@ -199,6 +206,7 @@ __all__ = ( "ChatJoinRequest", "ChatPermissions", "ChatLocation", + "ForumTopic", "BotCommand", "BotCommandScope", "BotCommandScopeDefault", diff --git a/aiogram/types/callback_query.py b/aiogram/types/callback_query.py index f9929bca..4f96c8a3 100644 --- a/aiogram/types/callback_query.py +++ b/aiogram/types/callback_query.py @@ -14,7 +14,7 @@ if TYPE_CHECKING: class CallbackQuery(TelegramObject): """ - This object represents an incoming callback query from a callback button in an `inline keyboard `_. If the button that originated the query was attached to a message sent by the bot, the field *message* will be present. If the button was attached to a message sent via the bot (in `inline mode `_), the field *inline_message_id* will be present. Exactly one of the fields *data* or *game_short_name* will be present. + This object represents an incoming callback query from a callback button in an `inline keyboard `_. If the button that originated the query was attached to a message sent by the bot, the field *message* will be present. If the button was attached to a message sent via the bot (in `inline mode `_), the field *inline_message_id* will be present. Exactly one of the fields *data* or *game_short_name* will be present. **NOTE:** After the user presses a callback button, Telegram clients will display a progress bar until you call :class:`aiogram.methods.answer_callback_query.AnswerCallbackQuery`. It is, therefore, necessary to react by calling :class:`aiogram.methods.answer_callback_query.AnswerCallbackQuery` even if no notification to the user is needed (e.g., without specifying any of the optional parameters). diff --git a/aiogram/types/chat.py b/aiogram/types/chat.py index 875ef36c..7e276c25 100644 --- a/aiogram/types/chat.py +++ b/aiogram/types/chat.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING, List, Optional from .base import TelegramObject @@ -31,8 +31,14 @@ class Chat(TelegramObject): """*Optional*. First name of the other party in a private chat""" last_name: Optional[str] = None """*Optional*. Last name of the other party in a private chat""" + is_forum: Optional[bool] = None + """*Optional*. :code:`True`, if the supergroup chat is a forum (has `topics `_ enabled)""" photo: Optional[ChatPhoto] = None """*Optional*. Chat photo. Returned only in :class:`aiogram.methods.get_chat.GetChat`.""" + active_usernames: Optional[List[str]] = None + """*Optional*. If non-empty, the list of all `active chat usernames `_; for private chats, supergroups and channels. Returned only in :class:`aiogram.methods.get_chat.GetChat`.""" + emoji_status_custom_emoji_id: Optional[str] = None + """*Optional*. Custom emoji identifier of emoji status of the other party in a private chat. Returned only in :class:`aiogram.methods.get_chat.GetChat`.""" bio: Optional[str] = None """*Optional*. Bio of the other party in a private chat. Returned only in :class:`aiogram.methods.get_chat.GetChat`.""" has_private_forwards: Optional[bool] = None diff --git a/aiogram/types/chat_administrator_rights.py b/aiogram/types/chat_administrator_rights.py index 20f4b65c..eb38b693 100644 --- a/aiogram/types/chat_administrator_rights.py +++ b/aiogram/types/chat_administrator_rights.py @@ -37,3 +37,5 @@ class ChatAdministratorRights(TelegramObject): """*Optional*. :code:`True`, if the administrator can edit messages of other users and can pin messages; channels only""" can_pin_messages: Optional[bool] = None """*Optional*. :code:`True`, if the user is allowed to pin messages; groups and supergroups only""" + can_manage_topics: Optional[bool] = None + """*Optional*. :code:`True`, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only""" diff --git a/aiogram/types/chat_member.py b/aiogram/types/chat_member.py index d430e0ce..5d306177 100644 --- a/aiogram/types/chat_member.py +++ b/aiogram/types/chat_member.py @@ -53,6 +53,8 @@ class ChatMember(TelegramObject): """*Optional*. :code:`True`, if the administrator can edit messages of other users and can pin messages; channels only""" can_pin_messages: Optional[bool] = None """*Optional*. :code:`True`, if the user is allowed to pin messages; groups and supergroups only""" + can_manage_topics: Optional[bool] = None + """*Optional*. :code:`True`, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only""" is_member: Optional[bool] = None """*Optional*. :code:`True`, if the user is a member of the chat at the moment of the request""" can_send_messages: Optional[bool] = None diff --git a/aiogram/types/chat_member_administrator.py b/aiogram/types/chat_member_administrator.py index 896033d2..1c9a8aae 100644 --- a/aiogram/types/chat_member_administrator.py +++ b/aiogram/types/chat_member_administrator.py @@ -45,5 +45,7 @@ class ChatMemberAdministrator(ChatMember): """*Optional*. :code:`True`, if the administrator can edit messages of other users and can pin messages; channels only""" can_pin_messages: Optional[bool] = None """*Optional*. :code:`True`, if the user is allowed to pin messages; groups and supergroups only""" + can_manage_topics: Optional[bool] = None + """*Optional*. :code:`True`, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only""" custom_title: Optional[str] = None """*Optional*. Custom title for this user""" diff --git a/aiogram/types/chat_member_restricted.py b/aiogram/types/chat_member_restricted.py index 7e244024..6cff8f53 100644 --- a/aiogram/types/chat_member_restricted.py +++ b/aiogram/types/chat_member_restricted.py @@ -30,6 +30,8 @@ class ChatMemberRestricted(ChatMember): """:code:`True`, if the user is allowed to invite new users to the chat""" can_pin_messages: bool """:code:`True`, if the user is allowed to pin messages""" + can_manage_topics: bool + """:code:`True`, if the user is allowed to create forum topics""" can_send_messages: bool """:code:`True`, if the user is allowed to send text messages, contacts, locations and venues""" can_send_media_messages: bool diff --git a/aiogram/types/chat_permissions.py b/aiogram/types/chat_permissions.py index 15ddaba4..0263ada2 100644 --- a/aiogram/types/chat_permissions.py +++ b/aiogram/types/chat_permissions.py @@ -28,3 +28,5 @@ class ChatPermissions(MutableTelegramObject): """*Optional*. :code:`True`, if the user is allowed to invite new users to the chat""" can_pin_messages: Optional[bool] = None """*Optional*. :code:`True`, if the user is allowed to pin messages. Ignored in public supergroups""" + can_manage_topics: Optional[bool] = None + """*Optional*. :code:`True`, if the user is allowed to create forum topics. If omitted defaults to the value of can_pin_messages""" diff --git a/aiogram/types/force_reply.py b/aiogram/types/force_reply.py index 55f1b6c9..c27af31e 100644 --- a/aiogram/types/force_reply.py +++ b/aiogram/types/force_reply.py @@ -9,7 +9,7 @@ from .base import MutableTelegramObject class ForceReply(MutableTelegramObject): """ - Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot's message and tapped 'Reply'). This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice `privacy mode `_. + Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot's message and tapped 'Reply'). This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice `privacy mode `_. **Example:** A `poll bot `_ for groups runs in privacy mode (only receives commands, replies to its messages and mentions). There could be two ways to create a new poll: diff --git a/aiogram/types/forum_topic.py b/aiogram/types/forum_topic.py new file mode 100644 index 00000000..09592077 --- /dev/null +++ b/aiogram/types/forum_topic.py @@ -0,0 +1,22 @@ +from __future__ import annotations + +from typing import Optional + +from .base import TelegramObject + + +class ForumTopic(TelegramObject): + """ + This object represents a forum topic. + + Source: https://core.telegram.org/bots/api#forumtopic + """ + + message_thread_id: int + """Unique identifier of the forum topic""" + name: str + """Name of the topic""" + icon_color: int + """Color of the topic icon in RGB format""" + icon_custom_emoji_id: Optional[str] = None + """*Optional*. Unique identifier of the custom emoji shown as the topic icon""" diff --git a/aiogram/types/forum_topic_closed.py b/aiogram/types/forum_topic_closed.py new file mode 100644 index 00000000..390b3317 --- /dev/null +++ b/aiogram/types/forum_topic_closed.py @@ -0,0 +1,11 @@ +from __future__ import annotations + +from .base import TelegramObject + + +class ForumTopicClosed(TelegramObject): + """ + This object represents a service message about a forum topic closed in the chat. Currently holds no information. + + Source: https://core.telegram.org/bots/api#forumtopicclosed + """ diff --git a/aiogram/types/forum_topic_created.py b/aiogram/types/forum_topic_created.py new file mode 100644 index 00000000..25448cf8 --- /dev/null +++ b/aiogram/types/forum_topic_created.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +from typing import Optional + +from .base import TelegramObject + + +class ForumTopicCreated(TelegramObject): + """ + This object represents a service message about a new forum topic created in the chat. + + Source: https://core.telegram.org/bots/api#forumtopiccreated + """ + + name: str + """Name of the topic""" + icon_color: int + """Color of the topic icon in RGB format""" + icon_custom_emoji_id: Optional[str] = None + """*Optional*. Unique identifier of the custom emoji shown as the topic icon""" diff --git a/aiogram/types/forum_topic_reopened.py b/aiogram/types/forum_topic_reopened.py new file mode 100644 index 00000000..e02fbafb --- /dev/null +++ b/aiogram/types/forum_topic_reopened.py @@ -0,0 +1,11 @@ +from __future__ import annotations + +from .base import TelegramObject + + +class ForumTopicReopened(TelegramObject): + """ + This object represents a service message about a forum topic reopened in the chat. Currently holds no information. + + Source: https://core.telegram.org/bots/api#forumtopicreopened + """ diff --git a/aiogram/types/inline_keyboard_markup.py b/aiogram/types/inline_keyboard_markup.py index 0bbdee37..473e292c 100644 --- a/aiogram/types/inline_keyboard_markup.py +++ b/aiogram/types/inline_keyboard_markup.py @@ -10,7 +10,7 @@ if TYPE_CHECKING: class InlineKeyboardMarkup(MutableTelegramObject): """ - This object represents an `inline keyboard `_ that appears right next to the message it belongs to. + This object represents an `inline keyboard `_ that appears right next to the message it belongs to. **Note:** This will only work in Telegram versions released after 9 April, 2016. Older clients will display *unsupported message*. Source: https://core.telegram.org/bots/api#inlinekeyboardmarkup diff --git a/aiogram/types/inline_query_result_article.py b/aiogram/types/inline_query_result_article.py index 9fa6a9c6..0b4578dd 100644 --- a/aiogram/types/inline_query_result_article.py +++ b/aiogram/types/inline_query_result_article.py @@ -27,7 +27,7 @@ class InlineQueryResultArticle(InlineQueryResult): input_message_content: InputMessageContent """Content of the message to be sent""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" url: Optional[str] = None """*Optional*. URL of the result""" hide_url: Optional[bool] = None diff --git a/aiogram/types/inline_query_result_audio.py b/aiogram/types/inline_query_result_audio.py index 97141268..615980f6 100644 --- a/aiogram/types/inline_query_result_audio.py +++ b/aiogram/types/inline_query_result_audio.py @@ -40,6 +40,6 @@ class InlineQueryResultAudio(InlineQueryResult): audio_duration: Optional[int] = None """*Optional*. Audio duration in seconds""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" input_message_content: Optional[InputMessageContent] = None """*Optional*. Content of the message to be sent instead of the audio""" diff --git a/aiogram/types/inline_query_result_cached_audio.py b/aiogram/types/inline_query_result_cached_audio.py index d9f12668..08971c79 100644 --- a/aiogram/types/inline_query_result_cached_audio.py +++ b/aiogram/types/inline_query_result_cached_audio.py @@ -34,6 +34,6 @@ class InlineQueryResultCachedAudio(InlineQueryResult): caption_entities: Optional[List[MessageEntity]] = None """*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" input_message_content: Optional[InputMessageContent] = None """*Optional*. Content of the message to be sent instead of the audio""" diff --git a/aiogram/types/inline_query_result_cached_document.py b/aiogram/types/inline_query_result_cached_document.py index bb4f1349..f5fc741f 100644 --- a/aiogram/types/inline_query_result_cached_document.py +++ b/aiogram/types/inline_query_result_cached_document.py @@ -38,6 +38,6 @@ class InlineQueryResultCachedDocument(InlineQueryResult): caption_entities: Optional[List[MessageEntity]] = None """*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" input_message_content: Optional[InputMessageContent] = None """*Optional*. Content of the message to be sent instead of the file""" diff --git a/aiogram/types/inline_query_result_cached_gif.py b/aiogram/types/inline_query_result_cached_gif.py index 053dfd43..03abe92e 100644 --- a/aiogram/types/inline_query_result_cached_gif.py +++ b/aiogram/types/inline_query_result_cached_gif.py @@ -35,6 +35,6 @@ class InlineQueryResultCachedGif(InlineQueryResult): caption_entities: Optional[List[MessageEntity]] = None """*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" input_message_content: Optional[InputMessageContent] = None """*Optional*. Content of the message to be sent instead of the GIF animation""" diff --git a/aiogram/types/inline_query_result_cached_mpeg4_gif.py b/aiogram/types/inline_query_result_cached_mpeg4_gif.py index 0500603f..6ff85564 100644 --- a/aiogram/types/inline_query_result_cached_mpeg4_gif.py +++ b/aiogram/types/inline_query_result_cached_mpeg4_gif.py @@ -35,6 +35,6 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult): caption_entities: Optional[List[MessageEntity]] = None """*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" input_message_content: Optional[InputMessageContent] = None """*Optional*. Content of the message to be sent instead of the video animation""" diff --git a/aiogram/types/inline_query_result_cached_photo.py b/aiogram/types/inline_query_result_cached_photo.py index 07ab3a50..9d570b66 100644 --- a/aiogram/types/inline_query_result_cached_photo.py +++ b/aiogram/types/inline_query_result_cached_photo.py @@ -37,6 +37,6 @@ class InlineQueryResultCachedPhoto(InlineQueryResult): caption_entities: Optional[List[MessageEntity]] = None """*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" input_message_content: Optional[InputMessageContent] = None """*Optional*. Content of the message to be sent instead of the photo""" diff --git a/aiogram/types/inline_query_result_cached_sticker.py b/aiogram/types/inline_query_result_cached_sticker.py index 80685ff2..850e08c6 100644 --- a/aiogram/types/inline_query_result_cached_sticker.py +++ b/aiogram/types/inline_query_result_cached_sticker.py @@ -26,6 +26,6 @@ class InlineQueryResultCachedSticker(InlineQueryResult): sticker_file_id: str """A valid file identifier of the sticker""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" input_message_content: Optional[InputMessageContent] = None """*Optional*. Content of the message to be sent instead of the sticker""" diff --git a/aiogram/types/inline_query_result_cached_video.py b/aiogram/types/inline_query_result_cached_video.py index 334eafbf..75196161 100644 --- a/aiogram/types/inline_query_result_cached_video.py +++ b/aiogram/types/inline_query_result_cached_video.py @@ -37,6 +37,6 @@ class InlineQueryResultCachedVideo(InlineQueryResult): caption_entities: Optional[List[MessageEntity]] = None """*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" input_message_content: Optional[InputMessageContent] = None """*Optional*. Content of the message to be sent instead of the video""" diff --git a/aiogram/types/inline_query_result_cached_voice.py b/aiogram/types/inline_query_result_cached_voice.py index 3da9abf8..c62e467a 100644 --- a/aiogram/types/inline_query_result_cached_voice.py +++ b/aiogram/types/inline_query_result_cached_voice.py @@ -36,6 +36,6 @@ class InlineQueryResultCachedVoice(InlineQueryResult): caption_entities: Optional[List[MessageEntity]] = None """*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" input_message_content: Optional[InputMessageContent] = None """*Optional*. Content of the message to be sent instead of the voice message""" diff --git a/aiogram/types/inline_query_result_contact.py b/aiogram/types/inline_query_result_contact.py index dcbda121..d6bb278a 100644 --- a/aiogram/types/inline_query_result_contact.py +++ b/aiogram/types/inline_query_result_contact.py @@ -32,7 +32,7 @@ class InlineQueryResultContact(InlineQueryResult): vcard: Optional[str] = None """*Optional*. Additional data about the contact in the form of a `vCard `_, 0-2048 bytes""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" input_message_content: Optional[InputMessageContent] = None """*Optional*. Content of the message to be sent instead of the contact""" thumb_url: Optional[str] = None diff --git a/aiogram/types/inline_query_result_game.py b/aiogram/types/inline_query_result_game.py index 4ece5b95..bcf56acb 100644 --- a/aiogram/types/inline_query_result_game.py +++ b/aiogram/types/inline_query_result_game.py @@ -25,4 +25,4 @@ class InlineQueryResultGame(InlineQueryResult): game_short_name: str """Short name of the game""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" diff --git a/aiogram/types/inline_query_result_gif.py b/aiogram/types/inline_query_result_gif.py index 2946437c..cf53e726 100644 --- a/aiogram/types/inline_query_result_gif.py +++ b/aiogram/types/inline_query_result_gif.py @@ -45,6 +45,6 @@ class InlineQueryResultGif(InlineQueryResult): caption_entities: Optional[List[MessageEntity]] = None """*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" input_message_content: Optional[InputMessageContent] = None """*Optional*. Content of the message to be sent instead of the GIF animation""" diff --git a/aiogram/types/inline_query_result_location.py b/aiogram/types/inline_query_result_location.py index b7e45919..339a967e 100644 --- a/aiogram/types/inline_query_result_location.py +++ b/aiogram/types/inline_query_result_location.py @@ -38,7 +38,7 @@ class InlineQueryResultLocation(InlineQueryResult): proximity_alert_radius: Optional[int] = None """*Optional*. For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" input_message_content: Optional[InputMessageContent] = None """*Optional*. Content of the message to be sent instead of the location""" thumb_url: Optional[str] = None diff --git a/aiogram/types/inline_query_result_mpeg4_gif.py b/aiogram/types/inline_query_result_mpeg4_gif.py index 242386f6..e4ed3e60 100644 --- a/aiogram/types/inline_query_result_mpeg4_gif.py +++ b/aiogram/types/inline_query_result_mpeg4_gif.py @@ -45,6 +45,6 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult): caption_entities: Optional[List[MessageEntity]] = None """*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" input_message_content: Optional[InputMessageContent] = None """*Optional*. Content of the message to be sent instead of the video animation""" diff --git a/aiogram/types/inline_query_result_photo.py b/aiogram/types/inline_query_result_photo.py index c150ace7..6925b0bb 100644 --- a/aiogram/types/inline_query_result_photo.py +++ b/aiogram/types/inline_query_result_photo.py @@ -43,6 +43,6 @@ class InlineQueryResultPhoto(InlineQueryResult): caption_entities: Optional[List[MessageEntity]] = None """*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" input_message_content: Optional[InputMessageContent] = None """*Optional*. Content of the message to be sent instead of the photo""" diff --git a/aiogram/types/inline_query_result_venue.py b/aiogram/types/inline_query_result_venue.py index e27e6cd0..38d362b7 100644 --- a/aiogram/types/inline_query_result_venue.py +++ b/aiogram/types/inline_query_result_venue.py @@ -40,7 +40,7 @@ class InlineQueryResultVenue(InlineQueryResult): google_place_type: Optional[str] = None """*Optional*. Google Places type of the venue. (See `supported types `_.)""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" input_message_content: Optional[InputMessageContent] = None """*Optional*. Content of the message to be sent instead of the venue""" thumb_url: Optional[str] = None diff --git a/aiogram/types/inline_query_result_video.py b/aiogram/types/inline_query_result_video.py index abd76c94..3848396f 100644 --- a/aiogram/types/inline_query_result_video.py +++ b/aiogram/types/inline_query_result_video.py @@ -49,6 +49,6 @@ class InlineQueryResultVideo(InlineQueryResult): description: Optional[str] = None """*Optional*. Short description of the result""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" input_message_content: Optional[InputMessageContent] = None """*Optional*. Content of the message to be sent instead of the video. This field is **required** if InlineQueryResultVideo is used to send an HTML-page as a result (e.g., a YouTube video).""" diff --git a/aiogram/types/inline_query_result_voice.py b/aiogram/types/inline_query_result_voice.py index 2097f6b7..e0ed7296 100644 --- a/aiogram/types/inline_query_result_voice.py +++ b/aiogram/types/inline_query_result_voice.py @@ -38,6 +38,6 @@ class InlineQueryResultVoice(InlineQueryResult): voice_duration: Optional[int] = None """*Optional*. Recording duration in seconds""" reply_markup: Optional[InlineKeyboardMarkup] = None - """*Optional*. `Inline keyboard `_ attached to the message""" + """*Optional*. `Inline keyboard `_ attached to the message""" input_message_content: Optional[InputMessageContent] = None """*Optional*. Content of the message to be sent instead of the voice recording""" diff --git a/aiogram/types/menu_button_commands.py b/aiogram/types/menu_button_commands.py index 5f4e252b..f115bdd6 100644 --- a/aiogram/types/menu_button_commands.py +++ b/aiogram/types/menu_button_commands.py @@ -2,7 +2,7 @@ from __future__ import annotations from pydantic import Field -from . import MenuButton +from .menu_button import MenuButton class MenuButtonCommands(MenuButton): diff --git a/aiogram/types/menu_button_default.py b/aiogram/types/menu_button_default.py index 13cd3a37..2ff09546 100644 --- a/aiogram/types/menu_button_default.py +++ b/aiogram/types/menu_button_default.py @@ -2,7 +2,7 @@ from __future__ import annotations from pydantic import Field -from . import MenuButton +from .menu_button import MenuButton class MenuButtonDefault(MenuButton): diff --git a/aiogram/types/menu_button_web_app.py b/aiogram/types/menu_button_web_app.py index 0de45b94..982dfa06 100644 --- a/aiogram/types/menu_button_web_app.py +++ b/aiogram/types/menu_button_web_app.py @@ -4,7 +4,7 @@ from typing import TYPE_CHECKING from pydantic import Field -from . import MenuButton +from .menu_button import MenuButton if TYPE_CHECKING: from .web_app_info import WebAppInfo diff --git a/aiogram/types/message.py b/aiogram/types/message.py index 834503d1..724d279d 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -48,6 +48,9 @@ if TYPE_CHECKING: from .dice import Dice from .document import Document from .force_reply import ForceReply + from .forum_topic_closed import ForumTopicClosed + from .forum_topic_created import ForumTopicCreated + from .forum_topic_reopened import ForumTopicReopened from .game import Game from .inline_keyboard_markup import InlineKeyboardMarkup from .input_file import InputFile @@ -94,6 +97,8 @@ class Message(TelegramObject): """Date the message was sent in Unix time""" chat: Chat """Conversation the message belongs to""" + message_thread_id: Optional[int] = None + """*Optional*. Unique identifier of a message thread to which the message belongs; for supergroups only""" from_user: Optional[User] = Field(None, alias="from") """*Optional*. Sender of the message; empty for messages sent to channels. For backward compatibility, the field contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.""" sender_chat: Optional[Chat] = None @@ -110,6 +115,8 @@ class Message(TelegramObject): """*Optional*. Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages""" forward_date: Optional[int] = None """*Optional*. For forwarded messages, date the original message was sent in Unix time""" + is_topic_message: Optional[bool] = None + """*Optional*. :code:`True`, if the message is sent to a forum topic""" is_automatic_forward: Optional[bool] = None """*Optional*. :code:`True`, if the message is a channel post that was automatically forwarded to the connected discussion group""" reply_to_message: Optional[Message] = None @@ -194,6 +201,12 @@ class Message(TelegramObject): """*Optional*. Telegram Passport data""" proximity_alert_triggered: Optional[ProximityAlertTriggered] = None """*Optional*. Service message. A user in the chat triggered another user's proximity alert while sharing Live Location.""" + forum_topic_created: Optional[ForumTopicCreated] = None + """*Optional*. Service message: forum topic created""" + forum_topic_closed: Optional[ForumTopicClosed] = None + """*Optional*. Service message: forum topic closed""" + forum_topic_reopened: Optional[ForumTopicReopened] = None + """*Optional*. Service message: forum topic reopened""" video_chat_scheduled: Optional[VideoChatScheduled] = None """*Optional*. Service message: video chat scheduled""" video_chat_started: Optional[VideoChatStarted] = None diff --git a/aiogram/types/user.py b/aiogram/types/user.py index f9e8af24..2308dbd4 100644 --- a/aiogram/types/user.py +++ b/aiogram/types/user.py @@ -2,14 +2,15 @@ from __future__ import annotations from typing import Optional -from ..utils.link import create_tg_link from ..utils import markdown +from ..utils.link import create_tg_link from .base import TelegramObject class User(TelegramObject): """ This object represents a Telegram user or bot. + Source: https://core.telegram.org/bots/api#user """ @@ -32,7 +33,7 @@ class User(TelegramObject): can_join_groups: Optional[bool] = None """*Optional*. :code:`True`, if the bot can be invited to groups. Returned only in :class:`aiogram.methods.get_me.GetMe`.""" can_read_all_group_messages: Optional[bool] = None - """*Optional*. :code:`True`, if `privacy mode `_ is disabled for the bot. Returned only in :class:`aiogram.methods.get_me.GetMe`.""" + """*Optional*. :code:`True`, if `privacy mode `_ is disabled for the bot. Returned only in :class:`aiogram.methods.get_me.GetMe`.""" supports_inline_queries: Optional[bool] = None """*Optional*. :code:`True`, if the bot supports inline queries. Returned only in :class:`aiogram.methods.get_me.GetMe`.""" diff --git a/aiogram/types/video_chat_ended.py b/aiogram/types/video_chat_ended.py index cb85a931..d890a153 100644 --- a/aiogram/types/video_chat_ended.py +++ b/aiogram/types/video_chat_ended.py @@ -1,12 +1,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from .base import TelegramObject -if TYPE_CHECKING: - pass - class VideoChatEnded(TelegramObject): """ diff --git a/aiogram/types/video_chat_scheduled.py b/aiogram/types/video_chat_scheduled.py index 541e988a..508b1ce3 100644 --- a/aiogram/types/video_chat_scheduled.py +++ b/aiogram/types/video_chat_scheduled.py @@ -1,6 +1,6 @@ from __future__ import annotations -from datetime import datetime +import datetime from .base import TelegramObject @@ -12,5 +12,5 @@ class VideoChatScheduled(TelegramObject): Source: https://core.telegram.org/bots/api#videochatscheduled """ - start_date: datetime + start_date: datetime.datetime """Point in time (Unix timestamp) when the video chat is supposed to be started by a chat administrator""" diff --git a/docs/api/methods/close_forum_topic.rst b/docs/api/methods/close_forum_topic.rst new file mode 100644 index 00000000..127813d0 --- /dev/null +++ b/docs/api/methods/close_forum_topic.rst @@ -0,0 +1,44 @@ +############### +closeForumTopic +############### + +Returns: :obj:`bool` + +.. automodule:: aiogram.methods.close_forum_topic + :members: + :member-order: bysource + :undoc-members: True + + +Usage +===== + +As bot method +------------- + +.. code-block:: + + result: bool = await bot.close_forum_topic(...) + + +Method as object +---------------- + +Imports: + +- :code:`from aiogram.methods.close_forum_topic import CloseForumTopic` +- alias: :code:`from aiogram.methods import CloseForumTopic` + +With specific bot +~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + result: bool = await bot(CloseForumTopic(...)) + +As reply into Webhook in handler +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + return CloseForumTopic(...) diff --git a/docs/api/methods/create_forum_topic.rst b/docs/api/methods/create_forum_topic.rst new file mode 100644 index 00000000..0c46afeb --- /dev/null +++ b/docs/api/methods/create_forum_topic.rst @@ -0,0 +1,44 @@ +################ +createForumTopic +################ + +Returns: :obj:`ForumTopic` + +.. automodule:: aiogram.methods.create_forum_topic + :members: + :member-order: bysource + :undoc-members: True + + +Usage +===== + +As bot method +------------- + +.. code-block:: + + result: ForumTopic = await bot.create_forum_topic(...) + + +Method as object +---------------- + +Imports: + +- :code:`from aiogram.methods.create_forum_topic import CreateForumTopic` +- alias: :code:`from aiogram.methods import CreateForumTopic` + +With specific bot +~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + result: ForumTopic = await bot(CreateForumTopic(...)) + +As reply into Webhook in handler +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + return CreateForumTopic(...) diff --git a/docs/api/methods/delete_forum_topic.rst b/docs/api/methods/delete_forum_topic.rst new file mode 100644 index 00000000..f17a204c --- /dev/null +++ b/docs/api/methods/delete_forum_topic.rst @@ -0,0 +1,44 @@ +################ +deleteForumTopic +################ + +Returns: :obj:`bool` + +.. automodule:: aiogram.methods.delete_forum_topic + :members: + :member-order: bysource + :undoc-members: True + + +Usage +===== + +As bot method +------------- + +.. code-block:: + + result: bool = await bot.delete_forum_topic(...) + + +Method as object +---------------- + +Imports: + +- :code:`from aiogram.methods.delete_forum_topic import DeleteForumTopic` +- alias: :code:`from aiogram.methods import DeleteForumTopic` + +With specific bot +~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + result: bool = await bot(DeleteForumTopic(...)) + +As reply into Webhook in handler +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + return DeleteForumTopic(...) diff --git a/docs/api/methods/edit_forum_topic.rst b/docs/api/methods/edit_forum_topic.rst new file mode 100644 index 00000000..daa6ff0e --- /dev/null +++ b/docs/api/methods/edit_forum_topic.rst @@ -0,0 +1,44 @@ +############## +editForumTopic +############## + +Returns: :obj:`bool` + +.. automodule:: aiogram.methods.edit_forum_topic + :members: + :member-order: bysource + :undoc-members: True + + +Usage +===== + +As bot method +------------- + +.. code-block:: + + result: bool = await bot.edit_forum_topic(...) + + +Method as object +---------------- + +Imports: + +- :code:`from aiogram.methods.edit_forum_topic import EditForumTopic` +- alias: :code:`from aiogram.methods import EditForumTopic` + +With specific bot +~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + result: bool = await bot(EditForumTopic(...)) + +As reply into Webhook in handler +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + return EditForumTopic(...) diff --git a/docs/api/methods/edit_message_live_location.rst b/docs/api/methods/edit_message_live_location.rst index 65af8bf1..3d9ec289 100644 --- a/docs/api/methods/edit_message_live_location.rst +++ b/docs/api/methods/edit_message_live_location.rst @@ -21,14 +21,6 @@ As bot method result: Union[Message, bool] = await bot.edit_message_live_location(...) -As message method ------------------ - -.. code-block:: - - result: Union[Message, bool] = await message.edit_live_location(...) - - Method as object ---------------- diff --git a/docs/api/methods/edit_message_media.rst b/docs/api/methods/edit_message_media.rst index 155a9eb6..efd8a3cb 100644 --- a/docs/api/methods/edit_message_media.rst +++ b/docs/api/methods/edit_message_media.rst @@ -21,14 +21,6 @@ As bot method result: Union[Message, bool] = await bot.edit_message_media(...) -As message method ------------------ - -.. code-block:: - - result: Union[Message, bool] = await message.edit_media(...) - - Method as object ---------------- diff --git a/docs/api/methods/forward_message.rst b/docs/api/methods/forward_message.rst index 0242715c..2b02dfdc 100644 --- a/docs/api/methods/forward_message.rst +++ b/docs/api/methods/forward_message.rst @@ -21,14 +21,6 @@ As bot method result: Message = await bot.forward_message(...) -As message method -------------- - -.. code-block:: - - result: Message = await message.forward(...) - - Method as object ---------------- diff --git a/docs/api/methods/get_chat_menu_button.rst b/docs/api/methods/get_chat_menu_button.rst index 85a6c6a3..5a3f5a6f 100644 --- a/docs/api/methods/get_chat_menu_button.rst +++ b/docs/api/methods/get_chat_menu_button.rst @@ -2,7 +2,7 @@ getChatMenuButton ################# -Returns: :obj:`MenuButton` +Returns: :obj:`Union[MenuButtonDefault, MenuButtonWebApp, MenuButtonCommands]` .. automodule:: aiogram.methods.get_chat_menu_button :members: @@ -18,7 +18,7 @@ As bot method .. code-block:: - result: MenuButton = await bot.get_chat_menu_button(...) + result: Union[MenuButtonDefault, MenuButtonWebApp, MenuButtonCommands] = await bot.get_chat_menu_button(...) Method as object @@ -34,4 +34,4 @@ With specific bot .. code-block:: python - result: MenuButton = await bot(GetChatMenuButton(...)) + result: Union[MenuButtonDefault, MenuButtonWebApp, MenuButtonCommands] = await bot(GetChatMenuButton(...)) diff --git a/docs/api/methods/get_forum_topic_icon_stickers.rst b/docs/api/methods/get_forum_topic_icon_stickers.rst new file mode 100644 index 00000000..ef3887e4 --- /dev/null +++ b/docs/api/methods/get_forum_topic_icon_stickers.rst @@ -0,0 +1,37 @@ +######################### +getForumTopicIconStickers +######################### + +Returns: :obj:`List[Sticker]` + +.. automodule:: aiogram.methods.get_forum_topic_icon_stickers + :members: + :member-order: bysource + :undoc-members: True + + +Usage +===== + +As bot method +------------- + +.. code-block:: + + result: List[Sticker] = await bot.get_forum_topic_icon_stickers(...) + + +Method as object +---------------- + +Imports: + +- :code:`from aiogram.methods.get_forum_topic_icon_stickers import GetForumTopicIconStickers` +- alias: :code:`from aiogram.methods import GetForumTopicIconStickers` + +With specific bot +~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + result: List[Sticker] = await bot(GetForumTopicIconStickers(...)) diff --git a/docs/api/methods/index.rst b/docs/api/methods/index.rst index d09d5881..a47ea7f6 100644 --- a/docs/api/methods/index.rst +++ b/docs/api/methods/index.rst @@ -78,6 +78,13 @@ Available methods get_chat_member set_chat_sticker_set delete_chat_sticker_set + get_forum_topic_icon_stickers + create_forum_topic + edit_forum_topic + close_forum_topic + reopen_forum_topic + delete_forum_topic + unpin_all_forum_topic_messages answer_callback_query set_my_commands delete_my_commands diff --git a/docs/api/methods/pin_chat_message.rst b/docs/api/methods/pin_chat_message.rst index d28eb9b4..ec730278 100644 --- a/docs/api/methods/pin_chat_message.rst +++ b/docs/api/methods/pin_chat_message.rst @@ -21,14 +21,6 @@ As bot method result: bool = await bot.pin_chat_message(...) -As message method ------------------ - -.. code-block:: - - result: bool = await message.pin(...) - - Method as object ---------------- diff --git a/docs/api/methods/reopen_forum_topic.rst b/docs/api/methods/reopen_forum_topic.rst new file mode 100644 index 00000000..c76b7adc --- /dev/null +++ b/docs/api/methods/reopen_forum_topic.rst @@ -0,0 +1,44 @@ +################ +reopenForumTopic +################ + +Returns: :obj:`bool` + +.. automodule:: aiogram.methods.reopen_forum_topic + :members: + :member-order: bysource + :undoc-members: True + + +Usage +===== + +As bot method +------------- + +.. code-block:: + + result: bool = await bot.reopen_forum_topic(...) + + +Method as object +---------------- + +Imports: + +- :code:`from aiogram.methods.reopen_forum_topic import ReopenForumTopic` +- alias: :code:`from aiogram.methods import ReopenForumTopic` + +With specific bot +~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + result: bool = await bot(ReopenForumTopic(...)) + +As reply into Webhook in handler +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + return ReopenForumTopic(...) diff --git a/docs/api/methods/stop_message_live_location.rst b/docs/api/methods/stop_message_live_location.rst index 2cdc3fb4..1ef6440a 100644 --- a/docs/api/methods/stop_message_live_location.rst +++ b/docs/api/methods/stop_message_live_location.rst @@ -21,14 +21,6 @@ As bot method result: Union[Message, bool] = await bot.stop_message_live_location(...) -As message method ------------------ - -.. code-block:: - - result: Union[Message, bool] = await message.stop_live_location(...) - - Method as object ---------------- diff --git a/docs/api/methods/unpin_all_forum_topic_messages.rst b/docs/api/methods/unpin_all_forum_topic_messages.rst new file mode 100644 index 00000000..7ae521f4 --- /dev/null +++ b/docs/api/methods/unpin_all_forum_topic_messages.rst @@ -0,0 +1,44 @@ +########################## +unpinAllForumTopicMessages +########################## + +Returns: :obj:`bool` + +.. automodule:: aiogram.methods.unpin_all_forum_topic_messages + :members: + :member-order: bysource + :undoc-members: True + + +Usage +===== + +As bot method +------------- + +.. code-block:: + + result: bool = await bot.unpin_all_forum_topic_messages(...) + + +Method as object +---------------- + +Imports: + +- :code:`from aiogram.methods.unpin_all_forum_topic_messages import UnpinAllForumTopicMessages` +- alias: :code:`from aiogram.methods import UnpinAllForumTopicMessages` + +With specific bot +~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + result: bool = await bot(UnpinAllForumTopicMessages(...)) + +As reply into Webhook in handler +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + return UnpinAllForumTopicMessages(...) diff --git a/docs/api/methods/unpin_chat_message.rst b/docs/api/methods/unpin_chat_message.rst index a4c5e7f1..1531ec19 100644 --- a/docs/api/methods/unpin_chat_message.rst +++ b/docs/api/methods/unpin_chat_message.rst @@ -21,14 +21,6 @@ As bot method result: bool = await bot.unpin_chat_message(...) -As message method ------------------ - -.. code-block:: - - result: bool = await message.unpin() - - Method as object ---------------- diff --git a/docs/api/types/forum_topic.rst b/docs/api/types/forum_topic.rst new file mode 100644 index 00000000..fa5e99a6 --- /dev/null +++ b/docs/api/types/forum_topic.rst @@ -0,0 +1,9 @@ +########## +ForumTopic +########## + + +.. automodule:: aiogram.types.forum_topic + :members: + :member-order: bysource + :undoc-members: True diff --git a/docs/api/types/forum_topic_closed.rst b/docs/api/types/forum_topic_closed.rst new file mode 100644 index 00000000..200b19a5 --- /dev/null +++ b/docs/api/types/forum_topic_closed.rst @@ -0,0 +1,9 @@ +################ +ForumTopicClosed +################ + + +.. automodule:: aiogram.types.forum_topic_closed + :members: + :member-order: bysource + :undoc-members: True diff --git a/docs/api/types/forum_topic_created.rst b/docs/api/types/forum_topic_created.rst new file mode 100644 index 00000000..5eeb2382 --- /dev/null +++ b/docs/api/types/forum_topic_created.rst @@ -0,0 +1,9 @@ +################# +ForumTopicCreated +################# + + +.. automodule:: aiogram.types.forum_topic_created + :members: + :member-order: bysource + :undoc-members: True diff --git a/docs/api/types/forum_topic_reopened.rst b/docs/api/types/forum_topic_reopened.rst new file mode 100644 index 00000000..8803cf1f --- /dev/null +++ b/docs/api/types/forum_topic_reopened.rst @@ -0,0 +1,9 @@ +################## +ForumTopicReopened +################## + + +.. automodule:: aiogram.types.forum_topic_reopened + :members: + :member-order: bysource + :undoc-members: True diff --git a/docs/api/types/index.rst b/docs/api/types/index.rst index 32b33b53..97a876e6 100644 --- a/docs/api/types/index.rst +++ b/docs/api/types/index.rst @@ -43,6 +43,9 @@ Available types web_app_data proximity_alert_triggered message_auto_delete_timer_changed + forum_topic_created + forum_topic_closed + forum_topic_reopened video_chat_scheduled video_chat_started video_chat_ended @@ -73,6 +76,7 @@ Available types chat_join_request chat_permissions chat_location + forum_topic bot_command bot_command_scope bot_command_scope_default