From 3d7f334d794daeb8c23f41841c26a84bd79705e9 Mon Sep 17 00:00:00 2001 From: _run Date: Tue, 26 Jul 2022 16:16:35 +0500 Subject: [PATCH] Updated all docstrings for types(visual) --- telebot/types.py | 3763 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 3587 insertions(+), 176 deletions(-) diff --git a/telebot/types.py b/telebot/types.py index c2d932b..1755ddd 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -27,6 +27,8 @@ class JsonSerializable(object): """ Returns a JSON string representation of this class. + :meta private: + This function must be overridden by subclasses. :return: a JSON formatted string. """ @@ -44,6 +46,8 @@ class Dictionaryable(object): """ Returns a DICT with class field values + :meta private: + This function must be overridden by subclasses. :return: a DICT """ @@ -61,6 +65,8 @@ class JsonDeserializable(object): """ Returns an instance of this class from the given json dict or string. + :meta private: + This function must be overridden by subclasses. :return: an instance of this class created from the given json dict or string. """ @@ -71,6 +77,8 @@ class JsonDeserializable(object): """ Checks whether json_type is a dict or a string. If it is already a dict, it is returned as-is. If it is not, it is converted to a dict by means of json.loads(json_type) + + :meta private: :param json_type: input json or parsed dict :param dict_copy: if dict is passed and it is changed outside - should be True! @@ -93,63 +101,69 @@ class JsonDeserializable(object): class Update(JsonDeserializable): """ - This object represents an incoming update. + This object represents an incoming update.At most one of the optional parameters can be present in any given update. - https://core.telegram.org/bots/api#update + Telegram Documentation: https://core.telegram.org/bots/api#update - :attribute update_id: The update's unique identifier. Update identifiers start from a certain positive number and increase sequentially. - This ID becomes especially handy if you're using webhooks, since it allows you to ignore repeated updates or to restore the correct - update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will - be chosen randomly instead of sequentially. - :type update_id: int + :param update_id: The update's unique identifier. Update identifiers start from a certain positive number and + increase sequentially. This ID becomes especially handy if you're using webhooks, since it allows you to ignore + repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates + for at least a week, then identifier of the next update will be chosen randomly instead of sequentially. + :type update_id: :obj:`int` - :attribute message: New incoming message of any kind — text, photo, sticker, etc. + :param message: Optional. New incoming message of any kind - text, photo, sticker, etc. :type message: :class:`telebot.types.Message` - :attribute edited_message: New version of a message that is known to the bot and was edited. + :param edited_message: Optional. New version of a message that is known to the bot and was edited :type edited_message: :class:`telebot.types.Message` - - :attribute channel_post: New incoming channel post of any kind — text, photo, sticker, etc. + + :param channel_post: Optional. New incoming channel post of any kind - text, photo, sticker, etc. :type channel_post: :class:`telebot.types.Message` - :attribute edited_channel_post: New version of a channel post that is known to the bot and was edited. + :param edited_channel_post: Optional. New version of a channel post that is known to the bot and was edited :type edited_channel_post: :class:`telebot.types.Message` - :attribute inline_query: New incoming query from a user, which is answered by a bot and can be further processed. + :param inline_query: Optional. New incoming inline query :type inline_query: :class:`telebot.types.InlineQuery` - :attribute chosen_inline_result: New incoming result of an inline query that was chosen by a user and sent to their chat partner. + :param chosen_inline_result: Optional. The result of an inline query that was chosen by a user and sent to their chat + partner. Please see our documentation on the feedback collecting for details on how to enable these updates for your + bot. :type chosen_inline_result: :class:`telebot.types.ChosenInlineResult` - :attribute callback_query: New incoming callback query from a user. + :param callback_query: Optional. New incoming callback query :type callback_query: :class:`telebot.types.CallbackQuery` - :attribute shipping_query: New incoming shipping query. Only for invoices with flexible price + :param shipping_query: Optional. New incoming shipping query. Only for invoices with flexible price :type shipping_query: :class:`telebot.types.ShippingQuery` - :attribute pre_checkout_query: New incoming pre-checkout query. Contains full information about checkout + :param pre_checkout_query: Optional. New incoming pre-checkout query. Contains full information about + checkout :type pre_checkout_query: :class:`telebot.types.PreCheckoutQuery` - :attribute poll: New poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot + :param poll: Optional. New poll state. Bots receive only updates about stopped polls and polls, which are sent by the + bot :type poll: :class:`telebot.types.Poll` - :attribute poll_answer: A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself. + :param poll_answer: Optional. A user changed their answer in a non-anonymous poll. Bots receive new votes only in + polls that were sent by the bot itself. :type poll_answer: :class:`telebot.types.PollAnswer` - :attribute my_chat_member: The bot's chat member status was updated in a chat. For private chats, - this update is received only when the bot is blocked or unblocked by the user. - :type my_chat_member: :class:`telebot.types.ChatMember` + :param my_chat_member: Optional. The bot's chat member status was updated in a chat. For private chats, this update + is received only when the bot is blocked or unblocked by the user. + :type my_chat_member: :class:`telebot.types.ChatMemberUpdated` - :attribute chat_member: A chat member's status was updated in a chat. The bot must be an administrator in the chat and must - explicitly specify “chat_member” in the list of allowed_updates to receive these updates. - :type chat_member: :class:`telebot.types.ChatMember` + :param chat_member: Optional. A chat member's status was updated in a chat. The bot must be an administrator in the + chat and must explicitly specify “chat_member” in the list of allowed_updates to receive these updates. + :type chat_member: :class:`telebot.types.ChatMemberUpdated` - :attribute chat_join_request: A request to join the chat has been sent. The bot must have the can_invite_users - administrator right in the chat to receive these updates. + :param chat_join_request: Optional. A request to join the chat has been sent. The bot must have the + can_invite_users administrator right in the chat to receive these updates. :type chat_join_request: :class:`telebot.types.ChatJoinRequest` - :return: An Update object. + :return: Instance of the class :rtype: :class:`telebot.types.Update` + """ @classmethod def de_json(cls, json_string): @@ -195,6 +209,33 @@ class Update(JsonDeserializable): class ChatMemberUpdated(JsonDeserializable): + """ + This object represents changes in the status of a chat member. + + Telegram Documentation: https://core.telegram.org/bots/api#chatmemberupdated + + :param chat: Chat the user belongs to + :type chat: :class:`telebot.types.Chat` + + :param from_user: Performer of the action, which resulted in the change + :type from_user: :class:`telebot.types.User` + + :param date: Date the change was done in Unix time + :type date: :obj:`int` + + :param old_chat_member: Previous information about the chat member + :type old_chat_member: :class:`telebot.types.ChatMember` + + :param new_chat_member: New information about the chat member + :type new_chat_member: :class:`telebot.types.ChatMember` + + :param invite_link: Optional. Chat invite link, which was used by the user to join the chat; for joining by invite + link events only. + :type invite_link: :class:`telebot.types.ChatInviteLink` + + :return: Instance of the class + :rtype: :class:`telebot.types.ChatMemberUpdated` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -219,7 +260,11 @@ class ChatMemberUpdated(JsonDeserializable): """ Get the difference between `old_chat_member` and `new_chat_member` as a dict in the following format {'parameter': [old_value, new_value]} - E.g {'status': ['member', 'kicked'], 'until_date': [None, 1625055092]} + E.g {'status': ['member', 'kicked'], 'until_date': [None, 1625055092]} + + + :return: Dict of differences + :rtype: Dict[str, List] """ old: Dict = self.old_chat_member.__dict__ new: Dict = self.new_chat_member.__dict__ @@ -229,8 +274,32 @@ class ChatMemberUpdated(JsonDeserializable): if new[key] != old[key]: dif[key] = [old[key], new[key]] return dif + class ChatJoinRequest(JsonDeserializable): + """ + Represents a join request sent to a chat. + + Telegram Documentation: https://core.telegram.org/bots/api#chatjoinrequest + + :param chat: Chat to which the request was sent + :type chat: :class:`telebot.types.Chat` + + :param from: User that sent the join request + :type from_user: :class:`telebot.types.User` + + :param date: Date the request was sent in Unix time + :type date: :obj:`int` + + :param bio: Optional. Bio of the user. + :type bio: :obj:`str` + + :param invite_link: Optional. Chat invite link that was used by the user to send the join request + :type invite_link: :class:`telebot.types.ChatInviteLink` + + :return: Instance of the class + :rtype: :class:`telebot.types.ChatJoinRequest` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -248,6 +317,46 @@ class ChatJoinRequest(JsonDeserializable): self.invite_link = invite_link class WebhookInfo(JsonDeserializable): + """ + Describes the current status of a webhook. + + Telegram Documentation: https://core.telegram.org/bots/api#webhookinfo + + :param url: Webhook URL, may be empty if webhook is not set up + :type url: :obj:`str` + + :param has_custom_certificate: True, if a custom certificate was provided for webhook certificate checks + :type has_custom_certificate: :obj:`bool` + + :param pending_update_count: Number of updates awaiting delivery + :type pending_update_count: :obj:`int` + + :param ip_address: Optional. Currently used webhook IP address + :type ip_address: :obj:`str` + + :param last_error_date: Optional. Unix time for the most recent error that happened when trying to deliver an + update via webhook + :type last_error_date: :obj:`int` + + :param last_error_message: Optional. Error message in human-readable format for the most recent error that + happened when trying to deliver an update via webhook + :type last_error_message: :obj:`str` + + :param last_synchronization_error_date: Optional. Unix time of the most recent error that happened when trying + to synchronize available updates with Telegram datacenters + :type last_synchronization_error_date: :obj:`int` + + :param max_connections: Optional. The maximum allowed number of simultaneous HTTPS connections to the webhook + for update delivery + :type max_connections: :obj:`int` + + :param allowed_updates: Optional. A list of update types the bot is subscribed to. Defaults to all update types + except chat_member + :type allowed_updates: :obj:`list` of :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.WebhookInfo` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -269,6 +378,50 @@ class WebhookInfo(JsonDeserializable): class User(JsonDeserializable, Dictionaryable, JsonSerializable): + """ + This object represents a Telegram user or bot. + + Telegram Documentation: https://core.telegram.org/bots/api#user + + :param id: Unique identifier for this user or bot. This number may have more than 32 significant bits and some + programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant + bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. + :type id: :obj:`int` + + :param is_bot: True, if this user is a bot + :type is_bot: :obj:`bool` + + :param first_name: User's or bot's first name + :type first_name: :obj:`str` + + :param last_name: Optional. User's or bot's last name + :type last_name: :obj:`str` + + :param username: Optional. User's or bot's username + :type username: :obj:`str` + + :param language_code: Optional. IETF language tag of the user's language + :type language_code: :obj:`str` + + :param is_premium: Optional. :obj:`bool`, if this user is a Telegram Premium user + :type is_premium: :obj:`bool` + + :param added_to_attachment_menu: Optional. :obj:`bool`, if this user added the bot to the attachment menu + :type added_to_attachment_menu: :obj:`bool` + + :param can_join_groups: Optional. True, if the bot can be invited to groups. Returned only in getMe. + :type can_join_groups: :obj:`bool` + + :param can_read_all_group_messages: Optional. True, if privacy mode is disabled for the bot. Returned only in + getMe. + :type can_read_all_group_messages: :obj:`bool` + + :param supports_inline_queries: Optional. True, if the bot supports inline queries. Returned only in getMe. + :type supports_inline_queries: :obj:`bool` + + :return: Instance of the class + :rtype: :class:`telebot.types.User` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -293,6 +446,9 @@ class User(JsonDeserializable, Dictionaryable, JsonSerializable): @property def full_name(self): + """ + :return: User's full name + """ full_name = self.first_name if self.last_name: full_name += ' {0}'.format(self.last_name) @@ -310,10 +466,15 @@ class User(JsonDeserializable, Dictionaryable, JsonSerializable): 'language_code': self.language_code, 'can_join_groups': self.can_join_groups, 'can_read_all_group_messages': self.can_read_all_group_messages, - 'supports_inline_queries': self.supports_inline_queries} + 'supports_inline_queries': self.supports_inline_queries, + 'is_premium': self.is_premium, + 'added_to_attachment_menu': self.added_to_attachment_menu} class GroupChat(JsonDeserializable): + """ + :meta private: + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -326,6 +487,95 @@ class GroupChat(JsonDeserializable): class Chat(JsonDeserializable): + """ + This object represents a chat. + + Telegram Documentation: https://core.telegram.org/bots/api#chat + + :param id: Unique identifier for this chat. This number may have more than 32 significant bits and some programming + languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed + 64-bit integer or double-precision float type are safe for storing this identifier. + :type id: :obj:`int` + + :param type: Type of chat, can be either “private”, “group”, “supergroup” or “channel” + :type type: :obj:`str` + + :param title: Optional. Title, for supergroups, channels and group chats + :type title: :obj:`str` + + :param username: Optional. Username, for private chats, supergroups and channels if available + :type username: :obj:`str` + + :param first_name: Optional. First name of the other party in a private chat + :type first_name: :obj:`str` + + :param last_name: Optional. Last name of the other party in a private chat + :type last_name: :obj:`str` + + :param photo: Optional. Chat photo. Returned only in getChat. + :type photo: :class:`telebot.types.ChatPhoto` + + :param bio: Optional. Bio of the other party in a private chat. Returned only in getChat. + :type bio: :obj:`str` + + :param has_private_forwards: Optional. :obj:`bool`, if privacy settings of the other party in the private chat + allows to use tg://user?id= links only in chats with the user. Returned only in getChat. + :type has_private_forwards: :obj:`bool` + + :param join_to_send_messages: Optional. :obj:`bool`, if users need to join the supergroup before they can send + messages. Returned only in getChat. + :type join_to_send_messages: :obj:`bool` + + :param join_by_request: Optional. :obj:`bool`, if all users directly joining the supergroup need to be approved + by supergroup administrators. Returned only in getChat. + :type join_by_request: :obj:`bool` + + :param description: Optional. Description, for groups, supergroups and channel chats. Returned only in getChat. + :type description: :obj:`str` + + :param invite_link: Optional. Primary invite link, for groups, supergroups and channel chats. Returned only in + getChat. + :type invite_link: :obj:`str` + + :param pinned_message: Optional. The most recent pinned message (by sending date). Returned only in getChat. + :type pinned_message: :class:`telebot.types.Message` + + :param permissions: Optional. Default chat member permissions, for groups and supergroups. Returned only in + getChat. + :type permissions: :class:`telebot.types.ChatPermissions` + + :param slow_mode_delay: Optional. For supergroups, the minimum allowed delay between consecutive messages sent + by each unpriviledged user; in seconds. Returned only in getChat. + :type slow_mode_delay: :obj:`int` + + :param message_auto_delete_time: Optional. The time after which all messages sent to the chat will be + automatically deleted; in seconds. Returned only in getChat. + :type message_auto_delete_time: :obj:`int` + + :param has_protected_content: Optional. :obj:`bool`, if messages from the chat can't be forwarded to other + chats. Returned only in getChat. + :type has_protected_content: :obj:`bool` + + :param sticker_set_name: Optional. For supergroups, name of group sticker set. Returned only in getChat. + :type sticker_set_name: :obj:`str` + + :param can_set_sticker_set: Optional. :obj:`bool`, if the bot can change the group sticker set. Returned only in + getChat. + :type can_set_sticker_set: :obj:`bool` + + :param linked_chat_id: Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for + a channel and vice versa; for supergroups and channel chats. This identifier may be greater than 32 bits and some + programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a + signed 64 bit integer or double-precision float type are safe for storing this identifier. Returned only in getChat. + :type linked_chat_id: :obj:`int` + + :param location: Optional. For supergroups, the location to which the supergroup is connected. Returned only in + getChat. + :type location: :class:`telebot.types.ChatLocation` + + :return: Instance of the class + :rtype: :class:`telebot.types.Chat` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -372,6 +622,17 @@ class Chat(JsonDeserializable): class MessageID(JsonDeserializable): + """ + This object represents a unique message identifier. + + Telegram Documentation: https://core.telegram.org/bots/api#messageid + + :param message_id: Unique message identifier + :type message_id: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.MessageId` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -383,6 +644,22 @@ class MessageID(JsonDeserializable): class WebAppData(JsonDeserializable): + """ + Describes data sent from a Web App to the bot. + + Telegram Documentation: https://core.telegram.org/bots/api#webappdata + + :param data: The data. Be aware that a bad client can send arbitrary data in this field. + :type data: :obj:`str` + + :param button_text: Text of the web_app keyboard button from which the Web App was opened. Be aware that a bad client + can send arbitrary data in this field. + :type button_text: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.WebAppData` + """ + def __init__(self, data, button_text): self.data = data self.button_text = button_text @@ -397,6 +674,224 @@ class WebAppData(JsonDeserializable): class Message(JsonDeserializable): + """ + This object represents a message. + + Telegram Documentation: https://core.telegram.org/bots/api#message + + :param message_id: Unique message identifier inside this chat + :type message_id: :obj:`int` + + :param from_user: 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. + :type from_user: :class:`telebot.types.User` + + :param sender_chat: Optional. Sender of the message, sent on behalf of a chat. For example, the channel itself for + channel posts, the supergroup itself for messages from anonymous group administrators, the linked channel for + messages automatically forwarded to the discussion group. For backward compatibility, the field from contains a + fake sender user in non-channel chats, if the message was sent on behalf of a chat. + :type sender_chat: :class:`telebot.types.Chat` + + :param date: Date the message was sent in Unix time + :type date: :obj:`int` + + :param chat: Conversation the message belongs to + :type chat: :class:`telebot.types.Chat` + + :param forward_from: Optional. For forwarded messages, sender of the original message + :type forward_from: :class:`telebot.types.User` + + :param forward_from_chat: Optional. For messages forwarded from channels or from anonymous administrators, + information about the original sender chat + :type forward_from_chat: :class:`telebot.types.Chat` + + :param forward_from_message_id: Optional. For messages forwarded from channels, identifier of the original + message in the channel + :type forward_from_message_id: :obj:`int` + + :param forward_signature: Optional. For forwarded messages that were originally sent in channels or by an + anonymous chat administrator, signature of the message sender if present + :type forward_signature: :obj:`str` + + :param forward_sender_name: Optional. Sender's name for messages forwarded from users who disallow adding a link + to their account in forwarded messages + :type forward_sender_name: :obj:`str` + + :param forward_date: Optional. For forwarded messages, date the original message was sent in Unix time + :type forward_date: :obj:`int` + + :param is_automatic_forward: Optional. :obj:`bool`, if the message is a channel post that was automatically + forwarded to the connected discussion group + :type is_automatic_forward: :obj:`bool` + + :param reply_to_message: Optional. For replies, the original message. Note that the Message object in this field + will not contain further reply_to_message fields even if it itself is a reply. + :type reply_to_message: :class:`telebot.types.Message` + + :param via_bot: Optional. Bot through which the message was sent + :type via_bot: :class:`telebot.types.User` + + :param edit_date: Optional. Date the message was last edited in Unix time + :type edit_date: :obj:`int` + + :param has_protected_content: Optional. :obj:`bool`, if the message can't be forwarded + :type has_protected_content: :obj:`bool` + + :param media_group_id: Optional. The unique identifier of a media message group this message belongs to + :type media_group_id: :obj:`str` + + :param author_signature: Optional. Signature of the post author for messages in channels, or the custom title of an + anonymous group administrator + :type author_signature: :obj:`str` + + :param text: Optional. For text messages, the actual UTF-8 text of the message + :type text: :obj:`str` + + :param entities: Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that + appear in the text + :type entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param animation: Optional. Message is an animation, information about the animation. For backward + compatibility, when this field is set, the document field will also be set + :type animation: :class:`telebot.types.Animation` + + :param audio: Optional. Message is an audio file, information about the file + :type audio: :class:`telebot.types.Audio` + + :param document: Optional. Message is a general file, information about the file + :type document: :class:`telebot.types.Document` + + :param photo: Optional. Message is a photo, available sizes of the photo + :type photo: :obj:`list` of :class:`telebot.types.PhotoSize` + + :param sticker: Optional. Message is a sticker, information about the sticker + :type sticker: :class:`telebot.types.Sticker` + + :param video: Optional. Message is a video, information about the video + :type video: :class:`telebot.types.Video` + + :param video_note: Optional. Message is a video note, information about the video message + :type video_note: :class:`telebot.types.VideoNote` + + :param voice: Optional. Message is a voice message, information about the file + :type voice: :class:`telebot.types.Voice` + + :param caption: Optional. Caption for the animation, audio, document, photo, video or voice + :type caption: :obj:`str` + + :param caption_entities: Optional. For messages with a caption, special entities like usernames, URLs, bot + commands, etc. that appear in the caption + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param contact: Optional. Message is a shared contact, information about the contact + :type contact: :class:`telebot.types.Contact` + + :param dice: Optional. Message is a dice with random value + :type dice: :class:`telebot.types.Dice` + + :param game: Optional. Message is a game, information about the game. More about games » + :type game: :class:`telebot.types.Game` + + :param poll: Optional. Message is a native poll, information about the poll + :type poll: :class:`telebot.types.Poll` + + :param venue: Optional. Message is a venue, information about the venue. For backward compatibility, when this + field is set, the location field will also be set + :type venue: :class:`telebot.types.Venue` + + :param location: Optional. Message is a shared location, information about the location + :type location: :class:`telebot.types.Location` + + :param new_chat_members: Optional. New members that were added to the group or supergroup and information about + them (the bot itself may be one of these members) + :type new_chat_members: :obj:`list` of :class:`telebot.types.User` + + :param left_chat_member: Optional. A member was removed from the group, information about them (this member may be + the bot itself) + :type left_chat_member: :class:`telebot.types.User` + + :param new_chat_title: Optional. A chat title was changed to this value + :type new_chat_title: :obj:`str` + + :param new_chat_photo: Optional. A chat photo was change to this value + :type new_chat_photo: :obj:`list` of :class:`telebot.types.PhotoSize` + + :param delete_chat_photo: Optional. Service message: the chat photo was deleted + :type delete_chat_photo: :obj:`bool` + + :param group_chat_created: Optional. Service message: the group has been created + :type group_chat_created: :obj:`bool` + + :param supergroup_chat_created: Optional. Service message: the supergroup has been created. This field can't be + received in a message coming through updates, because bot can't be a member of a supergroup when it is created. It can + only be found in reply_to_message if someone replies to a very first message in a directly created supergroup. + :type supergroup_chat_created: :obj:`bool` + + :param channel_chat_created: Optional. Service message: the channel has been created. This field can't be + received in a message coming through updates, because bot can't be a member of a channel when it is created. It can only + be found in reply_to_message if someone replies to a very first message in a channel. + :type channel_chat_created: :obj:`bool` + + :param message_auto_delete_timer_changed: Optional. Service message: auto-delete timer settings changed in + the chat + :type message_auto_delete_timer_changed: :class:`telebot.types.MessageAutoDeleteTimerChanged` + + :param migrate_to_chat_id: Optional. The group has been migrated to a supergroup with the specified identifier. + This number may have more than 32 significant bits and some programming languages may have difficulty/silent + defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision + float type are safe for storing this identifier. + :type migrate_to_chat_id: :obj:`int` + + :param migrate_from_chat_id: Optional. The supergroup has been migrated from a group with the specified + identifier. This number may have more than 32 significant bits and some programming languages may have + difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or + double-precision float type are safe for storing this identifier. + :type migrate_from_chat_id: :obj:`int` + + :param pinned_message: Optional. Specified message was pinned. Note that the Message object in this field will not + contain further reply_to_message fields even if it is itself a reply. + :type pinned_message: :class:`telebot.types.Message` + + :param invoice: Optional. Message is an invoice for a payment, information about the invoice. More about payments » + :type invoice: :class:`telebot.types.Invoice` + + :param successful_payment: Optional. Message is a service message about a successful payment, information about + the payment. More about payments » + :type successful_payment: :class:`telebot.types.SuccessfulPayment` + + :param connected_website: Optional. The domain name of the website on which the user has logged in. More about + Telegram Login » + :type connected_website: :obj:`str` + + :param passport_data: Optional. Telegram Passport data + :type passport_data: :class:`telebot.types.PassportData` + + :param proximity_alert_triggered: Optional. Service message. A user in the chat triggered another user's + proximity alert while sharing Live Location. + :type proximity_alert_triggered: :class:`telebot.types.ProximityAlertTriggered` + + :param video_chat_scheduled: Optional. Service message: video chat scheduled + :type video_chat_scheduled: :class:`telebot.types.VideoChatScheduled` + + :param video_chat_started: Optional. Service message: video chat started + :type video_chat_started: :class:`telebot.types.VideoChatStarted` + + :param video_chat_ended: Optional. Service message: video chat ended + :type video_chat_ended: :class:`telebot.types.VideoChatEnded` + + :param video_chat_participants_invited: Optional. Service message: new participants invited to a video chat + :type video_chat_participants_invited: :class:`telebot.types.VideoChatParticipantsInvited` + + :param web_app_data: Optional. Service message: data sent by a Web App + :type web_app_data: :class:`telebot.types.WebAppData` + + :param reply_markup: Optional. Inline keyboard attached to the message. login_url buttons are represented as + ordinary url buttons. + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :return: Instance of the class + :rtype: :class:`telebot.types.Message` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -568,6 +1063,9 @@ class Message(JsonDeserializable): @classmethod def parse_chat(cls, chat): + """ + Parses chat. + """ if 'first_name' not in chat: return GroupChat.de_json(chat) else: @@ -575,6 +1073,9 @@ class Message(JsonDeserializable): @classmethod def parse_photo(cls, photo_size_array): + """ + Parses photo array. + """ ret = [] for ps in photo_size_array: ret.append(PhotoSize.de_json(ps)) @@ -582,6 +1083,9 @@ class Message(JsonDeserializable): @classmethod def parse_entities(cls, message_entity_array): + """ + Parses message entity array. + """ ret = [] for me in message_entity_array: ret.append(MessageEntity.de_json(me)) @@ -650,13 +1154,17 @@ class Message(JsonDeserializable): Updaters: @badiboy Message: "*Test* parse _formatting_, [url](https://example.com), [text_mention](tg://user?id=123456) and mention @username" - Example: + .. code-block:: python3 + :caption: Example: + message.html_text >> "Test parse formatting, url, text_mention and mention @username" Custom subs: You can customize the substitutes. By default, there is no substitute for the entities: hashtag, bot_command, email. You can add or modify substitute an existing entity. - Example: + .. code-block:: python3 + :caption: Example: + message.custom_subs = {"bold": "{text}", "italic": "{text}", "mention": "{text}"} message.html_text >> "Test parse formatting, url and text_mention and mention @username" @@ -716,16 +1224,56 @@ class Message(JsonDeserializable): @property def html_text(self): + """ + Returns html-rendered text. + """ return self.__html_text(self.text, self.entities) @property def html_caption(self): + """ + Returns html-rendered caption. + """ return self.__html_text(self.caption, self.caption_entities) class MessageEntity(Dictionaryable, JsonSerializable, JsonDeserializable): + """ + This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc. + + Telegram Documentation: https://core.telegram.org/bots/api#messageentity + + :param type: Type of the entity. Currently, can be “mention” (@username), “hashtag” (#hashtag), “cashtag” + ($USD), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” + (do-not-reply@telegram.org), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (italic text), + “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “code” + (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users + without usernames) + :type type: :obj:`str` + + :param offset: Offset in UTF-16 code units to the start of the entity + :type offset: :obj:`int` + + :param length: Length of the entity in UTF-16 code units + :type length: :obj:`int` + + :param url: Optional. For “text_link” only, URL that will be opened after user taps on the text + :type url: :obj:`str` + + :param user: Optional. For “text_mention” only, the mentioned user + :type user: :class:`telebot.types.User` + + :param language: Optional. For “pre” only, the programming language of the entity text + :type language: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.MessageEntity` + """ @staticmethod def to_list_of_dicts(entity_list) -> Union[List[Dict], None]: + """ + Converts a list of MessageEntity objects to a list of dictionaries. + """ res = [] for e in entity_list: res.append(MessageEntity.to_dict(e)) @@ -760,6 +1308,20 @@ class MessageEntity(Dictionaryable, JsonSerializable, JsonDeserializable): class Dice(JsonSerializable, Dictionaryable, JsonDeserializable): + """ + This object represents an animated emoji that displays a random value. + + Telegram Documentation: https://core.telegram.org/bots/api#dice + + :param emoji: Emoji on which the dice throw animation is based + :type emoji: :obj:`str` + + :param value: Value of the dice, 1-6 for “🎲”, “🎯” and “🎳” base emoji, 1-5 for “🏀” and “⚽” base emoji, 1-64 for “🎰” base emoji + :type value: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.Dice` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -779,6 +1341,30 @@ class Dice(JsonSerializable, Dictionaryable, JsonDeserializable): class PhotoSize(JsonDeserializable): + """ + This object represents one size of a photo or a file / sticker thumbnail. + + Telegram Documentation: https://core.telegram.org/bots/api#photosize + + :param file_id: Identifier for this file, which can be used to download or reuse the file + :type file_id: :obj:`str` + + :param file_unique_id: Unique identifier for this file, which is supposed to be the same over time and for different + bots. Can't be used to download or reuse the file. + :type file_unique_id: :obj:`str` + + :param width: Photo width + :type width: :obj:`int` + + :param height: Photo height + :type height: :obj:`int` + + :param file_size: Optional. File size in bytes + :type file_size: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.PhotoSize` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -794,6 +1380,44 @@ class PhotoSize(JsonDeserializable): class Audio(JsonDeserializable): + """ + This object represents an audio file to be treated as music by the Telegram clients. + + Telegram Documentation: https://core.telegram.org/bots/api#audio + + :param file_id: Identifier for this file, which can be used to download or reuse the file + :type file_id: :obj:`str` + + :param file_unique_id: Unique identifier for this file, which is supposed to be the same over time and for different + bots. Can't be used to download or reuse the file. + :type file_unique_id: :obj:`str` + + :param duration: Duration of the audio in seconds as defined by sender + :type duration: :obj:`int` + + :param performer: Optional. Performer of the audio as defined by sender or by audio tags + :type performer: :obj:`str` + + :param title: Optional. Title of the audio as defined by sender or by audio tags + :type title: :obj:`str` + + :param file_name: Optional. Original filename as defined by sender + :type file_name: :obj:`str` + + :param mime_type: Optional. MIME type of the file as defined by sender + :type mime_type: :obj:`str` + + :param file_size: Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have + difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or + double-precision float type are safe for storing this value. + :type file_size: :obj:`int` + + :param thumb: Optional. Thumbnail of the album cover to which the music file belongs + :type thumb: :class:`telebot.types.PhotoSize` + + :return: Instance of the class + :rtype: :class:`telebot.types.Audio` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -818,6 +1442,32 @@ class Audio(JsonDeserializable): class Voice(JsonDeserializable): + """ + This object represents a voice note. + + Telegram Documentation: https://core.telegram.org/bots/api#voice + + :param file_id: Identifier for this file, which can be used to download or reuse the file + :type file_id: :obj:`str` + + :param file_unique_id: Unique identifier for this file, which is supposed to be the same over time and for different + bots. Can't be used to download or reuse the file. + :type file_unique_id: :obj:`str` + + :param duration: Duration of the audio in seconds as defined by sender + :type duration: :obj:`int` + + :param mime_type: Optional. MIME type of the file as defined by sender + :type mime_type: :obj:`str` + + :param file_size: Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have + difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or + double-precision float type are safe for storing this value. + :type file_size: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.Voice` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -833,6 +1483,35 @@ class Voice(JsonDeserializable): class Document(JsonDeserializable): + """ + This object represents a general file (as opposed to photos, voice messages and audio files). + + Telegram Documentation: https://core.telegram.org/bots/api#document + + :param file_id: Identifier for this file, which can be used to download or reuse the file + :type file_id: :obj:`str` + + :param file_unique_id: Unique identifier for this file, which is supposed to be the same over time and for different + bots. Can't be used to download or reuse the file. + :type file_unique_id: :obj:`str` + + :param thumb: Optional. Document thumbnail as defined by sender + :type thumb: :class:`telebot.types.PhotoSize` + + :param file_name: Optional. Original filename as defined by sender + :type file_name: :obj:`str` + + :param mime_type: Optional. MIME type of the file as defined by sender + :type mime_type: :obj:`str` + + :param file_size: Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have + difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or + double-precision float type are safe for storing this value. + :type file_size: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.Document` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -853,6 +1532,44 @@ class Document(JsonDeserializable): class Video(JsonDeserializable): + """ + This object represents a video file. + + Telegram Documentation: https://core.telegram.org/bots/api#video + + :param file_id: Identifier for this file, which can be used to download or reuse the file + :type file_id: :obj:`str` + + :param file_unique_id: Unique identifier for this file, which is supposed to be the same over time and for different + bots. Can't be used to download or reuse the file. + :type file_unique_id: :obj:`str` + + :param width: Video width as defined by sender + :type width: :obj:`int` + + :param height: Video height as defined by sender + :type height: :obj:`int` + + :param duration: Duration of the video in seconds as defined by sender + :type duration: :obj:`int` + + :param thumb: Optional. Video thumbnail + :type thumb: :class:`telebot.types.PhotoSize` + + :param file_name: Optional. Original filename as defined by sender + :type file_name: :obj:`str` + + :param mime_type: Optional. MIME type of the file as defined by sender + :type mime_type: :obj:`str` + + :param file_size: Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have + difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or + double-precision float type are safe for storing this value. + :type file_size: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.Video` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -874,6 +1591,33 @@ class Video(JsonDeserializable): class VideoNote(JsonDeserializable): + """ + This object represents a video message (available in Telegram apps as of v.4.0). + + Telegram Documentation: https://core.telegram.org/bots/api#videonote + + :param file_id: Identifier for this file, which can be used to download or reuse the file + :type file_id: :obj:`str` + + :param file_unique_id: Unique identifier for this file, which is supposed to be the same over time and for different + bots. Can't be used to download or reuse the file. + :type file_unique_id: :obj:`str` + + :param length: Video width and height (diameter of the video message) as defined by sender + :type length: :obj:`int` + + :param duration: Duration of the video in seconds as defined by sender + :type duration: :obj:`int` + + :param thumb: Optional. Video thumbnail + :type thumb: :class:`telebot.types.PhotoSize` + + :param file_size: Optional. File size in bytes + :type file_size: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.VideoNote` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -892,6 +1636,31 @@ class VideoNote(JsonDeserializable): class Contact(JsonDeserializable): + """ + This object represents a phone contact. + + Telegram Documentation: https://core.telegram.org/bots/api#contact + + :param phone_number: Contact's phone number + :type phone_number: :obj:`str` + + :param first_name: Contact's first name + :type first_name: :obj:`str` + + :param last_name: Optional. Contact's last name + :type last_name: :obj:`str` + + :param user_id: Optional. Contact's user identifier in Telegram. This number may have more than 32 significant bits + and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 + significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. + :type user_id: :obj:`int` + + :param vcard: Optional. Additional data about the contact in the form of a vCard + :type vcard: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.Contact` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -907,6 +1676,34 @@ class Contact(JsonDeserializable): class Location(JsonDeserializable, JsonSerializable, Dictionaryable): + """ + This object represents a point on the map. + + Telegram Documentation: https://core.telegram.org/bots/api#location + + :param longitude: Longitude as defined by sender + :type longitude: :obj:`float` + + :param latitude: Latitude as defined by sender + :type latitude: :obj:`float` + + :param horizontal_accuracy: Optional. The radius of uncertainty for the location, measured in meters; 0-1500 + :type horizontal_accuracy: :obj:`float` number + + :param live_period: Optional. Time relative to the message sending date, during which the location can be updated; + in seconds. For active live locations only. + :type live_period: :obj:`int` + + :param heading: Optional. The direction in which user is moving, in degrees; 1-360. For active live locations only. + :type heading: :obj:`int` + + :param proximity_alert_radius: Optional. The maximum distance for proximity alerts about approaching another + chat member, in meters. For sent live locations only. + :type proximity_alert_radius: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.Location` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -937,6 +1734,36 @@ class Location(JsonDeserializable, JsonSerializable, Dictionaryable): class Venue(JsonDeserializable): + """ + This object represents a venue. + + Telegram Documentation: https://core.telegram.org/bots/api#venue + + :param location: Venue location. Can't be a live location + :type location: :class:`telebot.types.Location` + + :param title: Name of the venue + :type title: :obj:`str` + + :param address: Address of the venue + :type address: :obj:`str` + + :param foursquare_id: Optional. Foursquare identifier of the venue + :type foursquare_id: :obj:`str` + + :param foursquare_type: Optional. Foursquare type of the venue. (For example, “arts_entertainment/default”, + “arts_entertainment/aquarium” or “food/icecream”.) + :type foursquare_type: :obj:`str` + + :param google_place_id: Optional. Google Places identifier of the venue + :type google_place_id: :obj:`str` + + :param google_place_type: Optional. Google Places type of the venue. (See supported types.) + :type google_place_type: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.Venue` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -956,6 +1783,20 @@ class Venue(JsonDeserializable): class UserProfilePhotos(JsonDeserializable): + """ + This object represent a user's profile pictures. + + Telegram Documentation: https://core.telegram.org/bots/api#userprofilephotos + + :param total_count: Total number of profile pictures the target user has + :type total_count: :obj:`int` + + :param photos: Requested profile pictures (in up to 4 sizes each) + :type photos: :obj:`list` of :obj:`list` of :class:`telebot.types.PhotoSize` + + :return: Instance of the class + :rtype: :class:`telebot.types.UserProfilePhotos` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -971,6 +1812,30 @@ class UserProfilePhotos(JsonDeserializable): class File(JsonDeserializable): + """ + This object represents a file ready to be downloaded. The file can be downloaded via the link https://api.telegram.org/file/bot/. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile. + + Telegram Documentation: https://core.telegram.org/bots/api#file + + :param file_id: Identifier for this file, which can be used to download or reuse the file + :type file_id: :obj:`str` + + :param file_unique_id: Unique identifier for this file, which is supposed to be the same over time and for different + bots. Can't be used to download or reuse the file. + :type file_unique_id: :obj:`str` + + :param file_size: Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have + difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or + double-precision float type are safe for storing this value. + :type file_size: :obj:`int` + + :param file_path: Optional. File path. Use https://api.telegram.org/file/bot/ to get the + file. + :type file_path: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.File` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -985,6 +1850,27 @@ class File(JsonDeserializable): class ForceReply(JsonSerializable): + """ + 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. + + Telegram Documentation: https://core.telegram.org/bots/api#forcereply + + :param force_reply: Shows reply interface to the user, as if they manually selected the bot's message and tapped + 'Reply' + :type force_reply: :obj:`bool` + + :param input_field_placeholder: Optional. The placeholder to be shown in the input field when the reply is active; + 1-64 characters + :type input_field_placeholder: :obj:`str` + + :param selective: Optional. Use this parameter if you want to force reply from specific users only. Targets: 1) users + that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), + sender of the original message. + :type selective: :obj:`bool` + + :return: Instance of the class + :rtype: :class:`telebot.types.ForceReply` + """ def __init__(self, selective: Optional[bool]=None, input_field_placeholder: Optional[str]=None): self.selective: bool = selective self.input_field_placeholder: str = input_field_placeholder @@ -999,6 +1885,27 @@ class ForceReply(JsonSerializable): class ReplyKeyboardRemove(JsonSerializable): + """ + Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button (see ReplyKeyboardMarkup). + + Telegram Documentation: https://core.telegram.org/bots/api#replykeyboardremove + + :param remove_keyboard: Requests clients to remove the custom keyboard (user will not be able to summon this + keyboard; if you want to hide the keyboard from sight but keep it accessible, use one_time_keyboard in + ReplyKeyboardMarkup) + Note that this parameter is set to True by default by the library. You cannot modify it. + :type remove_keyboard: :obj:`bool` + + :param selective: Optional. Use this parameter if you want to remove the keyboard for specific users only. Targets: + 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has + reply_to_message_id), sender of the original message.Example: A user votes in a poll, bot returns confirmation + message in reply to the vote and removes the keyboard for that user, while still showing the keyboard with poll options + to users who haven't voted yet. + :type selective: :obj:`bool` + + :return: Instance of the class + :rtype: :class:`telebot.types.ReplyKeyboardRemove` + """ def __init__(self, selective=None): self.selective: bool = selective @@ -1010,6 +1917,17 @@ class ReplyKeyboardRemove(JsonSerializable): class WebAppInfo(JsonDeserializable): + """ + Describes a Web App. + + Telegram Documentation: https://core.telegram.org/bots/api#webappinfo + + :param url: An HTTPS URL of a Web App to be opened with additional data as specified in Initializing Web Apps + :type url: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.WebAppInfo` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -1024,6 +1942,51 @@ class WebAppInfo(JsonDeserializable): class ReplyKeyboardMarkup(JsonSerializable): + """ + This object represents a custom keyboard with reply options (see Introduction to bots for details and examples). + + .. code-block:: python3 + :caption: Example on creating ReplyKeyboardMarkup object + + from telebot.types import ReplyKeyboardMarkup, KeyboardButton + + markup = ReplyKeyboardMarkup(resize_keyboard=True) + markup.add(KeyboardButton('Text')) + # or: + markup.add('Text') + + # display this markup: + bot.send_message(chat_id, 'Text', reply_markup=markup) + + Telegram Documentation: https://core.telegram.org/bots/api#replykeyboardmarkup + + :param keyboard: :obj:`list` of button rows, each represented by an :obj:`list` of + :class:`telebot.types.KeyboardButton` objects + :type keyboard: :obj:`list` of :obj:`list` of :class:`telebot.types.KeyboardButton` + + :param resize_keyboard: Optional. Requests clients to resize the keyboard vertically for optimal fit (e.g., make + the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is + always of the same height as the app's standard keyboard. + :type resize_keyboard: :obj:`bool` + + :param one_time_keyboard: Optional. Requests clients to hide the keyboard as soon as it's been used. The keyboard + will still be available, but clients will automatically display the usual letter-keyboard in the chat - the user can + press a special button in the input field to see the custom keyboard again. Defaults to false. + :type one_time_keyboard: :obj:`bool` + + :param input_field_placeholder: Optional. The placeholder to be shown in the input field when the keyboard is + active; 1-64 characters + :type input_field_placeholder: :obj:`str` + + :param selective: Optional. Use this parameter if you want to show the keyboard to specific users only. Targets: 1) + users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has + reply_to_message_id), sender of the original message.Example: A user requests to change the bot's language, bot + replies to the request with a keyboard to select the new language. Other users in the group don't see the keyboard. + :type selective: :obj:`bool` + + :return: Instance of the class + :rtype: :class:`telebot.types.ReplyKeyboardMarkup` + """ max_row_keys = 12 def __init__(self, resize_keyboard: Optional[bool]=None, one_time_keyboard: Optional[bool]=None, @@ -1050,8 +2013,13 @@ class ReplyKeyboardMarkup(JsonSerializable): See https://core.telegram.org/bots/api#replykeyboardmarkup :param args: KeyboardButton to append to the keyboard + :type args: :obj:`str` or :class:`telebot.types.KeyboardButton` + :param row_width: width of row + :type row_width: :obj:`int` + :return: self, to allow function chaining. + :rtype: :class:`telebot.types.ReplyKeyboardMarkup` """ if row_width is None: row_width = self.row_width @@ -1082,7 +2050,10 @@ class ReplyKeyboardMarkup(JsonSerializable): See https://core.telegram.org/bots/api#replykeyboardmarkup :param args: strings + :type args: :obj:`str` + :return: self, to allow function chaining. + :rtype: :class:`telebot.types.ReplyKeyboardMarkup` """ return self.add(*args, row_width=self.max_row_keys) @@ -1106,6 +2077,18 @@ class ReplyKeyboardMarkup(JsonSerializable): class KeyboardButtonPollType(Dictionaryable): + """ + This object represents type of a poll, which is allowed to be created and sent when the corresponding button is pressed. + + Telegram Documentation: https://core.telegram.org/bots/api#keyboardbuttonpolltype + + :param type: Optional. If quiz is passed, the user will be allowed to create only polls in the quiz mode. If regular is + passed, only regular polls will be allowed. Otherwise, the user will be allowed to create a poll of any type. + :type type: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.KeyboardButtonPollType` + """ def __init__(self, type=''): self.type: str = type @@ -1114,6 +2097,34 @@ class KeyboardButtonPollType(Dictionaryable): class KeyboardButton(Dictionaryable, JsonSerializable): + """ + This object represents one button of the reply keyboard. For simple text buttons String can be used instead of this object to specify text of the button. Optional fields web_app, request_contact, request_location, and request_poll are mutually exclusive. + + Telegram Documentation: https://core.telegram.org/bots/api#keyboardbutton + + :param text: Text of the button. If none of the optional fields are used, it will be sent as a message when the button is + pressed + :type text: :obj:`str` + + :param request_contact: Optional. If True, the user's phone number will be sent as a contact when the button is + pressed. Available in private chats only. + :type request_contact: :obj:`bool` + + :param request_location: Optional. If True, the user's current location will be sent when the button is pressed. + Available in private chats only. + :type request_location: :obj:`bool` + + :param request_poll: Optional. If specified, the user will be asked to create a poll and send it to the bot when the + button is pressed. Available in private chats only. + :type request_poll: :class:`telebot.types.KeyboardButtonPollType` + + :param web_app: Optional. If specified, the described Web App will be launched when the button is pressed. The Web App + will be able to send a “web_app_data” service message. Available in private chats only. + :type web_app: :class:`telebot.types.WebAppInfo` + + :return: Instance of the class + :rtype: :class:`telebot.types.KeyboardButton` + """ def __init__(self, text: str, request_contact: Optional[bool]=None, request_location: Optional[bool]=None, request_poll: Optional[KeyboardButtonPollType]=None, web_app: WebAppInfo=None): @@ -1140,6 +2151,31 @@ class KeyboardButton(Dictionaryable, JsonSerializable): class InlineKeyboardMarkup(Dictionaryable, JsonSerializable, JsonDeserializable): + """ + This object represents an inline keyboard that appears right next to the message it belongs to. + + .. note:: + It is recommended to use :meth:`telebot.util.quick_markup` instead. + + .. code-block:: python3 + :caption: Example of a custom keyboard with buttons. + + from telebot.util import quick_markup + + markup = quick_markup( + {'text': 'Press me', 'callback_data': 'press'}, + {'text': 'Press me too', 'callback_data': 'press_too'} + ) + + Telegram Documentation: https://core.telegram.org/bots/api#inlinekeyboardmarkup + + :param inline_keyboard: :obj:`list` of button rows, each represented by an :obj:`list` of + :class:`telebot.types.InlineKeyboardButton` objects + :type inline_keyboard: :obj:`list` of :obj:`list` of :class:`telebot.types.InlineKeyboardButton` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineKeyboardMarkup` + """ max_row_keys = 8 @classmethod @@ -1150,12 +2186,6 @@ class InlineKeyboardMarkup(Dictionaryable, JsonSerializable, JsonDeserializable) return cls(keyboard = keyboard) def __init__(self, keyboard=None, row_width=3): - """ - This object represents an inline keyboard that appears - right next to the message it belongs to. - - :return: None - """ if row_width > self.max_row_keys: # Todo: Will be replaced with Exception in future releases logger.error('Telegram does not support inline keyboard row width over %d.' % self.max_row_keys) @@ -1176,8 +2206,13 @@ class InlineKeyboardMarkup(Dictionaryable, JsonSerializable, JsonDeserializable) See https://core.telegram.org/bots/api#inlinekeyboardmarkup :param args: Array of InlineKeyboardButton to append to the keyboard + :type args: :obj:`list` of :class:`telebot.types.InlineKeyboardButton` + :param row_width: width of row + :type row_width: :obj:`int` + :return: self, to allow function chaining. + :rtype: :class:`telebot.types.InlineKeyboardMarkup` """ if row_width is None: row_width = self.row_width @@ -1203,18 +2238,15 @@ class InlineKeyboardMarkup(Dictionaryable, JsonSerializable, JsonDeserializable) See https://core.telegram.org/bots/api#inlinekeyboardmarkup :param args: Array of InlineKeyboardButton to append to the keyboard + :type args: :obj:`list` of :class:`telebot.types.InlineKeyboardButton` + :return: self, to allow function chaining. + :rtype: :class:`telebot.types.InlineKeyboardMarkup` """ return self.add(*args, row_width=self.max_row_keys) def to_json(self): - """ - Converts this object to its json representation - following the Telegram API guidelines described here: - https://core.telegram.org/bots/api#inlinekeyboardmarkup - :return: - """ return json.dumps(self.to_dict()) def to_dict(self): @@ -1224,6 +2256,54 @@ class InlineKeyboardMarkup(Dictionaryable, JsonSerializable, JsonDeserializable) class InlineKeyboardButton(Dictionaryable, JsonSerializable, JsonDeserializable): + """ + This object represents one button of an inline keyboard. You must use exactly one of the optional fields. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinekeyboardbutton + + :param text: Label text on the button + :type text: :obj:`str` + + :param url: Optional. HTTP or tg:// URL to be opened when the button is pressed. Links tg://user?id= can be + used to mention a user by their ID without using a username, if this is allowed by their privacy settings. + :type url: :obj:`str` + + :param callback_data: Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes + :type callback_data: :obj:`str` + + :param web_app: Optional. Description of the Web App that will be launched when the user presses the button. The Web + App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Available only + in private chats between a user and the bot. + :type web_app: :class:`telebot.types.WebAppInfo` + + :param login_url: Optional. An HTTPS URL used to automatically authorize the user. Can be used as a replacement for + the Telegram Login Widget. + :type login_url: :class:`telebot.types.LoginUrl` + + :param switch_inline_query: Optional. If set, pressing the button will prompt the user to select one of their chats, + open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which + case just the bot's username will be inserted.Note: This offers an easy way for users to start using your bot in inline + mode when they are currently in a private chat with it. Especially useful when combined with switch_pm… actions - in + this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen. + :type switch_inline_query: :obj:`str` + + :param switch_inline_query_current_chat: Optional. If set, pressing the button will insert the bot's username + and the specified inline query in the current chat's input field. May be empty, in which case only the bot's username + will be inserted.This offers a quick way for the user to open your bot in inline mode in the same chat - good for selecting + something from multiple options. + :type switch_inline_query_current_chat: :obj:`str` + + :param callback_game: Optional. Description of the game that will be launched when the user presses the + button. NOTE: This type of button must always be the first button in the first row. + :type callback_game: :class:`telebot.types.CallbackGame` + + :param pay: Optional. Specify True, to send a Pay button. NOTE: This type of button must always be the first button in + the first row and can only be used in invoice messages. + :type pay: :obj:`bool` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineKeyboardButton` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -1272,6 +2352,33 @@ class InlineKeyboardButton(Dictionaryable, JsonSerializable, JsonDeserializable) class LoginUrl(Dictionaryable, JsonSerializable, JsonDeserializable): + """ + This object represents a parameter of the inline keyboard button used to automatically authorize a user. Serves as a great replacement for the Telegram Login Widget when the user is coming from Telegram. All the user needs to do is tap/click a button and confirm that they want to log in: + + Telegram Documentation: https://core.telegram.org/bots/api#loginurl + + :param url: An HTTPS URL to be opened with user authorization data added to the query string when the button is pressed. + If the user refuses to provide authorization data, the original URL without information about the user will be + opened. The data added is the same as described in Receiving authorization data. NOTE: You must always check the hash + of the received data to verify the authentication and the integrity of the data as described in Checking + authorization. + :type url: :obj:`str` + + :param forward_text: Optional. New text of the button in forwarded messages. + :type forward_text: :obj:`str` + + :param bot_username: Optional. Username of a bot, which will be used for user authorization. See Setting up a bot for + more details. If not specified, the current bot's username will be assumed. The url's domain must be the same as the + domain linked with the bot. See Linking your domain to the bot for more details. + :type bot_username: :obj:`str` + + :param request_write_access: Optional. Pass True to request the permission for your bot to send messages to the + user. + :type request_write_access: :obj:`bool` + + :return: Instance of the class + :rtype: :class:`telebot.types.LoginUrl` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -1299,6 +2406,39 @@ class LoginUrl(Dictionaryable, JsonSerializable, JsonDeserializable): class CallbackQuery(JsonDeserializable): + """ + 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. + + Telegram Documentation: https://core.telegram.org/bots/api#callbackquery + + :param id: Unique identifier for this query + :type id: :obj:`str` + + :param from_user: Sender + :type from_user: :class:`telebot.types.User` + + :param message: Optional. Message with the callback button that originated the query. Note that message content and + message date will not be available if the message is too old + :type message: :class:`telebot.types.Message` + + :param inline_message_id: Optional. Identifier of the message sent via the bot in inline mode, that originated the + query. + :type inline_message_id: :obj:`str` + + :param chat_instance: Global identifier, uniquely corresponding to the chat to which the message with the callback + button was sent. Useful for high scores in games. + :type chat_instance: :obj:`str` + + :param data: Optional. Data associated with the callback button. Be aware that the message originated the query can + contain no callback buttons with this data. + :type data: :obj:`str` + + :param game_short_name: Optional. Short name of a Game to be returned, serves as the unique identifier for the game + :type game_short_name: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.CallbackQuery` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -1324,6 +2464,30 @@ class CallbackQuery(JsonDeserializable): class ChatPhoto(JsonDeserializable): + """ + This object represents a chat photo. + + Telegram Documentation: https://core.telegram.org/bots/api#chatphoto + + :param small_file_id: File identifier of small (160x160) chat photo. This file_id can be used only for photo + download and only for as long as the photo is not changed. + :type small_file_id: :obj:`str` + + :param small_file_unique_id: Unique file identifier of small (160x160) chat photo, which is supposed to be the same + over time and for different bots. Can't be used to download or reuse the file. + :type small_file_unique_id: :obj:`str` + + :param big_file_id: File identifier of big (640x640) chat photo. This file_id can be used only for photo download and + only for as long as the photo is not changed. + :type big_file_id: :obj:`str` + + :param big_file_unique_id: Unique file identifier of big (640x640) chat photo, which is supposed to be the same over + time and for different bots. Can't be used to download or reuse the file. + :type big_file_unique_id: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.ChatPhoto` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -1338,6 +2502,20 @@ class ChatPhoto(JsonDeserializable): class ChatMember(JsonDeserializable): + """ + This object contains information about one member of a chat. + Currently, the following 6 types of chat members are supported: + + * :class:`telebot.types.ChatMemberOwner` + * :class:`telebot.types.ChatMemberAdministrator` + * :class:`telebot.types.ChatMemberMember` + * :class:`telebot.types.ChatMemberRestricted` + * :class:`telebot.types.ChatMemberLeft` + * :class:`telebot.types.ChatMemberBanned` + + Telegram Documentation: https://core.telegram.org/bots/api#chatmember + """ + @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -1395,30 +2573,238 @@ class ChatMember(JsonDeserializable): class ChatMemberOwner(ChatMember): + """ + Represents a chat member that owns the chat and has all administrator privileges. + + Telegram Documentation: https://core.telegram.org/bots/api#chatmemberowner + + :param status: The member's status in the chat, always “creator” + :type status: :obj:`str` + + :param user: Information about the user + :type user: :class:`telebot.types.User` + + :param is_anonymous: True, if the user's presence in the chat is hidden + :type is_anonymous: :obj:`bool` + + :param custom_title: Optional. Custom title for this user + :type custom_title: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.ChatMemberOwner` + """ pass class ChatMemberAdministrator(ChatMember): + """ + Represents a chat member that has some additional privileges. + + Telegram Documentation: https://core.telegram.org/bots/api#chatmemberadministrator + + :param status: The member's status in the chat, always “administrator” + :type status: :obj:`str` + + :param user: Information about the user + :type user: :class:`telebot.types.User` + + :param can_be_edited: True, if the bot is allowed to edit administrator privileges of that user + :type can_be_edited: :obj:`bool` + + :param is_anonymous: True, if the user's presence in the chat is hidden + :type is_anonymous: :obj:`bool` + + :param can_manage_chat: True, if the administrator can access the chat event log, chat statistics, message + statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. + Implied by any other administrator privilege + :type can_manage_chat: :obj:`bool` + + :param can_delete_messages: True, if the administrator can delete messages of other users + :type can_delete_messages: :obj:`bool` + + :param can_manage_video_chats: True, if the administrator can manage video chats + :type can_manage_video_chats: :obj:`bool` + + :param can_restrict_members: True, if the administrator can restrict, ban or unban chat members + :type can_restrict_members: :obj:`bool` + + :param can_promote_members: True, if the administrator can add new administrators with a subset of their own + privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that + were appointed by the user) + :type can_promote_members: :obj:`bool` + + :param can_change_info: True, if the user is allowed to change the chat title, photo and other settings + :type can_change_info: :obj:`bool` + + :param can_invite_users: True, if the user is allowed to invite new users to the chat + :type can_invite_users: :obj:`bool` + + :param can_post_messages: Optional. True, if the administrator can post in the channel; channels only + :type can_post_messages: :obj:`bool` + + :param can_edit_messages: Optional. True, if the administrator can edit messages of other users and can pin + messages; channels only + :type can_edit_messages: :obj:`bool` + + :param can_pin_messages: Optional. True, if the user is allowed to pin messages; groups and supergroups only + :type can_pin_messages: :obj:`bool` + + :param custom_title: Optional. Custom title for this user + :type custom_title: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.ChatMemberAdministrator` + """ pass class ChatMemberMember(ChatMember): + """ + Represents a chat member that has no additional privileges or restrictions. + + Telegram Documentation: https://core.telegram.org/bots/api#chatmembermember + + :param status: The member's status in the chat, always “member” + :type status: :obj:`str` + + :param user: Information about the user + :type user: :class:`telebot.types.User` + + :return: Instance of the class + :rtype: :class:`telebot.types.ChatMemberMember` + """ pass class ChatMemberRestricted(ChatMember): + """ + Represents a chat member that is under certain restrictions in the chat. Supergroups only. + + Telegram Documentation: https://core.telegram.org/bots/api#chatmemberrestricted + + :param status: The member's status in the chat, always “restricted” + :type status: :obj:`str` + + :param user: Information about the user + :type user: :class:`telebot.types.User` + + :param is_member: True, if the user is a member of the chat at the moment of the request + :type is_member: :obj:`bool` + + :param can_change_info: True, if the user is allowed to change the chat title, photo and other settings + :type can_change_info: :obj:`bool` + + :param can_invite_users: True, if the user is allowed to invite new users to the chat + :type can_invite_users: :obj:`bool` + + :param can_pin_messages: True, if the user is allowed to pin messages + :type can_pin_messages: :obj:`bool` + + :param can_send_messages: True, if the user is allowed to send text messages, contacts, locations and venues + :type can_send_messages: :obj:`bool` + + :param can_send_media_messages: True, if the user is allowed to send audios, documents, photos, videos, video + notes and voice notes + :type can_send_media_messages: :obj:`bool` + + :param can_send_polls: True, if the user is allowed to send polls + :type can_send_polls: :obj:`bool` + + :param can_send_other_messages: True, if the user is allowed to send animations, games, stickers and use inline + bots + :type can_send_other_messages: :obj:`bool` + + :param can_add_web_page_previews: True, if the user is allowed to add web page previews to their messages + :type can_add_web_page_previews: :obj:`bool` + + :param until_date: Date when restrictions will be lifted for this user; unix time. If 0, then the user is restricted + forever + :type until_date: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.ChatMemberRestricted` + """ pass class ChatMemberLeft(ChatMember): + """ + Represents a chat member that isn't currently a member of the chat, but may join it themselves. + + Telegram Documentation: https://core.telegram.org/bots/api#chatmemberleft + + :param status: The member's status in the chat, always “left” + :type status: :obj:`str` + + :param user: Information about the user + :type user: :class:`telebot.types.User` + + :return: Instance of the class + :rtype: :class:`telebot.types.ChatMemberLeft` + """ pass class ChatMemberBanned(ChatMember): + """ + Represents a chat member that was banned in the chat and can't return to the chat or view chat messages. + + Telegram Documentation: https://core.telegram.org/bots/api#chatmemberbanned + + :param status: The member's status in the chat, always “kicked” + :type status: :obj:`str` + + :param user: Information about the user + :type user: :class:`telebot.types.User` + + :param until_date: Date when restrictions will be lifted for this user; unix time. If 0, then the user is banned + forever + :type until_date: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.ChatMemberBanned` + """ pass class ChatPermissions(JsonDeserializable, JsonSerializable, Dictionaryable): + """ + Describes actions that a non-administrator user is allowed to take in a chat. + + Telegram Documentation: https://core.telegram.org/bots/api#chatpermissions + + :param can_send_messages: Optional. True, if the user is allowed to send text messages, contacts, locations and + venues + :type can_send_messages: :obj:`bool` + + :param can_send_media_messages: Optional. True, if the user is allowed to send audios, documents, photos, videos, + video notes and voice notes, implies can_send_messages + :type can_send_media_messages: :obj:`bool` + + :param can_send_polls: Optional. True, if the user is allowed to send polls, implies can_send_messages + :type can_send_polls: :obj:`bool` + + :param can_send_other_messages: Optional. True, if the user is allowed to send animations, games, stickers and use + inline bots, implies can_send_media_messages + :type can_send_other_messages: :obj:`bool` + + :param can_add_web_page_previews: Optional. True, if the user is allowed to add web page previews to their + messages, implies can_send_media_messages + :type can_add_web_page_previews: :obj:`bool` + + :param can_change_info: Optional. True, if the user is allowed to change the chat title, photo and other settings. + Ignored in public supergroups + :type can_change_info: :obj:`bool` + + :param can_invite_users: Optional. True, if the user is allowed to invite new users to the chat + :type can_invite_users: :obj:`bool` + + :param can_pin_messages: Optional. True, if the user is allowed to pin messages. Ignored in public supergroups + :type can_pin_messages: :obj:`bool` + + :return: Instance of the class + :rtype: :class:`telebot.types.ChatPermissions` + """ @classmethod def de_json(cls, json_string): if json_string is None: return json_string @@ -1463,6 +2849,21 @@ class ChatPermissions(JsonDeserializable, JsonSerializable, Dictionaryable): class BotCommand(JsonSerializable, JsonDeserializable): + """ + This object represents a bot command. + + Telegram Documentation: https://core.telegram.org/bots/api#botcommand + + :param command: Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and + underscores. + :type command: :obj:`str` + + :param description: Description of the command; 1-256 characters. + :type description: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.BotCommand` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -1470,13 +2871,6 @@ class BotCommand(JsonSerializable, JsonDeserializable): return cls(**obj) def __init__(self, command, description): - """ - This object represents a bot command. - :param command: Text of the command, 1-32 characters. - Can contain only lowercase English letters, digits and underscores. - :param description: Description of the command, 3-256 characters. - :return: - """ self.command: str = command self.description: str = description @@ -1490,18 +2884,48 @@ class BotCommand(JsonSerializable, JsonDeserializable): # BotCommandScopes class BotCommandScope(ABC, JsonSerializable): + """ + This object represents the scope to which bot commands are applied. Currently, the following 7 scopes are supported: + + * :class:`BotCommandScopeDefault` + * :class:`BotCommandScopeAllPrivateChats` + * :class:`BotCommandScopeAllGroupChats` + * :class:`BotCommandScopeAllChatAdministrators` + * :class:`BotCommandScopeChat` + * :class:`BotCommandScopeChatAdministrators` + * :class:`BotCommandScopeChatMember` + + Determining list of commands + The following algorithm is used to determine the list of commands for a particular user viewing the bot menu. The first list of commands which is set is returned: + + Commands in the chat with the bot: + + * :class:`BotCommandScopeChat` + language_code + * :class:`BotCommandScopeChat` + * :class:`BotCommandScopeAllPrivateChats` + language_code + * :class:`BotCommandScopeAllPrivateChats` + * :class:`BotCommandScopeDefault` + language_code + * :class:`BotCommandScopeDefault` + + Commands in group and supergroup chats: + + * :class:`BotCommandScopeChatMember` + language_code + * :class:`BotCommandScopeChatMember` + * :class:`BotCommandScopeChatAdministrators` + language_code (administrators only) + * :class:`BotCommandScopeChatAdministrators` (administrators only) + * :class:`BotCommandScopeChat` + language_code + * :class:`BotCommandScopeChat` + * :class:`BotCommandScopeAllChatAdministrators` + language_code (administrators only) + * :class:`BotCommandScopeAllChatAdministrators` (administrators only) + * :class:`BotCommandScopeAllGroupChats` + language_code + * :class:`BotCommandScopeAllGroupChats` + * :class:`BotCommandScopeDefault` + language_code + * :class:`BotCommandScopeDefault` + + :return: Instance of the class + :rtype: :class:`telebot.types.BotCommandScope` + """ def __init__(self, type='default', chat_id=None, user_id=None): - """ - Abstract class. - Use BotCommandScopeX classes to set a specific scope type: - BotCommandScopeDefault - BotCommandScopeAllPrivateChats - BotCommandScopeAllGroupChats - BotCommandScopeAllChatAdministrators - BotCommandScopeChat - BotCommandScopeChatAdministrators - BotCommandScopeChatMember - """ self.type: str = type self.chat_id: Optional[Union[int, str]] = chat_id self.user_id: Optional[Union[int, str]] = user_id @@ -1516,6 +2940,17 @@ class BotCommandScope(ABC, JsonSerializable): class BotCommandScopeDefault(BotCommandScope): + """ + Represents the default scope of bot commands. Default commands are used if no commands with a narrower scope are specified for the user. + + Telegram Documentation: https://core.telegram.org/bots/api#botcommandscopedefault + + :param type: Scope type, must be default + :type type: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.BotCommandScopeDefault` + """ def __init__(self): """ Represents the default scope of bot commands. @@ -1525,6 +2960,17 @@ class BotCommandScopeDefault(BotCommandScope): class BotCommandScopeAllPrivateChats(BotCommandScope): + """ + Represents the scope of bot commands, covering all private chats. + + Telegram Documentation: https://core.telegram.org/bots/api#botcommandscopeallprivatechats + + :param type: Scope type, must be all_private_chats + :type type: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.BotCommandScopeAllPrivateChats` + """ def __init__(self): """ Represents the scope of bot commands, covering all private chats. @@ -1533,6 +2979,17 @@ class BotCommandScopeAllPrivateChats(BotCommandScope): class BotCommandScopeAllGroupChats(BotCommandScope): + """ + Represents the scope of bot commands, covering all group and supergroup chats. + + Telegram Documentation: https://core.telegram.org/bots/api#botcommandscopeallgroupchats + + :param type: Scope type, must be all_group_chats + :type type: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.BotCommandScopeAllGroupChats` + """ def __init__(self): """ Represents the scope of bot commands, covering all group and supergroup chats. @@ -1541,6 +2998,17 @@ class BotCommandScopeAllGroupChats(BotCommandScope): class BotCommandScopeAllChatAdministrators(BotCommandScope): + """ + Represents the scope of bot commands, covering all group and supergroup chat administrators. + + Telegram Documentation: https://core.telegram.org/bots/api#botcommandscopeallchatadministrators + + :param type: Scope type, must be all_chat_administrators + :type type: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.BotCommandScopeAllChatAdministrators` + """ def __init__(self): """ Represents the scope of bot commands, covering all group and supergroup chat administrators. @@ -1549,32 +3017,100 @@ class BotCommandScopeAllChatAdministrators(BotCommandScope): class BotCommandScopeChat(BotCommandScope): + """ + Represents the scope of bot commands, covering a specific chat. + + Telegram Documentation: https://core.telegram.org/bots/api#botcommandscopechat + + :param type: Scope type, must be chat + :type type: :obj:`str` + + :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format + @supergroupusername) + :type chat_id: :obj:`int` or :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.BotCommandScopeChat` + """ def __init__(self, chat_id=None): super(BotCommandScopeChat, self).__init__(type='chat', chat_id=chat_id) class BotCommandScopeChatAdministrators(BotCommandScope): + """ + Represents the scope of bot commands, covering all administrators of a specific group or supergroup chat. + + Telegram Documentation: https://core.telegram.org/bots/api#botcommandscopechatadministrators + + :param type: Scope type, must be chat_administrators + :type type: :obj:`str` + + :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format + @supergroupusername) + :type chat_id: :obj:`int` or :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.BotCommandScopeChatAdministrators` + """ def __init__(self, chat_id=None): - """ - Represents the scope of bot commands, covering a specific chat. - @param chat_id: Unique identifier for the target chat - """ super(BotCommandScopeChatAdministrators, self).__init__(type='chat_administrators', chat_id=chat_id) class BotCommandScopeChatMember(BotCommandScope): + """ + Represents the scope of bot commands, covering a specific member of a group or supergroup chat. + + Telegram Documentation: https://core.telegram.org/bots/api#botcommandscopechatmember + + :param type: Scope type, must be chat_member + :type type: :obj:`str` + + :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format + @supergroupusername) + :type chat_id: :obj:`int` or :obj:`str` + + :param user_id: Unique identifier of the target user + :type user_id: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.BotCommandScopeChatMember` + """ def __init__(self, chat_id=None, user_id=None): - """ - Represents the scope of bot commands, covering all administrators of a specific group or supergroup chat - @param chat_id: Unique identifier for the target chat - @param user_id: Unique identifier of the target user - """ super(BotCommandScopeChatMember, self).__init__(type='chat_member', chat_id=chat_id, user_id=user_id) # InlineQuery class InlineQuery(JsonDeserializable): + """ + This object represents an incoming inline query. When the user sends an empty query, your bot could return some default or trending results. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequery + + :param id: Unique identifier for this query + :type id: :obj:`str` + + :param from_user: Sender + :type from_user: :class:`telebot.types.User` + + :param query: Text of the query (up to 256 characters) + :type query: :obj:`str` + + :param offset: Offset of the results to be returned, can be controlled by the bot + :type offset: :obj:`str` + + :param chat_type: Optional. Type of the chat from which the inline query was sent. Can be either “sender” for a private + chat with the inline query sender, “private”, “group”, “supergroup”, or “channel”. The chat type should be always + known for requests sent from official clients and most third-party clients, unless the request was sent from a secret + chat + :type chat_type: :obj:`str` + + :param location: Optional. Sender location, only for bots that request user location + :type location: :class:`telebot.types.Location` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQuery` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -1585,20 +3121,6 @@ class InlineQuery(JsonDeserializable): return cls(**obj) def __init__(self, id, from_user, query, offset, chat_type=None, location=None, **kwargs): - """ - This object represents an incoming inline query. - When the user sends an empty query, your bot could - return some default or trending results. - :param id: string Unique identifier for this query - :param from_user: User Sender - :param query: String Text of the query - :param chat_type: String Type of the chat, from which the inline query was sent. - Can be either “sender” for a private chat with the inline query sender, - “private”, “group”, “supergroup”, or “channel”. - :param offset: String Offset of the results to be returned, can be controlled by the bot - :param location: Sender location, only for bots that request user location - :return: InlineQuery Object - """ self.id: int = id self.from_user: User = from_user self.query: str = query @@ -1608,6 +3130,28 @@ class InlineQuery(JsonDeserializable): class InputTextMessageContent(Dictionaryable): + """ + Represents the content of a text message to be sent as the result of an inline query. + + Telegram Documentation: https://core.telegram.org/bots/api#inputtextmessagecontent + + :param message_text: Text of the message to be sent, 1-4096 characters + :type message_text: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the message text. See formatting options for more + details. + :type parse_mode: :obj:`str` + + :param entities: Optional. List of special entities that appear in message text, which can be specified instead of + parse_mode + :type entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param disable_web_page_preview: Optional. Disables link previews for links in the sent message + :type disable_web_page_preview: :obj:`bool` + + :return: Instance of the class + :rtype: :class:`telebot.types.InputTextMessageContent` + """ def __init__(self, message_text, parse_mode=None, entities=None, disable_web_page_preview=None): self.message_text: str = message_text self.parse_mode: str = parse_mode @@ -1626,6 +3170,35 @@ class InputTextMessageContent(Dictionaryable): class InputLocationMessageContent(Dictionaryable): + """ + Represents the content of a location message to be sent as the result of an inline query. + + Telegram Documentation: https://core.telegram.org/bots/api#inputlocationmessagecontent + + :param latitude: Latitude of the location in degrees + :type latitude: :obj:`float` + + :param longitude: Longitude of the location in degrees + :type longitude: :obj:`float` + + :param horizontal_accuracy: Optional. The radius of uncertainty for the location, measured in meters; 0-1500 + :type horizontal_accuracy: :obj:`float` number + + :param live_period: Optional. Period in seconds for which the location can be updated, should be between 60 and + 86400. + :type live_period: :obj:`int` + + :param heading: Optional. For live locations, a direction in which the user is moving, in degrees. Must be between 1 + and 360 if specified. + :type heading: :obj:`int` + + :param proximity_alert_radius: 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. + :type proximity_alert_radius: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.InputLocationMessageContent` + """ def __init__(self, latitude, longitude, horizontal_accuracy=None, live_period=None, heading=None, proximity_alert_radius=None): self.latitude: float = latitude self.longitude: float = longitude @@ -1648,6 +3221,39 @@ class InputLocationMessageContent(Dictionaryable): class InputVenueMessageContent(Dictionaryable): + """ + Represents the content of a venue message to be sent as the result of an inline query. + + Telegram Documentation: https://core.telegram.org/bots/api#inputvenuemessagecontent + + :param latitude: Latitude of the venue in degrees + :type latitude: :obj:`float` + + :param longitude: Longitude of the venue in degrees + :type longitude: :obj:`float` + + :param title: Name of the venue + :type title: :obj:`str` + + :param address: Address of the venue + :type address: :obj:`str` + + :param foursquare_id: Optional. Foursquare identifier of the venue, if known + :type foursquare_id: :obj:`str` + + :param foursquare_type: Optional. Foursquare type of the venue, if known. (For example, + “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) + :type foursquare_type: :obj:`str` + + :param google_place_id: Optional. Google Places identifier of the venue + :type google_place_id: :obj:`str` + + :param google_place_type: Optional. Google Places type of the venue. (See supported types.) + :type google_place_type: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.InputVenueMessageContent` + """ def __init__(self, latitude, longitude, title, address, foursquare_id=None, foursquare_type=None, google_place_id=None, google_place_type=None): self.latitude: float = latitude @@ -1678,6 +3284,26 @@ class InputVenueMessageContent(Dictionaryable): class InputContactMessageContent(Dictionaryable): + """ + Represents the content of a contact message to be sent as the result of an inline query. + + Telegram Documentation: https://core.telegram.org/bots/api#inputcontactmessagecontent + + :param phone_number: Contact's phone number + :type phone_number: :obj:`str` + + :param first_name: Contact's first name + :type first_name: :obj:`str` + + :param last_name: Optional. Contact's last name + :type last_name: :obj:`str` + + :param vcard: Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes + :type vcard: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.InputContactMessageContent` + """ def __init__(self, phone_number, first_name, last_name=None, vcard=None): self.phone_number: str = phone_number self.first_name: str = first_name @@ -1694,6 +3320,84 @@ class InputContactMessageContent(Dictionaryable): class InputInvoiceMessageContent(Dictionaryable): + """ + Represents the content of an invoice message to be sent as the result of an inline query. + + Telegram Documentation: https://core.telegram.org/bots/api#inputinvoicemessagecontent + + :param title: Product name, 1-32 characters + :type title: :obj:`str` + + :param description: Product description, 1-255 characters + :type description: :obj:`str` + + :param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your + internal processes. + :type payload: :obj:`str` + + :param provider_token: Payment provider token, obtained via @BotFather + :type provider_token: :obj:`str` + + :param currency: Three-letter ISO 4217 currency code, see more on currencies + :type currency: :obj:`str` + + :param prices: Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery + cost, delivery tax, bonus, etc.) + :type prices: :obj:`list` of :class:`telebot.types.LabeledPrice` + + :param max_tip_amount: Optional. The maximum accepted amount for tips in the smallest units of the currency + (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass 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 + :type max_tip_amount: :obj:`int` + + :param suggested_tip_amounts: Optional. A JSON-serialized array of suggested amounts of tip 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. + :type suggested_tip_amounts: :obj:`list` of :obj:`int` + + :param provider_data: Optional. A JSON-serialized object for data about the invoice, which will be shared with the + payment provider. A detailed description of the required fields should be provided by the payment provider. + :type provider_data: :obj:`str` + + :param photo_url: Optional. URL of the product photo for the invoice. Can be a photo of the goods or a marketing image + for a service. + :type photo_url: :obj:`str` + + :param photo_size: Optional. Photo size in bytes + :type photo_size: :obj:`int` + + :param photo_width: Optional. Photo width + :type photo_width: :obj:`int` + + :param photo_height: Optional. Photo height + :type photo_height: :obj:`int` + + :param need_name: Optional. Pass True, if you require the user's full name to complete the order + :type need_name: :obj:`bool` + + :param need_phone_number: Optional. Pass True, if you require the user's phone number to complete the order + :type need_phone_number: :obj:`bool` + + :param need_email: Optional. Pass True, if you require the user's email address to complete the order + :type need_email: :obj:`bool` + + :param need_shipping_address: Optional. Pass True, if you require the user's shipping address to complete the + order + :type need_shipping_address: :obj:`bool` + + :param send_phone_number_to_provider: Optional. Pass True, if the user's phone number should be sent to provider + :type send_phone_number_to_provider: :obj:`bool` + + :param send_email_to_provider: Optional. Pass True, if the user's email address should be sent to provider + :type send_email_to_provider: :obj:`bool` + + :param is_flexible: Optional. Pass True, if the final price depends on the shipping method + :type is_flexible: :obj:`bool` + + :return: Instance of the class + :rtype: :class:`telebot.types.InputInvoiceMessageContent` + """ def __init__(self, title, description, payload, provider_token, currency, prices, max_tip_amount=None, suggested_tip_amounts=None, provider_data=None, photo_url=None, photo_size=None, photo_width=None, photo_height=None, @@ -1762,6 +3466,30 @@ class InputInvoiceMessageContent(Dictionaryable): class ChosenInlineResult(JsonDeserializable): + """ + Represents a result of an inline query that was chosen by the user and sent to their chat partner. + + Telegram Documentation: https://core.telegram.org/bots/api#choseninlineresult + + :param result_id: The unique identifier for the result that was chosen + :type result_id: :obj:`str` + + :param from: The user that chose the result + :type from: :class:`telebot.types.User` + + :param location: Optional. Sender location, only for bots that require user location + :type location: :class:`telebot.types.Location` + + :param inline_message_id: Optional. Identifier of the sent inline message. Available only if there is an inline + keyboard attached to the message. Will be also received in callback queries and can be used to edit the message. + :type inline_message_id: :obj:`str` + + :param query: The query that was used to obtain the result + :type query: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.ChosenInlineResult` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -1772,14 +3500,6 @@ class ChosenInlineResult(JsonDeserializable): return cls(**obj) def __init__(self, result_id, from_user, query, location=None, inline_message_id=None, **kwargs): - """ - This object represents a result of an inline query - that was chosen by the user and sent to their chat partner. - :param result_id: string The unique identifier for the result that was chosen. - :param from_user: User The user that chose the result. - :param query: String The query that was used to obtain the result. - :return: ChosenInlineResult Object. - """ self.result_id: str = result_id self.from_user: User = from_user self.location: Location = location @@ -1788,6 +3508,32 @@ class ChosenInlineResult(JsonDeserializable): class InlineQueryResultBase(ABC, Dictionaryable, JsonSerializable): + """ + This object represents one result of an inline query. Telegram clients currently support results of the following 20 types: + + * :class:`InlineQueryResultCachedAudio` + * :class:`InlineQueryResultCachedDocument` + * :class:`InlineQueryResultCachedGif` + * :class:`InlineQueryResultCachedMpeg4Gif` + * :class:`InlineQueryResultCachedPhoto` + * :class:`InlineQueryResultCachedSticker` + * :class:`InlineQueryResultCachedVideo` + * :class:`InlineQueryResultCachedVoice` + * :class:`InlineQueryResultArticle` + * :class:`InlineQueryResultAudio` + * :class:`InlineQueryResultContact` + * :class:`InlineQueryResultGame` + * :class:`InlineQueryResultDocument` + * :class:`InlineQueryResultGif` + * :class:`InlineQueryResultLocation` + * :class:`InlineQueryResultMpeg4Gif` + * :class:`InlineQueryResultPhoto` + * :class:`InlineQueryResultVenue` + * :class:`InlineQueryResultVideo` + * :class:`InlineQueryResultVoice` + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresult + """ # noinspection PyShadowingBuiltins def __init__(self, type, id, title = None, caption = None, input_message_content = None, reply_markup = None, caption_entities = None, parse_mode = None): @@ -1824,6 +3570,18 @@ class InlineQueryResultBase(ABC, Dictionaryable, JsonSerializable): class SentWebAppMessage(JsonDeserializable): + """ + Describes an inline message sent by a Web App on behalf of a user. + + Telegram Documentation: https://core.telegram.org/bots/api#sentwebappmessage + + :param inline_message_id: Optional. Identifier of the sent inline message. Available only if there is an inline + keyboard attached to the message. + :type inline_message_id: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.SentWebAppMessage` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -1839,27 +3597,51 @@ class SentWebAppMessage(JsonDeserializable): json_dict['inline_message_id'] = self.inline_message_id return json_dict - - - class InlineQueryResultArticle(InlineQueryResultBase): + """ + Represents a link to an article or web page. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultarticle + + :param type: Type of the result, must be article + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 Bytes + :type id: :obj:`str` + + :param title: Title of the result + :type title: :obj:`str` + + :param input_message_content: Content of the message to be sent + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param url: Optional. URL of the result + :type url: :obj:`str` + + :param hide_url: Optional. Pass True, if you don't want the URL to be shown in the message + :type hide_url: :obj:`bool` + + :param description: Optional. Short description of the result + :type description: :obj:`str` + + :param thumb_url: Optional. Url of the thumbnail for the result + :type thumb_url: :obj:`str` + + :param thumb_width: Optional. Thumbnail width + :type thumb_width: :obj:`int` + + :param thumb_height: Optional. Thumbnail height + :type thumb_height: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultArticle` + """ def __init__(self, id, title, input_message_content, reply_markup=None, url=None, hide_url=None, description=None, thumb_url=None, thumb_width=None, thumb_height=None): - """ - Represents a link to an article or web page. - :param id: Unique identifier for this result, 1-64 Bytes. - :param title: Title of the result. - :param input_message_content: InputMessageContent : Content of the message to be sent - :param reply_markup: InlineKeyboardMarkup : Inline keyboard attached to the message - :param url: URL of the result. - :param hide_url: Pass True, if you don't want the URL to be shown in the message. - :param description: Short description of the result. - :param thumb_url: Url of the thumbnail for the result. - :param thumb_width: Thumbnail width. - :param thumb_height: Thumbnail height - :return: - """ super().__init__('article', id, title = title, input_message_content = input_message_content, reply_markup = reply_markup) self.url = url self.hide_url = hide_url @@ -1886,24 +3668,57 @@ class InlineQueryResultArticle(InlineQueryResultBase): class InlineQueryResultPhoto(InlineQueryResultBase): + """ + Represents a link to a photo. By default, this photo will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultphoto + + :param type: Type of the result, must be photo + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 bytes + :type id: :obj:`str` + + :param photo_url: A valid URL of the photo. Photo must be in JPEG format. Photo size must not exceed 5MB + :type photo_url: :obj:`str` + + :param thumb_url: URL of the thumbnail for the photo + :type thumb_url: :obj:`str` + + :param photo_width: Optional. Width of the photo + :type photo_width: :obj:`int` + + :param photo_height: Optional. Height of the photo + :type photo_height: :obj:`int` + + :param title: Optional. Title for the result + :type title: :obj:`str` + + :param description: Optional. Short description of the result + :type description: :obj:`str` + + :param caption: Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the photo caption. See formatting options for more + details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param input_message_content: Optional. Content of the message to be sent instead of the photo + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultPhoto` + """ def __init__(self, id, photo_url, thumb_url, photo_width=None, photo_height=None, title=None, description=None, caption=None, caption_entities=None, parse_mode=None, reply_markup=None, input_message_content=None): - """ - Represents a link to a photo. - :param id: Unique identifier for this result, 1-64 bytes - :param photo_url: A valid URL of the photo. Photo must be in jpeg format. Photo size must not exceed 5MB - :param thumb_url: URL of the thumbnail for the photo - :param photo_width: Width of the photo. - :param photo_height: Height of the photo. - :param title: Title for the result. - :param description: Short description of the result. - :param caption: Caption of the photo to be sent, 0-200 characters. - :param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or - inline URLs in the media caption. - :param reply_markup: InlineKeyboardMarkup : Inline keyboard attached to the message - :param input_message_content: InputMessageContent : Content of the message to be sent instead of the photo - :return: - """ super().__init__('photo', id, title = title, caption = caption, input_message_content = input_message_content, reply_markup = reply_markup, parse_mode = parse_mode, caption_entities = caption_entities) @@ -1927,23 +3742,62 @@ class InlineQueryResultPhoto(InlineQueryResultBase): class InlineQueryResultGif(InlineQueryResultBase): + """ + Represents a link to an animated GIF file. By default, this animated GIF file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultgif + + :param type: Type of the result, must be gif + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 bytes + :type id: :obj:`str` + + :param gif_url: A valid URL for the GIF file. File size must not exceed 1MB + :type gif_url: :obj:`str` + + :param gif_width: Optional. Width of the GIF + :type gif_width: :obj:`int` + + :param gif_height: Optional. Height of the GIF + :type gif_height: :obj:`int` + + :param gif_duration: Optional. Duration of the GIF in seconds + :type gif_duration: :obj:`int` + + :param thumb_url: URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result + :type thumb_url: :obj:`str` + + :param thumb_mime_type: Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or + “video/mp4”. Defaults to “image/jpeg” + :type thumb_mime_type: :obj:`str` + + :param title: Optional. Title for the result + :type title: :obj:`str` + + :param caption: Optional. Caption of the GIF file to be sent, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the caption. See formatting options for more details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param input_message_content: Optional. Content of the message to be sent instead of the GIF animation + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultGif` + """ def __init__(self, id, gif_url, thumb_url, gif_width=None, gif_height=None, title=None, caption=None, caption_entities=None, reply_markup=None, input_message_content=None, gif_duration=None, parse_mode=None, thumb_mime_type=None): - """ - Represents a link to an animated GIF file. - :param id: Unique identifier for this result, 1-64 bytes. - :param gif_url: A valid URL for the GIF file. File size must not exceed 1MB - :param thumb_url: URL of the static thumbnail (jpeg or gif) for the result. - :param gif_width: Width of the GIF. - :param gif_height: Height of the GIF. - :param title: Title for the result. - :param caption: Caption of the GIF file to be sent, 0-200 characters - :param reply_markup: InlineKeyboardMarkup : Inline keyboard attached to the message - :param input_message_content: InputMessageContent : Content of the message to be sent instead of the photo - :return: - """ super().__init__('gif', id, title = title, caption = caption, input_message_content = input_message_content, reply_markup = reply_markup, parse_mode = parse_mode, caption_entities = caption_entities) @@ -1970,25 +3824,62 @@ class InlineQueryResultGif(InlineQueryResultBase): class InlineQueryResultMpeg4Gif(InlineQueryResultBase): + """ + Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). By default, this animated MPEG-4 file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif + + :param type: Type of the result, must be mpeg4_gif + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 bytes + :type id: :obj:`str` + + :param mpeg4_url: A valid URL for the MPEG4 file. File size must not exceed 1MB + :type mpeg4_url: :obj:`str` + + :param mpeg4_width: Optional. Video width + :type mpeg4_width: :obj:`int` + + :param mpeg4_height: Optional. Video height + :type mpeg4_height: :obj:`int` + + :param mpeg4_duration: Optional. Video duration in seconds + :type mpeg4_duration: :obj:`int` + + :param thumb_url: URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result + :type thumb_url: :obj:`str` + + :param thumb_mime_type: Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or + “video/mp4”. Defaults to “image/jpeg” + :type thumb_mime_type: :obj:`str` + + :param title: Optional. Title for the result + :type title: :obj:`str` + + :param caption: Optional. Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the caption. See formatting options for more details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param input_message_content: Optional. Content of the message to be sent instead of the video animation + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultMpeg4Gif` + """ def __init__(self, id, mpeg4_url, thumb_url, mpeg4_width=None, mpeg4_height=None, title=None, caption=None, caption_entities=None, parse_mode=None, reply_markup=None, input_message_content=None, mpeg4_duration=None, thumb_mime_type=None): - """ - Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). - :param id: Unique identifier for this result, 1-64 bytes - :param mpeg4_url: A valid URL for the MP4 file. File size must not exceed 1MB - :param thumb_url: URL of the static thumbnail (jpeg or gif) for the result - :param mpeg4_width: Video width - :param mpeg4_height: Video height - :param title: Title for the result - :param caption: Caption of the MPEG-4 file to be sent, 0-200 characters - :param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text - or inline URLs in the media caption. - :param reply_markup: InlineKeyboardMarkup : Inline keyboard attached to the message - :param input_message_content: InputMessageContent : Content of the message to be sent instead of the photo - :return: - """ super().__init__('mpeg4_gif', id, title = title, caption = caption, input_message_content = input_message_content, reply_markup = reply_markup, parse_mode = parse_mode, caption_entities = caption_entities) @@ -2015,25 +3906,66 @@ class InlineQueryResultMpeg4Gif(InlineQueryResultBase): class InlineQueryResultVideo(InlineQueryResultBase): + """ + Represents a link to a page containing an embedded video player or a video file. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultvideo + + :param type: Type of the result, must be video + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 bytes + :type id: :obj:`str` + + :param video_url: A valid URL for the embedded video player or video file + :type video_url: :obj:`str` + + :param mime_type: MIME type of the content of the video URL, “text/html” or “video/mp4” + :type mime_type: :obj:`str` + + :param thumb_url: URL of the thumbnail (JPEG only) for the video + :type thumb_url: :obj:`str` + + :param title: Title for the result + :type title: :obj:`str` + + :param caption: Optional. Caption of the video to be sent, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the video caption. See formatting options for more + details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param video_width: Optional. Video width + :type video_width: :obj:`int` + + :param video_height: Optional. Video height + :type video_height: :obj:`int` + + :param video_duration: Optional. Video duration in seconds + :type video_duration: :obj:`int` + + :param description: Optional. Short description of the result + :type description: :obj:`str` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param input_message_content: 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). + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultVideo` + """ def __init__(self, id, video_url, mime_type, thumb_url, title, caption=None, caption_entities=None, parse_mode=None, video_width=None, video_height=None, video_duration=None, description=None, reply_markup=None, input_message_content=None): - """ - Represents link to a page containing an embedded video player or a video file. - :param id: Unique identifier for this result, 1-64 bytes - :param video_url: A valid URL for the embedded video player or video file - :param mime_type: Mime type of the content of video url, “text/html” or “video/mp4” - :param thumb_url: URL of the thumbnail (jpeg only) for the video - :param title: Title for the result - :param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or - inline URLs in the media caption. - :param video_width: Video width - :param video_height: Video height - :param video_duration: Video duration in seconds - :param description: Short description of the result - :return: - """ super().__init__('video', id, title = title, caption = caption, input_message_content = input_message_content, reply_markup = reply_markup, parse_mode = parse_mode, caption_entities = caption_entities) @@ -2060,6 +3992,49 @@ class InlineQueryResultVideo(InlineQueryResultBase): class InlineQueryResultAudio(InlineQueryResultBase): + """ + Represents a link to an MP3 audio file. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultaudio + + :param type: Type of the result, must be audio + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 bytes + :type id: :obj:`str` + + :param audio_url: A valid URL for the audio file + :type audio_url: :obj:`str` + + :param title: Title + :type title: :obj:`str` + + :param caption: Optional. Caption, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the audio caption. See formatting options for more + details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param performer: Optional. Performer + :type performer: :obj:`str` + + :param audio_duration: Optional. Audio duration in seconds + :type audio_duration: :obj:`int` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param input_message_content: Optional. Content of the message to be sent instead of the audio + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultAudio` + """ def __init__(self, id, audio_url, title, caption=None, caption_entities=None, parse_mode=None, performer=None, audio_duration=None, reply_markup=None, input_message_content=None): @@ -2081,6 +4056,46 @@ class InlineQueryResultAudio(InlineQueryResultBase): class InlineQueryResultVoice(InlineQueryResultBase): + """ + Represents a link to a voice recording in an .OGG container encoded with OPUS. By default, this voice recording will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the the voice message. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultvoice + + :param type: Type of the result, must be voice + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 bytes + :type id: :obj:`str` + + :param voice_url: A valid URL for the voice recording + :type voice_url: :obj:`str` + + :param title: Recording title + :type title: :obj:`str` + + :param caption: Optional. Caption, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the voice message caption. See formatting options for + more details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param voice_duration: Optional. Recording duration in seconds + :type voice_duration: :obj:`int` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param input_message_content: Optional. Content of the message to be sent instead of the voice recording + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultVoice` + """ def __init__(self, id, voice_url, title, caption=None, caption_entities=None, parse_mode=None, voice_duration=None, reply_markup=None, input_message_content=None): super().__init__('voice', id, title = title, caption = caption, @@ -2098,6 +4113,58 @@ class InlineQueryResultVoice(InlineQueryResultBase): class InlineQueryResultDocument(InlineQueryResultBase): + """ + Represents a link to a file. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. Currently, only .PDF and .ZIP files can be sent using this method. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultdocument + + :param type: Type of the result, must be document + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 bytes + :type id: :obj:`str` + + :param title: Title for the result + :type title: :obj:`str` + + :param caption: Optional. Caption of the document to be sent, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the document caption. See formatting options for more + details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param document_url: A valid URL for the file + :type document_url: :obj:`str` + + :param mime_type: MIME type of the content of the file, either “application/pdf” or “application/zip” + :type mime_type: :obj:`str` + + :param description: Optional. Short description of the result + :type description: :obj:`str` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param input_message_content: Optional. Content of the message to be sent instead of the file + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :param thumb_url: Optional. URL of the thumbnail (JPEG only) for the file + :type thumb_url: :obj:`str` + + :param thumb_width: Optional. Thumbnail width + :type thumb_width: :obj:`int` + + :param thumb_height: Optional. Thumbnail height + :type thumb_height: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultDocument` + """ def __init__(self, id, title, document_url, mime_type, caption=None, caption_entities=None, parse_mode=None, description=None, reply_markup=None, input_message_content=None, thumb_url=None, thumb_width=None, thumb_height=None): @@ -2127,6 +4194,59 @@ class InlineQueryResultDocument(InlineQueryResultBase): class InlineQueryResultLocation(InlineQueryResultBase): + """ + Represents a location on a map. By default, the location will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the location. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultlocation + + :param type: Type of the result, must be location + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 Bytes + :type id: :obj:`str` + + :param latitude: Location latitude in degrees + :type latitude: :obj:`float` number + + :param longitude: Location longitude in degrees + :type longitude: :obj:`float` number + + :param title: Location title + :type title: :obj:`str` + + :param horizontal_accuracy: Optional. The radius of uncertainty for the location, measured in meters; 0-1500 + :type horizontal_accuracy: :obj:`float` number + + :param live_period: Optional. Period in seconds for which the location can be updated, should be between 60 and + 86400. + :type live_period: :obj:`int` + + :param heading: Optional. For live locations, a direction in which the user is moving, in degrees. Must be between 1 + and 360 if specified. + :type heading: :obj:`int` + + :param proximity_alert_radius: 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. + :type proximity_alert_radius: :obj:`int` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param input_message_content: Optional. Content of the message to be sent instead of the location + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :param thumb_url: Optional. Url of the thumbnail for the result + :type thumb_url: :obj:`str` + + :param thumb_width: Optional. Thumbnail width + :type thumb_width: :obj:`int` + + :param thumb_height: Optional. Thumbnail height + :type thumb_height: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultLocation` + """ def __init__(self, id, title, latitude, longitude, horizontal_accuracy, live_period=None, reply_markup=None, input_message_content=None, thumb_url=None, thumb_width=None, thumb_height=None, heading=None, proximity_alert_radius = None): super().__init__('location', id, title = title, @@ -2163,6 +4283,60 @@ class InlineQueryResultLocation(InlineQueryResultBase): class InlineQueryResultVenue(InlineQueryResultBase): + """ + Represents a venue. By default, the venue will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the venue. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultvenue + + :param type: Type of the result, must be venue + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 Bytes + :type id: :obj:`str` + + :param latitude: Latitude of the venue location in degrees + :type latitude: :obj:`float` + + :param longitude: Longitude of the venue location in degrees + :type longitude: :obj:`float` + + :param title: Title of the venue + :type title: :obj:`str` + + :param address: Address of the venue + :type address: :obj:`str` + + :param foursquare_id: Optional. Foursquare identifier of the venue if known + :type foursquare_id: :obj:`str` + + :param foursquare_type: Optional. Foursquare type of the venue, if known. (For example, + “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) + :type foursquare_type: :obj:`str` + + :param google_place_id: Optional. Google Places identifier of the venue + :type google_place_id: :obj:`str` + + :param google_place_type: Optional. Google Places type of the venue. (See supported types.) + :type google_place_type: :obj:`str` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param input_message_content: Optional. Content of the message to be sent instead of the venue + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :param thumb_url: Optional. Url of the thumbnail for the result + :type thumb_url: :obj:`str` + + :param thumb_width: Optional. Thumbnail width + :type thumb_width: :obj:`int` + + :param thumb_height: Optional. Thumbnail height + :type thumb_height: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultVenue` + """ def __init__(self, id, title, latitude, longitude, address, foursquare_id=None, foursquare_type=None, reply_markup=None, input_message_content=None, thumb_url=None, thumb_width=None, thumb_height=None, google_place_id=None, google_place_type=None): @@ -2202,6 +4376,47 @@ class InlineQueryResultVenue(InlineQueryResultBase): class InlineQueryResultContact(InlineQueryResultBase): + """ + Represents a contact with a phone number. By default, this contact will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the contact. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcontact + + :param type: Type of the result, must be contact + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 Bytes + :type id: :obj:`str` + + :param phone_number: Contact's phone number + :type phone_number: :obj:`str` + + :param first_name: Contact's first name + :type first_name: :obj:`str` + + :param last_name: Optional. Contact's last name + :type last_name: :obj:`str` + + :param vcard: Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes + :type vcard: :obj:`str` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param input_message_content: Optional. Content of the message to be sent instead of the contact + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :param thumb_url: Optional. Url of the thumbnail for the result + :type thumb_url: :obj:`str` + + :param thumb_width: Optional. Thumbnail width + :type thumb_width: :obj:`int` + + :param thumb_height: Optional. Thumbnail height + :type thumb_height: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultContact` + """ def __init__(self, id, phone_number, first_name, last_name=None, vcard=None, reply_markup=None, input_message_content=None, thumb_url=None, thumb_width=None, thumb_height=None): @@ -2233,6 +4448,26 @@ class InlineQueryResultContact(InlineQueryResultBase): class InlineQueryResultGame(InlineQueryResultBase): + """ + Represents a Game. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultgame + + :param type: Type of the result, must be game + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 bytes + :type id: :obj:`str` + + :param game_short_name: Short name of the game + :type game_short_name: :obj:`str` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultGame` + """ def __init__(self, id, game_short_name, reply_markup=None): super().__init__('game', id, reply_markup = reply_markup) self.game_short_name = game_short_name @@ -2244,6 +4479,9 @@ class InlineQueryResultGame(InlineQueryResultBase): class InlineQueryResultCachedBase(ABC, JsonSerializable): + """ + Base class of all InlineQueryResultCached* classes. + """ def __init__(self): self.type = None self.id = None @@ -2278,6 +4516,46 @@ class InlineQueryResultCachedBase(ABC, JsonSerializable): class InlineQueryResultCachedPhoto(InlineQueryResultCachedBase): + """ + Represents a link to a photo stored on the Telegram servers. By default, this photo will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcachedphoto + + :param type: Type of the result, must be photo + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 bytes + :type id: :obj:`str` + + :param photo_file_id: A valid file identifier of the photo + :type photo_file_id: :obj:`str` + + :param title: Optional. Title for the result + :type title: :obj:`str` + + :param description: Optional. Short description of the result + :type description: :obj:`str` + + :param caption: Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the photo caption. See formatting options for more + details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param input_message_content: Optional. Content of the message to be sent instead of the photo + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultCachedPhoto` + """ def __init__(self, id, photo_file_id, title=None, description=None, caption=None, caption_entities = None, parse_mode=None, reply_markup=None, input_message_content=None): @@ -2296,6 +4574,42 @@ class InlineQueryResultCachedPhoto(InlineQueryResultCachedBase): class InlineQueryResultCachedGif(InlineQueryResultCachedBase): + """ + Represents a link to an animated GIF file stored on the Telegram servers. By default, this animated GIF file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with specified content instead of the animation. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcachedgif + + :param type: Type of the result, must be gif + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 bytes + :type id: :obj:`str` + + :param gif_file_id: A valid file identifier for the GIF file + :type gif_file_id: :obj:`str` + + :param title: Optional. Title for the result + :type title: :obj:`str` + + :param caption: Optional. Caption of the GIF file to be sent, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the caption. See formatting options for more details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param input_message_content: Optional. Content of the message to be sent instead of the GIF animation + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultCachedGif` + """ def __init__(self, id, gif_file_id, title=None, description=None, caption=None, caption_entities = None, parse_mode=None, reply_markup=None, input_message_content=None): @@ -2314,6 +4628,42 @@ class InlineQueryResultCachedGif(InlineQueryResultCachedBase): class InlineQueryResultCachedMpeg4Gif(InlineQueryResultCachedBase): + """ + Represents a link to a video animation (H.264/MPEG-4 AVC video without sound) stored on the Telegram servers. By default, this animated MPEG-4 file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcachedmpeg4gif + + :param type: Type of the result, must be mpeg4_gif + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 bytes + :type id: :obj:`str` + + :param mpeg4_file_id: A valid file identifier for the MPEG4 file + :type mpeg4_file_id: :obj:`str` + + :param title: Optional. Title for the result + :type title: :obj:`str` + + :param caption: Optional. Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the caption. See formatting options for more details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param input_message_content: Optional. Content of the message to be sent instead of the video animation + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultCachedMpeg4Gif` + """ def __init__(self, id, mpeg4_file_id, title=None, description=None, caption=None, caption_entities = None, parse_mode=None, reply_markup=None, input_message_content=None): @@ -2332,6 +4682,29 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResultCachedBase): class InlineQueryResultCachedSticker(InlineQueryResultCachedBase): + """ + Represents a link to a sticker stored on the Telegram servers. By default, this sticker will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the sticker. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcachedsticker + + :param type: Type of the result, must be sticker + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 bytes + :type id: :obj:`str` + + :param sticker_file_id: A valid file identifier of the sticker + :type sticker_file_id: :obj:`str` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param input_message_content: Optional. Content of the message to be sent instead of the sticker + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultCachedSticker` + """ def __init__(self, id, sticker_file_id, reply_markup=None, input_message_content=None): InlineQueryResultCachedBase.__init__(self) self.type = 'sticker' @@ -2343,6 +4716,46 @@ class InlineQueryResultCachedSticker(InlineQueryResultCachedBase): class InlineQueryResultCachedDocument(InlineQueryResultCachedBase): + """ + Represents a link to a file stored on the Telegram servers. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcacheddocument + + :param type: Type of the result, must be document + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 bytes + :type id: :obj:`str` + + :param title: Title for the result + :type title: :obj:`str` + + :param document_file_id: A valid file identifier for the file + :type document_file_id: :obj:`str` + + :param description: Optional. Short description of the result + :type description: :obj:`str` + + :param caption: Optional. Caption of the document to be sent, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the document caption. See formatting options for more + details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param input_message_content: Optional. Content of the message to be sent instead of the file + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultCachedDocument` + """ def __init__(self, id, document_file_id, title, description=None, caption=None, caption_entities = None, parse_mode=None, reply_markup=None, input_message_content=None): @@ -2361,6 +4774,46 @@ class InlineQueryResultCachedDocument(InlineQueryResultCachedBase): class InlineQueryResultCachedVideo(InlineQueryResultCachedBase): + """ + Represents a link to a video file stored on the Telegram servers. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcachedvideo + + :param type: Type of the result, must be video + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 bytes + :type id: :obj:`str` + + :param video_file_id: A valid file identifier for the video file + :type video_file_id: :obj:`str` + + :param title: Title for the result + :type title: :obj:`str` + + :param description: Optional. Short description of the result + :type description: :obj:`str` + + :param caption: Optional. Caption of the video to be sent, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the video caption. See formatting options for more + details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param input_message_content: Optional. Content of the message to be sent instead of the video + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultCachedVideo` + """ def __init__(self, id, video_file_id, title, description=None, caption=None, caption_entities = None, parse_mode=None, reply_markup=None, @@ -2380,6 +4833,43 @@ class InlineQueryResultCachedVideo(InlineQueryResultCachedBase): class InlineQueryResultCachedVoice(InlineQueryResultCachedBase): + """ + Represents a link to a voice message stored on the Telegram servers. By default, this voice message will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the voice message. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcachedvoice + + :param type: Type of the result, must be voice + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 bytes + :type id: :obj:`str` + + :param voice_file_id: A valid file identifier for the voice message + :type voice_file_id: :obj:`str` + + :param title: Voice message title + :type title: :obj:`str` + + :param caption: Optional. Caption, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the voice message caption. See formatting options for + more details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param input_message_content: Optional. Content of the message to be sent instead of the voice message + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultCachedVoice` + """ def __init__(self, id, voice_file_id, title, caption=None, caption_entities = None, parse_mode=None, reply_markup=None, input_message_content=None): InlineQueryResultCachedBase.__init__(self) @@ -2396,6 +4886,40 @@ class InlineQueryResultCachedVoice(InlineQueryResultCachedBase): class InlineQueryResultCachedAudio(InlineQueryResultCachedBase): + """ + Represents a link to an MP3 audio file stored on the Telegram servers. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio. + + Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcachedaudio + + :param type: Type of the result, must be audio + :type type: :obj:`str` + + :param id: Unique identifier for this result, 1-64 bytes + :type id: :obj:`str` + + :param audio_file_id: A valid file identifier for the audio file + :type audio_file_id: :obj:`str` + + :param caption: Optional. Caption, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the audio caption. See formatting options for more + details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param reply_markup: Optional. Inline keyboard attached to the message + :type reply_markup: :class:`telebot.types.InlineKeyboardMarkup` + + :param input_message_content: Optional. Content of the message to be sent instead of the audio + :type input_message_content: :class:`telebot.types.InputMessageContent` + + :return: Instance of the class + :rtype: :class:`telebot.types.InlineQueryResultCachedAudio` + """ def __init__(self, id, audio_file_id, caption=None, caption_entities = None, parse_mode=None, reply_markup=None, input_message_content=None): InlineQueryResultCachedBase.__init__(self) @@ -2413,6 +4937,34 @@ class InlineQueryResultCachedAudio(InlineQueryResultCachedBase): # Games class Game(JsonDeserializable): + """ + This object represents a game. Use BotFather to create and edit games, their short names will act as unique identifiers. + + Telegram Documentation: https://core.telegram.org/bots/api#game + + :param title: Title of the game + :type title: :obj:`str` + + :param description: Description of the game + :type description: :obj:`str` + + :param photo: Photo that will be displayed in the game message in chats. + :type photo: :obj:`list` of :class:`telebot.types.PhotoSize` + + :param text: Optional. Brief description of the game or high scores included in the game message. Can be + automatically edited to include current high scores for the game when the bot calls setGameScore, or manually edited + using editMessageText. 0-4096 characters. + :type text: :obj:`str` + + :param text_entities: Optional. Special entities that appear in text, such as usernames, URLs, bot commands, etc. + :type text_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param animation: Optional. Animation that will be displayed in the game message in chats. Upload via BotFather + :type animation: :class:`telebot.types.Animation` + + :return: Instance of the class + :rtype: :class:`telebot.types.Game` + """ @classmethod def de_json(cls, json_string): if (json_string is None): return None @@ -2426,6 +4978,9 @@ class Game(JsonDeserializable): @classmethod def parse_photo(cls, photo_size_array): + """ + Parse the photo array into a list of PhotoSize objects + """ ret = [] for ps in photo_size_array: ret.append(PhotoSize.de_json(ps)) @@ -2433,6 +4988,9 @@ class Game(JsonDeserializable): @classmethod def parse_entities(cls, message_entity_array): + """ + Parse the message entity array into a list of MessageEntity objects + """ ret = [] for me in message_entity_array: ret.append(MessageEntity.de_json(me)) @@ -2448,6 +5006,44 @@ class Game(JsonDeserializable): class Animation(JsonDeserializable): + """ + This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound). + + Telegram Documentation: https://core.telegram.org/bots/api#animation + + :param file_id: Identifier for this file, which can be used to download or reuse the file + :type file_id: :obj:`str` + + :param file_unique_id: Unique identifier for this file, which is supposed to be the same over time and for different + bots. Can't be used to download or reuse the file. + :type file_unique_id: :obj:`str` + + :param width: Video width as defined by sender + :type width: :obj:`int` + + :param height: Video height as defined by sender + :type height: :obj:`int` + + :param duration: Duration of the video in seconds as defined by sender + :type duration: :obj:`int` + + :param thumb: Optional. Animation thumbnail as defined by sender + :type thumb: :class:`telebot.types.PhotoSize` + + :param file_name: Optional. Original animation filename as defined by sender + :type file_name: :obj:`str` + + :param mime_type: Optional. MIME type of the file as defined by sender + :type mime_type: :obj:`str` + + :param file_size: Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have + difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or + double-precision float type are safe for storing this value. + :type file_size: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.Animation` + """ @classmethod def de_json(cls, json_string): if (json_string is None): return None @@ -2472,6 +5068,23 @@ class Animation(JsonDeserializable): class GameHighScore(JsonDeserializable): + """ + This object represents one row of the high scores table for a game. + + Telegram Documentation: https://core.telegram.org/bots/api#gamehighscore + + :param position: Position in high score table for the game + :type position: :obj:`int` + + :param user: User + :type user: :class:`telebot.types.User` + + :param score: Score + :type score: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.GameHighScore` + """ @classmethod def de_json(cls, json_string): if (json_string is None): return None @@ -2488,6 +5101,22 @@ class GameHighScore(JsonDeserializable): # Payments class LabeledPrice(JsonSerializable): + """ + This object represents a portion of the price for goods or services. + + Telegram Documentation: https://core.telegram.org/bots/api#labeledprice + + :param label: Portion label + :type label: :obj:`str` + + :param amount: Price of the product in the smallest units of the currency (integer, not float/double). For example, + for a price of US$ 1.45 pass 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). + :type amount: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.LabeledPrice` + """ def __init__(self, label, amount): self.label: str = label self.amount: int = amount @@ -2502,6 +5131,31 @@ class LabeledPrice(JsonSerializable): class Invoice(JsonDeserializable): + """ + This object contains basic information about an invoice. + + Telegram Documentation: https://core.telegram.org/bots/api#invoice + + :param title: Product name + :type title: :obj:`str` + + :param description: Product description + :type description: :obj:`str` + + :param start_parameter: Unique bot deep-linking parameter that can be used to generate this invoice + :type start_parameter: :obj:`str` + + :param currency: Three-letter ISO 4217 currency code + :type currency: :obj:`str` + + :param total_amount: Total price in the smallest units of the currency (integer, not float/double). For example, + for a price of US$ 1.45 pass 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). + :type total_amount: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.Invoice` + """ @classmethod def de_json(cls, json_string): if (json_string is None): return None @@ -2517,6 +5171,32 @@ class Invoice(JsonDeserializable): class ShippingAddress(JsonDeserializable): + """ + This object represents a shipping address. + + Telegram Documentation: https://core.telegram.org/bots/api#shippingaddress + + :param country_code: Two-letter ISO 3166-1 alpha-2 country code + :type country_code: :obj:`str` + + :param state: State, if applicable + :type state: :obj:`str` + + :param city: City + :type city: :obj:`str` + + :param street_line1: First line for the address + :type street_line1: :obj:`str` + + :param street_line2: Second line for the address + :type street_line2: :obj:`str` + + :param post_code: Address post code + :type post_code: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.ShippingAddress` + """ @classmethod def de_json(cls, json_string): if (json_string is None): return None @@ -2533,6 +5213,26 @@ class ShippingAddress(JsonDeserializable): class OrderInfo(JsonDeserializable): + """ + This object represents information about an order. + + Telegram Documentation: https://core.telegram.org/bots/api#orderinfo + + :param name: Optional. User name + :type name: :obj:`str` + + :param phone_number: Optional. User's phone number + :type phone_number: :obj:`str` + + :param email: Optional. User email + :type email: :obj:`str` + + :param shipping_address: Optional. User shipping address + :type shipping_address: :class:`telebot.types.ShippingAddress` + + :return: Instance of the class + :rtype: :class:`telebot.types.OrderInfo` + """ @classmethod def de_json(cls, json_string): if (json_string is None): return None @@ -2548,6 +5248,23 @@ class OrderInfo(JsonDeserializable): class ShippingOption(JsonSerializable): + """ + This object represents one shipping option. + + Telegram Documentation: https://core.telegram.org/bots/api#shippingoption + + :param id: Shipping option identifier + :type id: :obj:`str` + + :param title: Option title + :type title: :obj:`str` + + :param prices: List of price portions + :type prices: :obj:`list` of :class:`telebot.types.LabeledPrice` + + :return: Instance of the class + :rtype: :class:`telebot.types.ShippingOption` + """ def __init__(self, id, title): self.id: str = id self.title: str = title @@ -2558,6 +5275,9 @@ class ShippingOption(JsonSerializable): Add LabeledPrice to ShippingOption :param args: LabeledPrices + :type args: :obj:`LabeledPrice` + + :return: None """ for price in args: self.prices.append(price) @@ -2572,6 +5292,37 @@ class ShippingOption(JsonSerializable): class SuccessfulPayment(JsonDeserializable): + """ + This object contains basic information about a successful payment. + + Telegram Documentation: https://core.telegram.org/bots/api#successfulpayment + + :param currency: Three-letter ISO 4217 currency code + :type currency: :obj:`str` + + :param total_amount: Total price in the smallest units of the currency (integer, not float/double). For example, + for a price of US$ 1.45 pass 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). + :type total_amount: :obj:`int` + + :param invoice_payload: Bot specified invoice payload + :type invoice_payload: :obj:`str` + + :param shipping_option_id: Optional. Identifier of the shipping option chosen by the user + :type shipping_option_id: :obj:`str` + + :param order_info: Optional. Order information provided by the user + :type order_info: :class:`telebot.types.OrderInfo` + + :param telegram_payment_charge_id: Telegram payment identifier + :type telegram_payment_charge_id: :obj:`str` + + :param provider_payment_charge_id: Provider payment identifier + :type provider_payment_charge_id: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.SuccessfulPayment` + """ @classmethod def de_json(cls, json_string): if (json_string is None): return None @@ -2591,6 +5342,26 @@ class SuccessfulPayment(JsonDeserializable): class ShippingQuery(JsonDeserializable): + """ + This object contains information about an incoming shipping query. + + Telegram Documentation: https://core.telegram.org/bots/api#shippingquery + + :param id: Unique query identifier + :type id: :obj:`str` + + :param from: User who sent the query + :type from: :class:`telebot.types.User` + + :param invoice_payload: Bot specified invoice payload + :type invoice_payload: :obj:`str` + + :param shipping_address: User specified shipping address + :type shipping_address: :class:`telebot.types.ShippingAddress` + + :return: Instance of the class + :rtype: :class:`telebot.types.ShippingQuery` + """ @classmethod def de_json(cls, json_string): if (json_string is None): return None @@ -2607,6 +5378,37 @@ class ShippingQuery(JsonDeserializable): class PreCheckoutQuery(JsonDeserializable): + """ + This object contains information about an incoming pre-checkout query. + + Telegram Documentation: https://core.telegram.org/bots/api#precheckoutquery + + :param id: Unique query identifier + :type id: :obj:`str` + + :param from: User who sent the query + :type from: :class:`telebot.types.User` + + :param currency: Three-letter ISO 4217 currency code + :type currency: :obj:`str` + + :param total_amount: Total price in the smallest units of the currency (integer, not float/double). For example, + for a price of US$ 1.45 pass 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). + :type total_amount: :obj:`int` + + :param invoice_payload: Bot specified invoice payload + :type invoice_payload: :obj:`str` + + :param shipping_option_id: Optional. Identifier of the shipping option chosen by the user + :type shipping_option_id: :obj:`str` + + :param order_info: Optional. Order information provided by the user + :type order_info: :class:`telebot.types.OrderInfo` + + :return: Instance of the class + :rtype: :class:`telebot.types.PreCheckoutQuery` + """ @classmethod def de_json(cls, json_string): if (json_string is None): return None @@ -2628,6 +5430,35 @@ class PreCheckoutQuery(JsonDeserializable): # Stickers class StickerSet(JsonDeserializable): + """ + This object represents a sticker set. + + Telegram Documentation: https://core.telegram.org/bots/api#stickerset + + :param name: Sticker set name + :type name: :obj:`str` + + :param title: Sticker set title + :type title: :obj:`str` + + :param is_animated: True, if the sticker set contains animated stickers + :type is_animated: :obj:`bool` + + :param is_video: True, if the sticker set contains video stickers + :type is_video: :obj:`bool` + + :param contains_masks: True, if the sticker set contains masks + :type contains_masks: :obj:`bool` + + :param stickers: List of all set stickers + :type stickers: :obj:`list` of :class:`telebot.types.Sticker` + + :param thumb: Optional. Sticker set thumbnail in the .WEBP, .TGS, or .WEBM format + :type thumb: :class:`telebot.types.PhotoSize` + + :return: Instance of the class + :rtype: :class:`telebot.types.StickerSet` + """ @classmethod def de_json(cls, json_string): if (json_string is None): return None @@ -2653,6 +5484,52 @@ class StickerSet(JsonDeserializable): class Sticker(JsonDeserializable): + """ + This object represents a sticker. + + Telegram Documentation: https://core.telegram.org/bots/api#sticker + + :param file_id: Identifier for this file, which can be used to download or reuse the file + :type file_id: :obj:`str` + + :param file_unique_id: Unique identifier for this file, which is supposed to be the same over time and for different + bots. Can't be used to download or reuse the file. + :type file_unique_id: :obj:`str` + + :param width: Sticker width + :type width: :obj:`int` + + :param height: Sticker height + :type height: :obj:`int` + + :param is_animated: True, if the sticker is animated + :type is_animated: :obj:`bool` + + :param is_video: True, if the sticker is a video sticker + :type is_video: :obj:`bool` + + :param thumb: Optional. Sticker thumbnail in the .WEBP or .JPG format + :type thumb: :class:`telebot.types.PhotoSize` + + :param emoji: Optional. Emoji associated with the sticker + :type emoji: :obj:`str` + + :param set_name: Optional. Name of the sticker set to which the sticker belongs + :type set_name: :obj:`str` + + :param premium_animation: Optional. Premium animation for the sticker, if the sticker is premium + :type premium_animation: :class:`telebot.types.File` + + :param mask_position: Optional. For mask stickers, the position where the mask should be placed + :type mask_position: :class:`telebot.types.MaskPosition` + + :param file_size: Optional. File size in bytes + :type file_size: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.Sticker` + """ + @classmethod def de_json(cls, json_string): if (json_string is None): return None @@ -2686,6 +5563,30 @@ class Sticker(JsonDeserializable): class MaskPosition(Dictionaryable, JsonDeserializable, JsonSerializable): + """ + This object describes the position on faces where a mask should be placed by default. + + Telegram Documentation: https://core.telegram.org/bots/api#maskposition + + :param point: The part of the face relative to which the mask should be placed. One of “forehead”, “eyes”, “mouth”, or + “chin”. + :type point: :obj:`str` + + :param x_shift: Shift by X-axis measured in widths of the mask scaled to the face size, from left to right. For example, + choosing -1.0 will place mask just to the left of the default mask position. + :type x_shift: :obj:`float` number + + :param y_shift: Shift by Y-axis measured in heights of the mask scaled to the face size, from top to bottom. For + example, 1.0 will place the mask just below the default mask position. + :type y_shift: :obj:`float` number + + :param scale: Mask scaling coefficient. For example, 2.0 means double size. + :type scale: :obj:`float` number + + :return: Instance of the class + :rtype: :class:`telebot.types.MaskPosition` + """ + @classmethod def de_json(cls, json_string): if (json_string is None): return None @@ -2708,6 +5609,15 @@ class MaskPosition(Dictionaryable, JsonDeserializable, JsonSerializable): # InputMedia class InputMedia(Dictionaryable, JsonSerializable): + """ + This object represents the content of a media message to be sent. It should be one of + + * :class:`InputMediaAnimation` + * :class:`InputMediaDocument` + * :class:`InputMediaAudio` + * :class:`InputMediaPhoto` + * :class:`InputMediaVideo` + """ def __init__(self, type, media, caption=None, parse_mode=None, caption_entities=None): self.type: str = type self.media: str = media @@ -2736,6 +5646,9 @@ class InputMedia(Dictionaryable, JsonSerializable): return json_dict def convert_input_media(self): + """ + :meta private: + """ if util.is_string(self.media): return self.to_json(), None @@ -2743,6 +5656,33 @@ class InputMedia(Dictionaryable, JsonSerializable): class InputMediaPhoto(InputMedia): + """ + Represents a photo to be sent. + + Telegram Documentation: https://core.telegram.org/bots/api#inputmediaphoto + + :param type: Type of the result, must be photo + :type type: :obj:`str` + + :param media: File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an + HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using + multipart/form-data under name. More information on Sending Files » + :type media: :obj:`str` + + :param caption: Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the photo caption. See formatting options for more + details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :return: Instance of the class + :rtype: :class:`telebot.types.InputMediaPhoto` + """ def __init__(self, media, caption=None, parse_mode=None): if util.is_pil_image(media): media = util.pil_image_to_file(media) @@ -2754,6 +5694,52 @@ class InputMediaPhoto(InputMedia): class InputMediaVideo(InputMedia): + """ + Represents a video to be sent. + + Telegram Documentation: https://core.telegram.org/bots/api#inputmediavideo + + :param type: Type of the result, must be video + :type type: :obj:`str` + + :param media: File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an + HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using + multipart/form-data under name. More information on Sending Files » + :type media: :obj:`str` + + :param thumb: Optional. 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 . More information on Sending Files » + :type thumb: InputFile or :obj:`str` + + :param caption: Optional. Caption of the video to be sent, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the video caption. See formatting options for more + details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param width: Optional. Video width + :type width: :obj:`int` + + :param height: Optional. Video height + :type height: :obj:`int` + + :param duration: Optional. Video duration in seconds + :type duration: :obj:`int` + + :param supports_streaming: Optional. Pass True, if the uploaded video is suitable for streaming + :type supports_streaming: :obj:`bool` + + :return: Instance of the class + :rtype: :class:`telebot.types.InputMediaVideo` + """ def __init__(self, media, thumb=None, caption=None, parse_mode=None, width=None, height=None, duration=None, supports_streaming=None): super(InputMediaVideo, self).__init__(type="video", media=media, caption=caption, parse_mode=parse_mode) @@ -2779,6 +5765,49 @@ class InputMediaVideo(InputMedia): class InputMediaAnimation(InputMedia): + """ + Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent. + + Telegram Documentation: https://core.telegram.org/bots/api#inputmediaanimation + + :param type: Type of the result, must be animation + :type type: :obj:`str` + + :param media: File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an + HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using + multipart/form-data under name. More information on Sending Files » + :type media: :obj:`str` + + :param thumb: Optional. 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 . More information on Sending Files » + :type thumb: InputFile or :obj:`str` + + :param caption: Optional. Caption of the animation to be sent, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the animation caption. See formatting options for more + details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param width: Optional. Animation width + :type width: :obj:`int` + + :param height: Optional. Animation height + :type height: :obj:`int` + + :param duration: Optional. Animation duration in seconds + :type duration: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.InputMediaAnimation` + """ def __init__(self, media, thumb=None, caption=None, parse_mode=None, width=None, height=None, duration=None): super(InputMediaAnimation, self).__init__(type="animation", media=media, caption=caption, parse_mode=parse_mode) self.thumb = thumb @@ -2800,6 +5829,49 @@ class InputMediaAnimation(InputMedia): class InputMediaAudio(InputMedia): + """ + Represents an audio file to be treated as music to be sent. + + Telegram Documentation: https://core.telegram.org/bots/api#inputmediaaudio + + :param type: Type of the result, must be audio + :type type: :obj:`str` + + :param media: File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an + HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using + multipart/form-data under name. More information on Sending Files » + :type media: :obj:`str` + + :param thumb: Optional. 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 . More information on Sending Files » + :type thumb: InputFile or :obj:`str` + + :param caption: Optional. Caption of the audio to be sent, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the audio caption. See formatting options for more + details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param duration: Optional. Duration of the audio in seconds + :type duration: :obj:`int` + + :param performer: Optional. Performer of the audio + :type performer: :obj:`str` + + :param title: Optional. Title of the audio + :type title: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.InputMediaAudio` + """ def __init__(self, media, thumb=None, caption=None, parse_mode=None, duration=None, performer=None, title=None): super(InputMediaAudio, self).__init__(type="audio", media=media, caption=caption, parse_mode=parse_mode) self.thumb = thumb @@ -2821,6 +5893,44 @@ class InputMediaAudio(InputMedia): class InputMediaDocument(InputMedia): + """ + Represents a general file to be sent. + + Telegram Documentation: https://core.telegram.org/bots/api#inputmediadocument + + :param type: Type of the result, must be document + :type type: :obj:`str` + + :param media: File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an + HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using + multipart/form-data under name. More information on Sending Files » + :type media: :obj:`str` + + :param thumb: Optional. 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 . More information on Sending Files » + :type thumb: InputFile or :obj:`str` + + :param caption: Optional. Caption of the document to be sent, 0-1024 characters after entities parsing + :type caption: :obj:`str` + + :param parse_mode: Optional. Mode for parsing entities in the document caption. See formatting options for more + details. + :type parse_mode: :obj:`str` + + :param caption_entities: Optional. List of special entities that appear in the caption, which can be specified + instead of parse_mode + :type caption_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param disable_content_type_detection: Optional. Disables automatic server-side content type detection for + files uploaded using multipart/form-data. Always True, if the document is sent as part of an album. + :type disable_content_type_detection: :obj:`bool` + + :return: Instance of the class + :rtype: :class:`telebot.types.InputMediaDocument` + """ def __init__(self, media, thumb=None, caption=None, parse_mode=None, disable_content_type_detection=None): super(InputMediaDocument, self).__init__(type="document", media=media, caption=caption, parse_mode=parse_mode) self.thumb = thumb @@ -2836,6 +5946,20 @@ class InputMediaDocument(InputMedia): class PollOption(JsonDeserializable): + """ + This object contains information about one answer option in a poll. + + Telegram Documentation: https://core.telegram.org/bots/api#polloption + + :param text: Option text, 1-100 characters + :type text: :obj:`str` + + :param voter_count: Number of users that voted for this option + :type voter_count: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.PollOption` + """ @classmethod def de_json(cls, json_string): if (json_string is None): return None @@ -2852,6 +5976,56 @@ class PollOption(JsonDeserializable): class Poll(JsonDeserializable): + """ + This object contains information about a poll. + + Telegram Documentation: https://core.telegram.org/bots/api#poll + + :param id: Unique poll identifier + :type id: :obj:`str` + + :param question: Poll question, 1-300 characters + :type question: :obj:`str` + + :param options: List of poll options + :type options: :obj:`list` of :class:`telebot.types.PollOption` + + :param total_voter_count: Total number of users that voted in the poll + :type total_voter_count: :obj:`int` + + :param is_closed: True, if the poll is closed + :type is_closed: :obj:`bool` + + :param is_anonymous: True, if the poll is anonymous + :type is_anonymous: :obj:`bool` + + :param type: Poll type, currently can be “regular” or “quiz” + :type type: :obj:`str` + + :param allows_multiple_answers: True, if the poll allows multiple answers + :type allows_multiple_answers: :obj:`bool` + + :param correct_option_id: Optional. 0-based identifier of the correct answer option. Available only for polls in + the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot. + :type correct_option_id: :obj:`int` + + :param explanation: Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a + quiz-style poll, 0-200 characters + :type explanation: :obj:`str` + + :param explanation_entities: Optional. Special entities like usernames, URLs, bot commands, etc. that appear in + the explanation + :type explanation_entities: :obj:`list` of :class:`telebot.types.MessageEntity` + + :param open_period: Optional. Amount of time in seconds the poll will be active after creation + :type open_period: :obj:`int` + + :param close_date: Optional. Point in time (Unix timestamp) when the poll will be automatically closed + :type close_date: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.Poll` + """ @classmethod def de_json(cls, json_string): if (json_string is None): return None @@ -2892,6 +6066,12 @@ class Poll(JsonDeserializable): self.close_date: int = close_date def add(self, option): + """ + Add an option to the poll. + + :param option: Option to add + :type option: :class:`telebot.types.PollOption` or :obj:`str` + """ if type(option) is PollOption: self.options.append(option) else: @@ -2899,6 +6079,24 @@ class Poll(JsonDeserializable): class PollAnswer(JsonSerializable, JsonDeserializable, Dictionaryable): + """ + This object represents an answer of a user in a non-anonymous poll. + + Telegram Documentation: https://core.telegram.org/bots/api#pollanswer + + :param poll_id: Unique poll identifier + :type poll_id: :obj:`str` + + :param user: The user, who changed the answer to the poll + :type user: :class:`telebot.types.User` + + :param option_ids: 0-based identifiers of answer options, chosen by the user. May be empty if the user retracted + their vote. + :type option_ids: :obj:`list` of :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.PollAnswer` + """ @classmethod def de_json(cls, json_string): if (json_string is None): return None @@ -2921,6 +6119,20 @@ class PollAnswer(JsonSerializable, JsonDeserializable, Dictionaryable): class ChatLocation(JsonSerializable, JsonDeserializable, Dictionaryable): + """ + Represents a location to which a chat is connected. + + Telegram Documentation: https://core.telegram.org/bots/api#chatlocation + + :param location: The location to which the supergroup is connected. Can't be a live location. + :type location: :class:`telebot.types.Location` + + :param address: Location address; 1-64 characters, as defined by the chat owner + :type address: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.ChatLocation` + """ @classmethod def de_json(cls, json_string): if json_string is None: return json_string @@ -2943,6 +6155,43 @@ class ChatLocation(JsonSerializable, JsonDeserializable, Dictionaryable): class ChatInviteLink(JsonSerializable, JsonDeserializable, Dictionaryable): + """ + Represents an invite link for a chat. + + Telegram Documentation: https://core.telegram.org/bots/api#chatinvitelink + + :param invite_link: The invite link. If the link was created by another chat administrator, then the second part of + the link will be replaced with “…”. + :type invite_link: :obj:`str` + + :param creator: Creator of the link + :type creator: :class:`telebot.types.User` + + :param creates_join_request: True, if users joining the chat via the link need to be approved by chat administrators + :type creates_join_request: :obj:`bool` + + :param is_primary: True, if the link is primary + :type is_primary: :obj:`bool` + + :param is_revoked: True, if the link is revoked + :type is_revoked: :obj:`bool` + + :param name: Optional. Invite link name + :type name: :obj:`str` + + :param expire_date: Optional. Point in time (Unix timestamp) when the link will expire or has been expired + :type expire_date: :obj:`int` + + :param member_limit: Optional. The maximum number of users that can be members of the chat simultaneously after + joining the chat via this invite link; 1-99999 + :type member_limit: :obj:`int` + + :param pending_join_request_count: Optional. Number of pending join requests created using this link + :type pending_join_request_count: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.ChatInviteLink` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -2985,6 +6234,23 @@ class ChatInviteLink(JsonSerializable, JsonDeserializable, Dictionaryable): class ProximityAlertTriggered(JsonDeserializable): + """ + This object represents the content of a service message, sent whenever a user in the chat triggers a proximity alert set by another user. + + Telegram Documentation: https://core.telegram.org/bots/api#proximityalerttriggered + + :param traveler: User that triggered the alert + :type traveler: :class:`telebot.types.User` + + :param watcher: User that set the alert + :type watcher: :class:`telebot.types.User` + + :param distance: The distance between the users + :type distance: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.ProximityAlertTriggered` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -2998,24 +6264,39 @@ class ProximityAlertTriggered(JsonDeserializable): class VideoChatStarted(JsonDeserializable): + """ + This object represents a service message about a video chat started in the chat. Currently holds no information. + """ @classmethod def de_json(cls, json_string): return cls() def __init__(self): - """ - This object represents a service message about a voice chat started in the chat. - Currently holds no information. - """ pass class VoiceChatStarted(VideoChatStarted): + """ + Deprecated, use :class:`VideoChatStarted` instead. + """ + def __init__(self): logger.warning('VoiceChatStarted is deprecated. Use VideoChatStarted instead.') super().__init__() class VideoChatScheduled(JsonDeserializable): + """ + This object represents a service message about a video chat scheduled in the chat. + + Telegram Documentation: https://core.telegram.org/bots/api#videochatscheduled + + :param start_date: Point in time (Unix timestamp) when the video chat is supposed to be started by a chat + administrator + :type start_date: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.VideoChatScheduled` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -3026,12 +6307,26 @@ class VideoChatScheduled(JsonDeserializable): self.start_date: int = start_date class VoiceChatScheduled(VideoChatScheduled): + """ + Deprecated, use :class:`VideoChatScheduled` instead. + """ def __init__(self, *args, **kwargs): logger.warning('VoiceChatScheduled is deprecated. Use VideoChatScheduled instead.') super().__init__(*args, **kwargs) class VideoChatEnded(JsonDeserializable): + """ + This object represents a service message about a video chat ended in the chat. + + Telegram Documentation: https://core.telegram.org/bots/api#videochatended + + :param duration: Video chat duration in seconds + :type duration: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.VideoChatEnded` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -3042,6 +6337,9 @@ class VideoChatEnded(JsonDeserializable): self.duration: int = duration class VoiceChatEnded(VideoChatEnded): + """ + Deprecated, use :class:`VideoChatEnded` instead. + """ def __init__(self, *args, **kwargs): logger.warning('VoiceChatEnded is deprecated. Use VideoChatEnded instead.') super().__init__(*args, **kwargs) @@ -3049,6 +6347,17 @@ class VoiceChatEnded(VideoChatEnded): class VideoChatParticipantsInvited(JsonDeserializable): + """ + This object represents a service message about new members invited to a video chat. + + Telegram Documentation: https://core.telegram.org/bots/api#videochatparticipantsinvited + + :param users: New members that were invited to the video chat + :type users: :obj:`list` of :class:`telebot.types.User` + + :return: Instance of the class + :rtype: :class:`telebot.types.VideoChatParticipantsInvited` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -3061,12 +6370,26 @@ class VideoChatParticipantsInvited(JsonDeserializable): self.users: List[User] = users class VoiceChatParticipantsInvited(VideoChatParticipantsInvited): + """ + Deprecated, use :class:`VideoChatParticipantsInvited` instead. + """ def __init__(self, *args, **kwargs): logger.warning('VoiceChatParticipantsInvited is deprecated. Use VideoChatParticipantsInvited instead.') super().__init__(*args, **kwargs) class MessageAutoDeleteTimerChanged(JsonDeserializable): + """ + This object represents a service message about a change in auto-delete timer settings. + + Telegram Documentation: https://core.telegram.org/bots/api#messageautodeletetimerchanged + + :param message_auto_delete_time: New auto-delete time for messages in the chat; in seconds + :type message_auto_delete_time: :obj:`int` + + :return: Instance of the class + :rtype: :class:`telebot.types.MessageAutoDeleteTimerChanged` + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -3079,7 +6402,14 @@ class MessageAutoDeleteTimerChanged(JsonDeserializable): class MenuButton(JsonDeserializable, JsonSerializable): """ - Base class for MenuButtons. + This object describes the bot's menu button in a private chat. It should be one of + + * :class:`MenuButtonCommands` + * :class:`MenuButtonWebApp` + * :class:`MenuButtonDefault` + + If a menu button other than MenuButtonDefault is set for a private chat, then it is applied + in the chat. Otherwise the default menu button is applied. By default, the menu button opens the list of bot commands. """ @classmethod def de_json(cls, json_string): @@ -3097,6 +6427,17 @@ class MenuButton(JsonDeserializable, JsonSerializable): class MenuButtonCommands(MenuButton): + """ + Represents a menu button, which opens the bot's list of commands. + + Telegram Documentation: https://core.telegram.org/bots/api#menubuttoncommands + + :param type: Type of the button, must be commands + :type type: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.MenuButtonCommands` + """ def __init__(self, type): self.type = type @@ -3108,6 +6449,24 @@ class MenuButtonCommands(MenuButton): return json.dumps(self.to_dict()) class MenuButtonWebApp(MenuButton): + """ + Represents a menu button, which launches a Web App. + + Telegram Documentation: https://core.telegram.org/bots/api#menubuttonwebapp + + :param type: Type of the button, must be web_app + :type type: :obj:`str` + + :param text: Text on the button + :type text: :obj:`str` + + :param web_app: Description of the Web App that will be launched when the user presses the button. The Web App will be + able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. + :type web_app: :class:`telebot.types.WebAppInfo` + + :return: Instance of the class + :rtype: :class:`telebot.types.MenuButtonWebApp` + """ def __init__(self, type, text, web_app): self.type: str = type @@ -3121,7 +6480,17 @@ class MenuButtonWebApp(MenuButton): return json.dumps(self.to_dict()) class MenuButtonDefault(MenuButton): + """ + Describes that no specific value for the menu button was set. + Telegram Documentation: https://core.telegram.org/bots/api#menubuttondefault + + :param type: Type of the button, must be default + :type type: :obj:`str` + + :return: Instance of the class + :rtype: :class:`telebot.types.MenuButtonDefault` + """ def __init__(self, type): self.type: str = type @@ -3134,8 +6503,50 @@ class MenuButtonDefault(MenuButton): class ChatAdministratorRights(JsonDeserializable, JsonSerializable): """ - Class representation of: - https://core.telegram.org/bots/api#chatadministratorrights + Represents the rights of an administrator in a chat. + + Telegram Documentation: https://core.telegram.org/bots/api#chatadministratorrights + + :param is_anonymous: True, if the user's presence in the chat is hidden + :type is_anonymous: :obj:`bool` + + :param can_manage_chat: True, if the administrator can access the chat event log, chat statistics, message + statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. + Implied by any other administrator privilege + :type can_manage_chat: :obj:`bool` + + :param can_delete_messages: True, if the administrator can delete messages of other users + :type can_delete_messages: :obj:`bool` + + :param can_manage_video_chats: True, if the administrator can manage video chats + :type can_manage_video_chats: :obj:`bool` + + :param can_restrict_members: True, if the administrator can restrict, ban or unban chat members + :type can_restrict_members: :obj:`bool` + + :param can_promote_members: True, if the administrator can add new administrators with a subset of their own + privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that + were appointed by the user) + :type can_promote_members: :obj:`bool` + + :param can_change_info: True, if the user is allowed to change the chat title, photo and other settings + :type can_change_info: :obj:`bool` + + :param can_invite_users: True, if the user is allowed to invite new users to the chat + :type can_invite_users: :obj:`bool` + + :param can_post_messages: Optional. True, if the administrator can post in the channel; channels only + :type can_post_messages: :obj:`bool` + + :param can_edit_messages: Optional. True, if the administrator can edit messages of other users and can pin + messages; channels only + :type can_edit_messages: :obj:`bool` + + :param can_pin_messages: Optional. True, if the user is allowed to pin messages; groups and supergroups only + :type can_pin_messages: :obj:`bool` + + :return: Instance of the class + :rtype: :class:`telebot.types.ChatAdministratorRights` """ @classmethod