Added all new API methods

This commit is contained in:
Alex Root Junior 2022-11-06 03:54:16 +02:00
parent 93a425f528
commit 707988bf03
No known key found for this signature in database
GPG key ID: 074C1D455EBEA4AC
5 changed files with 228 additions and 57 deletions

View file

@ -252,6 +252,13 @@ class Methods(Helper):
GET_CHAT_MEMBER = Item() # getChatMember GET_CHAT_MEMBER = Item() # getChatMember
SET_CHAT_STICKER_SET = Item() # setChatStickerSet SET_CHAT_STICKER_SET = Item() # setChatStickerSet
DELETE_CHAT_STICKER_SET = Item() # deleteChatStickerSet DELETE_CHAT_STICKER_SET = Item() # deleteChatStickerSet
GET_FORUM_TOPIC_ICON_STICKERS = Item() # getForumTopicIconStickers
CREATE_FORUM_TOPIC = Item() # createForumTopic
EDIT_FORUM_TOPIC = Item() # editForumTopic
CLOSE_FORUM_TOPIC = Item() # closeForumTopic
REOPEN_FORUM_TOPIC = Item() # reopenForumTopic
DELETE_FORUM_TOPIC = Item() # deleteForumTopic
UNPIN_ALL_FORUM_TOPIC_MESSAGES = Item() # unpinAllForumTopicMessages
ANSWER_CALLBACK_QUERY = Item() # answerCallbackQuery ANSWER_CALLBACK_QUERY = Item() # answerCallbackQuery
SET_MY_COMMANDS = Item() # setMyCommands SET_MY_COMMANDS = Item() # setMyCommands
DELETE_MY_COMMANDS = Item() # deleteMyCommands DELETE_MY_COMMANDS = Item() # deleteMyCommands

View file

@ -280,9 +280,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
reply_to_message_id: typing.Optional[base.Integer] = None, reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove, types.ReplyKeyboardRemove,
types.ForceReply, None] = None, types.ForceReply, None] = None,
) -> types.Message: ) -> types.Message:
""" """
Use this method to send text messages. Use this method to send text messages.
@ -407,9 +407,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
reply_to_message_id: typing.Optional[base.Integer] = None, reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove, types.ReplyKeyboardRemove,
types.ForceReply, None] = None, types.ForceReply, None] = None,
) -> types.MessageId: ) -> types.MessageId:
""" """
Use this method to copy messages of any kind. The method is analogous to the Use this method to copy messages of any kind. The method is analogous to the
@ -495,9 +495,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
reply_to_message_id: typing.Optional[base.Integer] = None, reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove, types.ReplyKeyboardRemove,
types.ForceReply, None] = None, types.ForceReply, None] = None,
) -> types.Message: ) -> types.Message:
""" """
Use this method to send photos. Use this method to send photos.
@ -577,9 +577,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
reply_to_message_id: typing.Optional[base.Integer] = None, reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove, types.ReplyKeyboardRemove,
types.ForceReply, None] = None, types.ForceReply, None] = None,
) -> types.Message: ) -> types.Message:
""" """
Use this method to send audio files, if you want Telegram clients to display them in the music player. Use this method to send audio files, if you want Telegram clients to display them in the music player.
@ -673,10 +673,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
reply_to_message_id: typing.Optional[base.Integer] = None, reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove, types.ReplyKeyboardRemove,
types.ForceReply, types.ForceReply,
None] = None, None] = None,
) -> types.Message: ) -> types.Message:
""" """
Use this method to send general files. On success, the sent Message is Use this method to send general files. On success, the sent Message is
@ -773,9 +773,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
reply_to_message_id: typing.Optional[base.Integer] = None, reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove, types.ReplyKeyboardRemove,
types.ForceReply, None] = None, types.ForceReply, None] = None,
) -> types.Message: ) -> types.Message:
""" """
Use this method to send video files, Telegram clients support mp4 videos Use this method to send video files, Telegram clients support mp4 videos
@ -872,9 +872,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
reply_to_message_id: typing.Optional[base.Integer] = None, reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove, types.ReplyKeyboardRemove,
types.ForceReply], None] = None, types.ForceReply], None] = None,
) -> types.Message: ) -> types.Message:
""" """
Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound).
@ -971,9 +971,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
reply_to_message_id: typing.Optional[base.Integer] = None, reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove, types.ReplyKeyboardRemove,
types.ForceReply, None] = None, types.ForceReply, None] = None,
) -> types.Message: ) -> types.Message:
""" """
Use this method to send audio files, if you want Telegram clients to display the file Use this method to send audio files, if you want Telegram clients to display the file
@ -1055,9 +1055,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
reply_to_message_id: typing.Optional[base.Integer] = None, reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove, types.ReplyKeyboardRemove,
types.ForceReply, None] = None, types.ForceReply, None] = None,
) -> types.Message: ) -> types.Message:
""" """
As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long.
@ -1196,9 +1196,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
reply_to_message_id: typing.Optional[base.Integer] = None, reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove, types.ReplyKeyboardRemove,
types.ForceReply, None] = None, types.ForceReply, None] = None,
) -> types.Message: ) -> types.Message:
""" """
Use this method to send point on the map. Use this method to send point on the map.
@ -1330,7 +1330,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
message_id: typing.Optional[base.Integer] = None, message_id: typing.Optional[base.Integer] = None,
inline_message_id: typing.Optional[base.String] = None, inline_message_id: typing.Optional[base.String] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[types.InlineKeyboardMarkup,
None] = None) -> types.Message or base.Boolean: None] = None) -> types.Message or base.Boolean:
""" """
Use this method to stop updating a live location message sent by the bot or via the bot Use this method to stop updating a live location message sent by the bot or via the bot
(for inline bots) before live_period expires. (for inline bots) before live_period expires.
@ -1373,9 +1373,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
reply_to_message_id: typing.Optional[base.Integer] = None, reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove, types.ReplyKeyboardRemove,
types.ForceReply, None] = None, types.ForceReply, None] = None,
) -> types.Message: ) -> types.Message:
""" """
Use this method to send information about a venue. Use this method to send information about a venue.
@ -1459,9 +1459,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
reply_to_message_id: typing.Optional[base.Integer] = None, reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove, types.ReplyKeyboardRemove,
types.ForceReply, None] = None, types.ForceReply, None] = None,
) -> types.Message: ) -> types.Message:
""" """
Use this method to send phone contacts. Use this method to send phone contacts.
@ -1541,9 +1541,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
reply_to_message_id: typing.Optional[base.Integer] = None, reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove, types.ReplyKeyboardRemove,
types.ForceReply, None] = None, types.ForceReply, None] = None,
) -> types.Message: ) -> types.Message:
""" """
Use this method to send a native poll. On success, the sent Message is Use this method to send a native poll. On success, the sent Message is
@ -1653,9 +1653,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
reply_to_message_id: typing.Optional[base.Integer] = None, reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove, types.ReplyKeyboardRemove,
types.ForceReply, None] = None, types.ForceReply, None] = None,
) -> types.Message: ) -> types.Message:
""" """
Use this method to send an animated emoji that will display a random value. Use this method to send an animated emoji that will display a random value.
@ -1795,7 +1795,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
chat_id: typing.Union[base.Integer, base.String], chat_id: typing.Union[base.Integer, base.String],
user_id: base.Integer, user_id: base.Integer,
until_date: typing.Union[base.Integer, datetime.datetime, until_date: typing.Union[base.Integer, datetime.datetime,
datetime.timedelta, None] = None, datetime.timedelta, None] = None,
revoke_messages: typing.Optional[base.Boolean] = None, revoke_messages: typing.Optional[base.Boolean] = None,
) -> base.Boolean: ) -> base.Boolean:
""" """
@ -1841,7 +1841,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
chat_id: typing.Union[base.Integer, base.String], chat_id: typing.Union[base.Integer, base.String],
user_id: base.Integer, user_id: base.Integer,
until_date: typing.Union[base.Integer, datetime.datetime, until_date: typing.Union[base.Integer, datetime.datetime,
datetime.timedelta, None] = None, datetime.timedelta, None] = None,
revoke_messages: typing.Optional[base.Boolean] = None, revoke_messages: typing.Optional[base.Boolean] = None,
) -> base.Boolean: ) -> base.Boolean:
"""Renamed to ban_chat_member.""" """Renamed to ban_chat_member."""
@ -1955,6 +1955,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
can_pin_messages: typing.Optional[base.Boolean] = None, can_pin_messages: typing.Optional[base.Boolean] = None,
can_promote_members: typing.Optional[base.Boolean] = None, can_promote_members: typing.Optional[base.Boolean] = None,
can_manage_video_chats: typing.Optional[base.Boolean] = None, can_manage_video_chats: typing.Optional[base.Boolean] = None,
can_manage_topics: typing.Optional[base.Boolean] = None,
) -> base.Boolean: ) -> base.Boolean:
""" """
Use this method to promote or demote a user in a supergroup or a channel. Use this method to promote or demote a user in a supergroup or a channel.
@ -2008,6 +2009,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
:param can_manage_video_chats: Pass True, if the administrator can manage video chats :param can_manage_video_chats: Pass True, if the administrator can manage video chats
:param can_manage_topics: Pass True if the user is allowed to create, rename, close, and reopen forum topics, supergroups only
:type can_manage_topics: :obj:`typing.Optional[base.Boolean]`
:return: Returns True on success :return: Returns True on success
:rtype: :obj:`base.Boolean` :rtype: :obj:`base.Boolean`
""" """
@ -2124,7 +2128,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
async def create_chat_invite_link(self, async def create_chat_invite_link(self,
chat_id: typing.Union[base.Integer, base.String], chat_id: typing.Union[base.Integer, base.String],
expire_date: typing.Union[base.Integer, datetime.datetime, expire_date: typing.Union[base.Integer, datetime.datetime,
datetime.timedelta, None] = None, datetime.timedelta, None] = None,
member_limit: typing.Optional[base.Integer] = None, member_limit: typing.Optional[base.Integer] = None,
name: typing.Optional[base.String] = None, name: typing.Optional[base.String] = None,
creates_join_request: typing.Optional[base.Boolean] = None, creates_join_request: typing.Optional[base.Boolean] = None,
@ -2169,7 +2173,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
chat_id: typing.Union[base.Integer, base.String], chat_id: typing.Union[base.Integer, base.String],
invite_link: base.String, invite_link: base.String,
expire_date: typing.Union[base.Integer, datetime.datetime, expire_date: typing.Union[base.Integer, datetime.datetime,
datetime.timedelta, None] = None, datetime.timedelta, None] = None,
member_limit: typing.Optional[base.Integer] = None, member_limit: typing.Optional[base.Integer] = None,
name: typing.Optional[base.String] = None, name: typing.Optional[base.String] = None,
creates_join_request: typing.Optional[base.Boolean] = None, creates_join_request: typing.Optional[base.Boolean] = None,
@ -2587,6 +2591,138 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
return await self.request(api.Methods.DELETE_CHAT_STICKER_SET, payload) return await self.request(api.Methods.DELETE_CHAT_STICKER_SET, payload)
async def get_forum_topic_icon_stickers(self) -> typing.List[types.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 Sticker objects.
Source: https://core.telegram.org/bots/api#getforumtopiciconstickers
:return: Returns an Array of Sticker objects.
"""
payload = generate_payload(**locals())
result = await self.request(api.Methods.GET_FORUM_TOPIC_ICON_STICKERS, payload)
return [types.Sticker(**sticker) for sticker in result]
async def create_forum_topic(self, chat_id: typing.Union[int, str],
name: base.String,
icon_color: typing.Optional[base.Integer] = None,
icon_custom_emoji_id: typing.Optional[base.String] = None) -> types.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 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 @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 getForumTopicIconStickers to get all allowed custom emoji identifiers.
:return: Returns information about the created topic as a ForumTopic object.
"""
payload = generate_payload(**locals())
result = await self.request(api.Methods.CREATE_FORUM_TOPIC, payload)
return types.ForumTopic(**result)
async def edit_forum_topic(self, chat_id: typing.Union[int, str],
name: base.String,
message_thread_id: typing.Optional[base.Integer] = None,
icon_custom_emoji_id: typing.Optional[base.String] = None) -> base.Boolean:
"""
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 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 @supergroupusername)
:param name: Unique identifier for the target message thread of the forum topic
:param message_thread_id: New topic name, 1-128 characters
:param icon_custom_emoji_id: New unique identifier of the custom emoji shown as the topic icon.
Use getForumTopicIconStickers to get all allowed custom emoji identifiers
:return: Returns True on success.
"""
payload = generate_payload(**locals())
return await self.request(api.Methods.EDIT_FORUM_TOPIC, payload)
async def close_forum_topic(self, chat_id: typing.Union[int, str],
message_thread_id: typing.Optional[base.Integer] = None) -> base.Boolean:
"""
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 True on success.
:param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
:param message_thread_id: Unique identifier for the target message thread of the forum topic
:return: Returns True on success.
"""
payload = generate_payload(**locals())
return await self.request(api.Methods.CLOSE_FORUM_TOPIC, payload)
async def reopen_forum_topic(self, chat_id: typing.Union[int, str],
message_thread_id: typing.Optional[base.Integer] = None) -> base.Boolean:
"""
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 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 @supergroupusername)
:param message_thread_id: Unique identifier for the target message thread of the forum topic
:return: Returns True on success.
"""
payload = generate_payload(**locals())
return await self.request(api.Methods.REOPEN_FORUM_TOPIC, payload)
async def delete_forum_topic(self, chat_id: typing.Union[int, str],
message_thread_id: typing.Optional[base.Integer] = None) -> base.Boolean:
"""
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 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 @supergroupusername)
:param message_thread_id: Unique identifier for the target message thread of the forum topic
:return: Returns True on success.
"""
payload = generate_payload(**locals())
return await self.request(api.Methods.DELETE_FORUM_TOPIC, payload)
async def unpin_all_forum_topic_messages(self, chat_id: typing.Union[int, str],
message_thread_id: typing.Optional[base.Integer] = None) -> base.Boolean:
"""
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 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 @supergroupusername)
:param message_thread_id: Unique identifier for the target message thread of the forum topic
:return: Returns True on success.
"""
payload = generate_payload(**locals())
return await self.request(api.Methods.UNPIN_ALL_FORUM_TOPIC_MESSAGES, payload)
async def answer_callback_query(self, callback_query_id: base.String, async def answer_callback_query(self, callback_query_id: base.String,
text: typing.Optional[base.String] = None, text: typing.Optional[base.String] = None,
show_alert: typing.Optional[base.Boolean] = None, show_alert: typing.Optional[base.Boolean] = None,
@ -2805,7 +2941,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
entities: typing.Optional[typing.List[types.MessageEntity]] = None, entities: typing.Optional[typing.List[types.MessageEntity]] = None,
disable_web_page_preview: typing.Optional[base.Boolean] = None, disable_web_page_preview: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[types.InlineKeyboardMarkup,
None] = None, None] = None,
) -> types.Message or base.Boolean: ) -> types.Message or base.Boolean:
""" """
Use this method to edit text and game messages sent by the bot or via the bot (for inline bots). Use this method to edit text and game messages sent by the bot or via the bot (for inline bots).
@ -2863,7 +2999,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
parse_mode: typing.Optional[base.String] = None, parse_mode: typing.Optional[base.String] = None,
caption_entities: typing.Optional[typing.List[types.MessageEntity]] = None, caption_entities: typing.Optional[typing.List[types.MessageEntity]] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[types.InlineKeyboardMarkup,
None] = None) -> types.Message or base.Boolean: None] = None) -> types.Message or base.Boolean:
""" """
Use this method to edit captions of messages sent by the bot or via the bot (for inline bots). Use this method to edit captions of messages sent by the bot or via the bot (for inline bots).
@ -2959,7 +3095,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
message_id: typing.Optional[base.Integer] = None, message_id: typing.Optional[base.Integer] = None,
inline_message_id: typing.Optional[base.String] = None, inline_message_id: typing.Optional[base.String] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[types.InlineKeyboardMarkup,
None] = None) -> types.Message or base.Boolean: None] = None) -> types.Message or base.Boolean:
""" """
Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
@ -3042,9 +3178,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
reply_to_message_id: typing.Optional[base.Integer] = None, reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None, allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup, reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove, types.ReplyKeyboardRemove,
types.ForceReply, None] = None, types.ForceReply, None] = None,
) -> types.Message: ) -> types.Message:
""" """
Use this method to send .webp stickers. Use this method to send .webp stickers.
@ -3772,7 +3908,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
chat_id: typing.Optional[base.Integer] = None, chat_id: typing.Optional[base.Integer] = None,
message_id: typing.Optional[base.Integer] = None, message_id: typing.Optional[base.Integer] = None,
inline_message_id: typing.Union[base.String, inline_message_id: typing.Union[base.String,
None] = None) -> types.Message or base.Boolean: None] = None) -> types.Message or base.Boolean:
""" """
Use this method to set the score of the specified user in a game. Use this method to set the score of the specified user in a game.
@ -3810,7 +3946,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
chat_id: typing.Optional[base.Integer] = None, chat_id: typing.Optional[base.Integer] = None,
message_id: typing.Optional[base.Integer] = None, message_id: typing.Optional[base.Integer] = None,
inline_message_id: typing.Union[base.String, inline_message_id: typing.Union[base.String,
None] = None) -> typing.List[types.GameHighScore]: None] = None) -> typing.List[types.GameHighScore]:
""" """
Use this method to get data for high score tables. Use this method to get data for high score tables.

View file

@ -29,8 +29,9 @@ from .encrypted_credentials import EncryptedCredentials
from .encrypted_passport_element import EncryptedPassportElement from .encrypted_passport_element import EncryptedPassportElement
from .file import File from .file import File
from .force_reply import ForceReply from .force_reply import ForceReply
from .forum_topic_created import ForumTopicCreated from .forum_topic import ForumTopic
from .forum_topic_closed import ForumTopicClosed from .forum_topic_closed import ForumTopicClosed
from .forum_topic_created import ForumTopicCreated
from .forum_topic_reopened import ForumTopicReopened from .forum_topic_reopened import ForumTopicReopened
from .game import Game from .game import Game
from .game_high_score import GameHighScore from .game_high_score import GameHighScore
@ -141,6 +142,7 @@ __all__ = (
'EncryptedPassportElement', 'EncryptedPassportElement',
'File', 'File',
'ForceReply', 'ForceReply',
'ForumTopic',
'Game', 'Game',
'GameHighScore', 'GameHighScore',
'InlineKeyboardButton', 'InlineKeyboardButton',

View file

@ -0,0 +1,14 @@
from . import base
from . import fields
class ForumTopic(base.TelegramObject):
"""
This object represents a forum topic.
https://core.telegram.org/bots/api#forumtopic
"""
message_thread_id: base.Integer = fields.Field()
name: base.String = fields.Field()
icon_color: base.Integer = fields.Field()
icon_custom_emoji_id: base.String = fields.Field()

View file

@ -198,6 +198,12 @@ class Message(base.TelegramObject):
return ContentType.VOICE_CHAT_PARTICIPANTS_INVITED return ContentType.VOICE_CHAT_PARTICIPANTS_INVITED
if self.web_app_data: if self.web_app_data:
return ContentType.WEB_APP_DATA return ContentType.WEB_APP_DATA
if self.forum_topic_created:
return ContentType.FORUM_TOPIC_CREATED
if self.forum_topic_closed:
return ContentType.FORUM_TOPIC_CLOSED
if self.forum_topic_reopened:
return ContentType.FORUM_TOPIC_REOPENED
if self.video_chat_scheduled: if self.video_chat_scheduled:
return ContentType.VIDEO_CHAT_SCHEDULED return ContentType.VIDEO_CHAT_SCHEDULED
if self.video_chat_started: if self.video_chat_started:
@ -3328,6 +3334,9 @@ class ContentType(helper.Helper):
VOICE_CHAT_ENDED = helper.Item() # voice_chat_ended VOICE_CHAT_ENDED = helper.Item() # voice_chat_ended
VOICE_CHAT_PARTICIPANTS_INVITED = helper.Item() # voice_chat_participants_invited VOICE_CHAT_PARTICIPANTS_INVITED = helper.Item() # voice_chat_participants_invited
WEB_APP_DATA = helper.Item() # web_app_data WEB_APP_DATA = helper.Item() # web_app_data
FORUM_TOPIC_CREATED = helper.Item() # forum_topic_created
FORUM_TOPIC_CLOSED = helper.Item() # forum_topic_closed
FORUM_TOPIC_REOPENED = helper.Item() # forum_topic_reopened
VIDEO_CHAT_SCHEDULED = helper.Item() # video_chat_scheduled VIDEO_CHAT_SCHEDULED = helper.Item() # video_chat_scheduled
VIDEO_CHAT_STARTED = helper.Item() # video_chat_started VIDEO_CHAT_STARTED = helper.Item() # video_chat_started
VIDEO_CHAT_ENDED = helper.Item() # video_chat_ended VIDEO_CHAT_ENDED = helper.Item() # video_chat_ended
@ -3399,6 +3408,9 @@ class ContentTypes(helper.Helper):
GROUP_CHAT_CREATED = helper.ListItem() # group_chat_created GROUP_CHAT_CREATED = helper.ListItem() # group_chat_created
PASSPORT_DATA = helper.ListItem() # passport_data PASSPORT_DATA = helper.ListItem() # passport_data
WEB_APP_DATA = helper.Item() # web_app_data WEB_APP_DATA = helper.Item() # web_app_data
FORUM_TOPIC_CREATED = helper.ListItem() # forum_topic_created
FORUM_TOPIC_CLOSED = helper.ListItem() # forum_topic_closed
FORUM_TOPIC_REOPENED = helper.ListItem() # forum_topic_reopened
VIDEO_CHAT_SCHEDULED = helper.Item() # video_chat_scheduled VIDEO_CHAT_SCHEDULED = helper.Item() # video_chat_scheduled
VIDEO_CHAT_STARTED = helper.Item() # video_chat_started VIDEO_CHAT_STARTED = helper.Item() # video_chat_started
VIDEO_CHAT_ENDED = helper.Item() # video_chat_ended VIDEO_CHAT_ENDED = helper.Item() # video_chat_ended