diff --git a/telebot/__init__.py b/telebot/__init__.py index dcdeb8eb3..97b7ccadb 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -46,7 +46,7 @@ REPLY_MARKUP_TYPES = Union[ - types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, + types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply] @@ -93,7 +93,7 @@ class TeleBot: from telebot import TeleBot bot = TeleBot('token') # get token from @BotFather - # now you can register other handlers/update listeners, + # now you can register other handlers/update listeners, # and use bot methods. See more examples in examples/ directory: @@ -139,7 +139,7 @@ class TeleBot: :param use_class_middlewares: Use class middlewares, defaults to False :type use_class_middlewares: :obj:`bool`, optional - + :param disable_web_page_preview: Default value for disable_web_page_preview, defaults to None :type disable_web_page_preview: :obj:`bool`, optional @@ -151,7 +151,7 @@ class TeleBot: :param allow_sending_without_reply: Default value for allow_sending_without_reply, defaults to None :type allow_sending_without_reply: :obj:`bool`, optional - + :param colorful_logs: Outputs colorful logs :type colorful_logs: :obj:`bool`, optional @@ -168,7 +168,7 @@ def __init__( next_step_backend: Optional[HandlerBackend]=None, reply_backend: Optional[HandlerBackend]=None, exception_handler: Optional[ExceptionHandler]=None, last_update_id: Optional[int]=0, suppress_middleware_excepions: Optional[bool]=False, state_storage: Optional[StateStorageBase]=StateMemoryStorage(), - use_class_middlewares: Optional[bool]=False, + use_class_middlewares: Optional[bool]=False, disable_web_page_preview: Optional[bool]=None, disable_notification: Optional[bool]=None, protect_content: Optional[bool]=None, @@ -194,7 +194,7 @@ def __init__( if validate_token: util.validate_token(self.token) - + self.bot_id: Union[int, None] = util.extract_bot_id(self.token) # subject to change in future, unspecified # logs-related @@ -292,7 +292,7 @@ def __init__( self.threaded = threaded if self.threaded: self.worker_pool = util.ThreadPool(self, num_threads=num_threads) - + @property def user(self) -> types.User: """ @@ -438,15 +438,15 @@ def set_webhook(self, url: Optional[str]=None, certificate: Optional[Union[str, Defaults to 40. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput, defaults to None :type max_connections: :obj:`int`, optional - + :param allowed_updates: A JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member (default). If not specified, the previous setting will be used. - + Please note that this parameter doesn't affect updates created before the call to the setWebhook, so unwanted updates may be received for a short period of time. Defaults to None - + :type allowed_updates: :obj:`list`, optional :param ip_address: The fixed IP address which will be used to send webhook requests instead of the IP address @@ -516,7 +516,7 @@ def run_webhooks(self, :type max_connections: :obj:`int`, optional :param allowed_updates: A JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] - to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all updates regardless of type (default). + to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all updates regardless of type (default). If not specified, the previous setting will be used. defaults to None :type allowed_updates: :obj:`list`, optional @@ -545,7 +545,7 @@ def run_webhooks(self, if not url_path: url_path = self.token + '/' if url_path[-1] != '/': url_path += '/' - + protocol = "https" if certificate else "http" if not webhook_url: webhook_url = "{}://{}:{}/{}".format(protocol, listen, port, url_path) @@ -627,8 +627,8 @@ def remove_webhook(self) -> bool: return self.set_webhook() # No params resets webhook - def get_updates(self, offset: Optional[int]=None, limit: Optional[int]=None, - timeout: Optional[int]=20, allowed_updates: Optional[List[str]]=None, + def get_updates(self, offset: Optional[int]=None, limit: Optional[int]=None, + timeout: Optional[int]=20, allowed_updates: Optional[List[str]]=None, long_polling_timeout: int=20) -> List[types.Update]: """ Use this method to receive incoming updates using long polling (wiki). An Array of Update objects is returned. @@ -678,14 +678,14 @@ def __retrieve_updates(self, timeout=20, long_polling_timeout=20, allowed_update Registered listeners and applicable message handlers will be notified when a new message arrives. :meta private: - + :raises ApiException when a call has failed. """ if self.skip_pending: self.__skip_updates() logger.debug('Skipped all pending messages') self.skip_pending = False - updates = self.get_updates(offset=(self.last_update_id + 1), + updates = self.get_updates(offset=(self.last_update_id + 1), allowed_updates=allowed_updates, timeout=timeout, long_polling_timeout=long_polling_timeout) self.process_new_updates(updates) @@ -726,7 +726,7 @@ def process_new_updates(self, updates: List[types.Update]): new_edited_business_messages = None new_deleted_business_messages = None new_purchased_paid_media = None - + for update in updates: if apihelper.ENABLE_MIDDLEWARE and not self.use_class_middlewares: try: @@ -810,7 +810,7 @@ def process_new_updates(self, updates: List[types.Update]): if update.purchased_paid_media: if new_purchased_paid_media is None: new_purchased_paid_media = [] new_purchased_paid_media.append(update.purchased_paid_media) - + if new_messages: self.process_new_messages(new_messages) if new_edited_messages: @@ -890,7 +890,7 @@ def process_new_message_reaction(self, new_message_reactions): :meta private: """ self._notify_command_handlers(self.message_reaction_handlers, new_message_reactions, 'message_reaction') - + def process_new_message_reaction_count(self, new_message_reaction_counts): """ :meta private: @@ -938,7 +938,7 @@ def process_new_poll_answer(self, new_poll_answers): :meta private: """ self._notify_command_handlers(self.poll_answer_handlers, new_poll_answers, 'poll_answer') - + def process_new_my_chat_member(self, new_my_chat_members): """ :meta private: @@ -986,13 +986,13 @@ def process_new_edited_business_message(self, new_edited_business_messages): :meta private: """ self._notify_command_handlers(self.edited_business_message_handlers, new_edited_business_messages, 'edited_business_message') - + def process_new_deleted_business_messages(self, new_deleted_business_messages): """ :meta private: """ self._notify_command_handlers(self.deleted_business_messages_handlers, new_deleted_business_messages, 'deleted_business_messages') - + def process_new_purchased_paid_media(self, new_purchased_paid_media): """ :meta private: @@ -1047,7 +1047,7 @@ def _setup_change_detector(self, path_to_watch: str): # Make it possible to specify --path argument to the script path = sys.argv[sys.argv.index('--path') + 1] if '--path' in sys.argv else '.' - + self.event_observer = Observer() self.event_observer.schedule(self.event_handler, path, recursive=True) self.event_observer.start() @@ -1066,7 +1066,7 @@ def infinity_polling(self, timeout: Optional[int]=20, skip_pending: Optional[boo Wrap polling with infinite loop and exception handling to avoid bot stops polling. .. note:: - + Install watchdog and psutil before using restart_on_change option. :param timeout: Request connection timeout. @@ -1083,11 +1083,11 @@ def infinity_polling(self, timeout: Optional[int]=20, skip_pending: Optional[boo :type logger_level: :obj:`int`. :param allowed_updates: A list of the update types you want your bot to receive. - For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. - See util.update_types for a complete list of available update types. - Specify an empty list to receive all update types except chat_member (default). + For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. + See util.update_types for a complete list of available update types. + Specify an empty list to receive all update types except chat_member (default). If not specified, the previous setting will be used. - Please note that this parameter doesn't affect updates created before the call to the get_updates, + Please note that this parameter doesn't affect updates created before the call to the get_updates, so unwanted updates may be received for a short period of time. :type allowed_updates: :obj:`list` of :obj:`str` @@ -1132,14 +1132,14 @@ def polling(self, non_stop: Optional[bool]=False, skip_pending: Optional[bool]=F This allows the bot to retrieve Updates automatically and notify listeners and message handlers accordingly. Warning: Do not call this function more than once! - + Always gets updates. .. deprecated:: 4.1.1 Use :meth:`infinity_polling` instead. .. note:: - + Install watchdog and psutil before using restart_on_change option. :param interval: Delay between two update retrivals @@ -1153,7 +1153,7 @@ def polling(self, non_stop: Optional[bool]=False, skip_pending: Optional[bool]=F :param skip_pending: skip old updates :type skip_pending: :obj:`bool` - + :param long_polling_timeout: Timeout in seconds for long polling (see API docs) :type long_polling_timeout: :obj:`int` @@ -1162,12 +1162,12 @@ def polling(self, non_stop: Optional[bool]=False, skip_pending: Optional[bool]=F :type logger_level: :obj:`int` :param allowed_updates: A list of the update types you want your bot to receive. - For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. - See util.update_types for a complete list of available update types. - Specify an empty list to receive all update types except chat_member (default). + For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. + See util.update_types for a complete list of available update types. + Specify an empty list to receive all update types except chat_member (default). If not specified, the previous setting will be used. - - Please note that this parameter doesn't affect updates created before the call to the get_updates, + + Please note that this parameter doesn't affect updates created before the call to the get_updates, so unwanted updates may be received for a short period of time. :type allowed_updates: :obj:`list` of :obj:`str` @@ -1179,7 +1179,7 @@ def polling(self, non_stop: Optional[bool]=False, skip_pending: Optional[bool]=F :param path_to_watch: Path to watch for changes. Defaults to None :type path_to_watch: :obj:`str` - + :return: """ if none_stop is not None: @@ -1193,7 +1193,7 @@ def polling(self, non_stop: Optional[bool]=False, skip_pending: Optional[bool]=F self._setup_change_detector(path_to_watch) logger.info('Starting your bot with username: [@%s]', self.user.username) - + if self.threaded: self.__threaded_polling(non_stop=non_stop, interval=interval, timeout=timeout, long_polling_timeout=long_polling_timeout, logger_level=logger_level, allowed_updates=allowed_updates) @@ -1386,9 +1386,9 @@ def get_me(self) -> types.User: def get_file(self, file_id: Optional[str]) -> types.File: """ Use this method to get basic info about a file and prepare it for downloading. - For the moment, bots can download files of up to 20MB in size. - On success, a File object is returned. - It is guaranteed that the link will be valid for at least 1 hour. + For the moment, bots can download files of up to 20MB in size. + On success, a File object is returned. + 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 get_file again. Telegram documentation: https://core.telegram.org/bots/api#getfile @@ -1431,11 +1431,11 @@ def download_file(self, file_path: str) -> bytes: def log_out(self) -> bool: """ - Use this method to log out from the cloud Bot API server before launching the bot locally. + Use this method to log out from the cloud Bot API server before launching the bot locally. You MUST log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. - After a successful call, you can immediately log in on a local server, - but will not be able to log in back to the cloud Bot API server for 10 minutes. + After a successful call, you can immediately log in on a local server, + but will not be able to log in back to the cloud Bot API server for 10 minutes. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#logout @@ -1444,14 +1444,14 @@ def log_out(self) -> bool: :rtype: :obj:`bool` """ return apihelper.log_out(self.token) - - + + def close(self) -> bool: """ - Use this method to close the bot instance before moving it from one local server to another. + Use this method to close the bot instance before moving it from one local server to another. You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart. - The method will return error 429 in the first 10 minutes after the bot is launched. + The method will return error 429 in the first 10 minutes after the bot is launched. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#close @@ -1459,10 +1459,10 @@ def close(self) -> bool: :return: :obj:`bool` """ return apihelper.close(self.token) - + def set_message_reaction(self, chat_id: Union[int, str], message_id: int, reaction: Optional[List[types.ReactionType]]=None, is_big: Optional[bool]=None) -> bool: """ - Use this method to change the chosen reactions on a message. + Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Returns True on success. @@ -1487,7 +1487,7 @@ def set_message_reaction(self, chat_id: Union[int, str], message_id: int, reacti self.token, chat_id, message_id, reaction = reaction, is_big = is_big) - def get_user_profile_photos(self, user_id: int, offset: Optional[int]=None, + def get_user_profile_photos(self, user_id: int, offset: Optional[int]=None, limit: Optional[int]=None) -> types.UserProfilePhotos: """ Use this method to get a list of profile pictures for a user. @@ -1531,7 +1531,7 @@ def set_user_emoji_status(self, user_id: int, emoji_status_custom_emoji_id: Opti """ return apihelper.set_user_emoji_status( self.token, user_id, emoji_status_custom_emoji_id=emoji_status_custom_emoji_id, emoji_status_expiration_date=emoji_status_expiration_date) - + def get_chat(self, chat_id: Union[int, str]) -> types.ChatFullInfo: """ @@ -1571,7 +1571,7 @@ def get_chat_administrators(self, chat_id: Union[int, str]) -> List[types.ChatMe On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. - Telegram documentation: https://core.telegram.org/bots/api#getchatadministrators + Telegram documentation: https://core.telegram.org/bots/api#getchatadministrators :param chat_id: Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) @@ -1623,7 +1623,7 @@ def set_chat_sticker_set(self, chat_id: Union[int, str], sticker_set_name: str) Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success. - + Telegram documentation: https://core.telegram.org/bots/api#setchatstickerset :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) @@ -1643,7 +1643,7 @@ def delete_chat_sticker_set(self, chat_id: Union[int, str]) -> bool: Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success. - + Telegram documentation: https://core.telegram.org/bots/api#deletechatstickerset :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) @@ -1658,7 +1658,7 @@ def delete_chat_sticker_set(self, chat_id: Union[int, str]) -> bool: def get_chat_member(self, chat_id: Union[int, str], user_id: int) -> types.ChatMember: """ Use this method to get information about a member of a chat. Returns a ChatMember object on success. - + Telegram documentation: https://core.telegram.org/bots/api#getchatmember :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) @@ -1676,11 +1676,11 @@ def get_chat_member(self, chat_id: Union[int, str], user_id: int) -> types.ChatM def send_message( - self, chat_id: Union[int, str], text: str, - parse_mode: Optional[str]=None, + self, chat_id: Union[int, str], text: str, + parse_mode: Optional[str]=None, entities: Optional[List[types.MessageEntity]]=None, disable_web_page_preview: Optional[bool]=None, # deprecated, for backward compatibility - disable_notification: Optional[bool]=None, + disable_notification: Optional[bool]=None, protect_content: Optional[bool]=None, reply_to_message_id: Optional[int]=None, # deprecated, for backward compatibility allow_sending_without_reply: Optional[bool]=None, # deprecated, for backward compatibility @@ -1698,7 +1698,7 @@ def send_message( Use this method to send text messages. Warning: Do not send more than about 4096 characters each message, otherwise you'll risk an HTTP 414 error. - If you must send more than 4096 characters, + If you must send more than 4096 characters, use the `split_string` or `smart_split` function in util.py. Telegram documentation: https://core.telegram.org/bots/api#sendmessage @@ -1820,7 +1820,7 @@ def send_message( def forward_message( - self, chat_id: Union[int, str], from_chat_id: Union[int, str], + self, chat_id: Union[int, str], from_chat_id: Union[int, str], message_id: int, disable_notification: Optional[bool]=None, protect_content: Optional[bool]=None, timeout: Optional[int]=None, @@ -1883,13 +1883,13 @@ def forward_message( def copy_message( - self, chat_id: Union[int, str], - from_chat_id: Union[int, str], - message_id: int, - caption: Optional[str]=None, - parse_mode: Optional[str]=None, + self, chat_id: Union[int, str], + from_chat_id: Union[int, str], + message_id: int, + caption: Optional[str]=None, + parse_mode: Optional[str]=None, caption_entities: Optional[List[types.MessageEntity]]=None, - disable_notification: Optional[bool]=None, + disable_notification: Optional[bool]=None, protect_content: Optional[bool]=None, reply_to_message_id: Optional[int]=None, # deprecated, for backward compatibility allow_sending_without_reply: Optional[bool]=None, # deprecated, for backward compatibility @@ -1972,11 +1972,11 @@ def copy_message( for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters` - + :return: On success, the MessageId of the sent message is returned. :rtype: :class:`telebot.types.MessageID` """ - + disable_notification = self.disable_notification if (disable_notification is None) else disable_notification parse_mode = self.parse_mode if (parse_mode is None) else parse_mode protect_content = self.protect_content if (protect_content is None) else protect_content @@ -2054,7 +2054,7 @@ def decline_suggested_post(self, chat_id: int, message_id: int, comment: Optiona return apihelper.decline_suggested_post(self.token, chat_id, message_id, comment=comment) - def delete_message(self, chat_id: Union[int, str], message_id: int, + def delete_message(self, chat_id: Union[int, str], message_id: int, timeout: Optional[int]=None) -> bool: """ Use this method to delete a message, including service messages, with the following limitations: @@ -2083,7 +2083,7 @@ def delete_message(self, chat_id: Union[int, str], message_id: int, """ return apihelper.delete_message(self.token, chat_id, message_id, timeout=timeout) - + def delete_messages(self, chat_id: Union[int, str], message_ids: List[int]): """ Use this method to delete multiple messages simultaneously. If some of the specified messages can't be found, they are skipped. @@ -2101,7 +2101,7 @@ def delete_messages(self, chat_id: Union[int, str], message_ids: List[int]): """ return apihelper.delete_messages(self.token, chat_id, message_ids) - + def forward_messages(self, chat_id: Union[str, int], from_chat_id: Union[str, int], message_ids: List[int], disable_notification: Optional[bool]=None, message_thread_id: Optional[int]=None, protect_content: Optional[bool]=None, direct_messages_topic_id: Optional[int]=None) -> List[types.MessageID]: @@ -2147,7 +2147,7 @@ def forward_messages(self, chat_id: Union[str, int], from_chat_id: Union[str, in protect_content=protect_content, direct_messages_topic_id=direct_messages_topic_id) return [types.MessageID.de_json(message_id) for message_id in result] - + def copy_messages(self, chat_id: Union[str, int], from_chat_id: Union[str, int], message_ids: List[int], disable_notification: Optional[bool] = None, message_thread_id: Optional[int] = None, protect_content: Optional[bool] = None, remove_caption: Optional[bool] = None, @@ -2198,7 +2198,7 @@ def copy_messages(self, chat_id: Union[str, int], from_chat_id: Union[str, int], message_thread_id=message_thread_id, protect_content=protect_content, remove_caption=remove_caption, direct_messages_topic_id=direct_messages_topic_id) return [types.MessageID.de_json(message_id) for message_id in result] - + def send_checklist( self, business_connection_id: str, chat_id: Union[int, str], checklist: types.InputChecklist, @@ -2242,7 +2242,7 @@ def send_checklist( """ disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + if reply_parameters and (reply_parameters.allow_sending_without_reply is None): reply_parameters.allow_sending_without_reply = self.allow_sending_without_reply @@ -2251,7 +2251,7 @@ def send_checklist( self.token, business_connection_id, chat_id, checklist, disable_notification=disable_notification, protect_content=protect_content, message_effect_id=message_effect_id, reply_parameters=reply_parameters, reply_markup=reply_markup)) - + def edit_message_checklist( self, business_connection_id: str, chat_id: Union[int, str], message_id: int, checklist: types.InputChecklist, @@ -2286,9 +2286,9 @@ def edit_message_checklist( def send_dice( self, chat_id: Union[int, str], - emoji: Optional[str]=None, disable_notification: Optional[bool]=None, + emoji: Optional[str]=None, disable_notification: Optional[bool]=None, reply_to_message_id: Optional[int]=None, # deprecated, for backward compatibility - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, timeout: Optional[int]=None, allow_sending_without_reply: Optional[bool]=None, # deprecated, for backward compatibility protect_content: Optional[bool]=None, @@ -2393,7 +2393,7 @@ def send_dice( def send_photo( - self, chat_id: Union[int, str], photo: Union[Any, str], + self, chat_id: Union[int, str], photo: Union[Any, str], caption: Optional[str]=None, parse_mode: Optional[str]=None, caption_entities: Optional[List[types.MessageEntity]]=None, disable_notification: Optional[bool]=None, @@ -2415,7 +2415,7 @@ def send_photo( Use this method to send photos. On success, the sent Message is returned. Telegram documentation: https://core.telegram.org/bots/api#sendphoto - + :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` @@ -2483,7 +2483,7 @@ def send_photo( for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters` - + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -2522,14 +2522,14 @@ def send_photo( ) def send_audio( - self, chat_id: Union[int, str], audio: Union[Any, str], - caption: Optional[str]=None, duration: Optional[int]=None, + self, chat_id: Union[int, str], audio: Union[Any, str], + caption: Optional[str]=None, duration: Optional[int]=None, performer: Optional[str]=None, title: Optional[str]=None, reply_to_message_id: Optional[int]=None, # deprecated, for backward compatibility - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, - parse_mode: Optional[str]=None, + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + parse_mode: Optional[str]=None, disable_notification: Optional[bool]=None, - timeout: Optional[int]=None, + timeout: Optional[int]=None, thumbnail: Optional[Union[Any, str]]=None, caption_entities: Optional[List[types.MessageEntity]]=None, allow_sending_without_reply: Optional[bool]=None, # deprecated, for backward compatibility @@ -2550,7 +2550,7 @@ def send_audio( For sending voice messages, use the send_voice method instead. Telegram documentation: https://core.telegram.org/bots/api#sendaudio - + :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` @@ -2671,12 +2671,12 @@ def send_audio( ) def send_voice( - self, chat_id: Union[int, str], voice: Union[Any, str], - caption: Optional[str]=None, duration: Optional[int]=None, + self, chat_id: Union[int, str], voice: Union[Any, str], + caption: Optional[str]=None, duration: Optional[int]=None, reply_to_message_id: Optional[int]=None, # deprecated, for backward compatibility reply_markup: Optional[REPLY_MARKUP_TYPES]=None, - parse_mode: Optional[str]=None, - disable_notification: Optional[bool]=None, + parse_mode: Optional[str]=None, + disable_notification: Optional[bool]=None, timeout: Optional[int]=None, caption_entities: Optional[List[types.MessageEntity]]=None, allow_sending_without_reply: Optional[bool]=None, # deprecated, for backward compatibility @@ -2692,7 +2692,7 @@ def send_voice( Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS, or in .MP3 format, or in .M4A format (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. Telegram documentation: https://core.telegram.org/bots/api#sendvoice - + :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` @@ -2796,11 +2796,11 @@ def send_voice( def send_document( self, chat_id: Union[int, str], document: Union[Any, str], reply_to_message_id: Optional[int]=None, # deprecated, for backward compatibility - caption: Optional[str]=None, + caption: Optional[str]=None, reply_markup: Optional[REPLY_MARKUP_TYPES]=None, - parse_mode: Optional[str]=None, - disable_notification: Optional[bool]=None, - timeout: Optional[int]=None, + parse_mode: Optional[str]=None, + disable_notification: Optional[bool]=None, + timeout: Optional[int]=None, thumbnail: Optional[Union[Any, str]]=None, caption_entities: Optional[List[types.MessageEntity]]=None, allow_sending_without_reply: Optional[bool]=None, # deprecated, for backward compatibility @@ -2819,7 +2819,7 @@ def send_document( Use this method to send general files. Telegram documentation: https://core.telegram.org/bots/api#senddocument - + :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` @@ -3054,7 +3054,7 @@ def send_sticker( if data and (not sticker): logger.warning('The parameter "data" is deprecated. Use "sticker" instead.') sticker = data - + return types.Message.de_json( apihelper.send_data( self.token, chat_id, sticker, 'sticker', @@ -3067,15 +3067,15 @@ def send_sticker( def send_video( - self, chat_id: Union[int, str], video: Union[Any, str], + self, chat_id: Union[int, str], video: Union[Any, str], duration: Optional[int]=None, width: Optional[int]=None, height: Optional[int]=None, - thumbnail: Optional[Union[Any, str]]=None, - caption: Optional[str]=None, - parse_mode: Optional[str]=None, + thumbnail: Optional[Union[Any, str]]=None, + caption: Optional[str]=None, + parse_mode: Optional[str]=None, caption_entities: Optional[List[types.MessageEntity]]=None, - supports_streaming: Optional[bool]=None, + supports_streaming: Optional[bool]=None, disable_notification: Optional[bool]=None, protect_content: Optional[bool]=None, reply_to_message_id: Optional[int]=None, # deprecated, for backward compatibility @@ -3097,7 +3097,7 @@ def send_video( suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message: """ Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). - + Telegram documentation: https://core.telegram.org/bots/api#sendvideo :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) @@ -3127,7 +3127,7 @@ def send_video( :param start_timestamp: Start timestamp for the video in the message :type start_timestamp: :obj:`int` - + :param caption: Video caption (may also be used when resending videos by file_id), 0-1024 characters after entities parsing :type caption: :obj:`str` @@ -3245,19 +3245,19 @@ def send_video( def send_animation( - self, chat_id: Union[int, str], animation: Union[Any, str], + self, chat_id: Union[int, str], animation: Union[Any, str], duration: Optional[int]=None, width: Optional[int]=None, height: Optional[int]=None, thumbnail: Optional[Union[Any, str]]=None, - caption: Optional[str]=None, + caption: Optional[str]=None, parse_mode: Optional[str]=None, caption_entities: Optional[List[types.MessageEntity]]=None, disable_notification: Optional[bool]=None, protect_content: Optional[bool]=None, reply_to_message_id: Optional[int]=None, # deprecated, for backward compatibility allow_sending_without_reply: Optional[bool]=None, # deprecated, for backward compatibility - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, timeout: Optional[int]=None, message_thread_id: Optional[int]=None, has_spoiler: Optional[bool]=None, @@ -3272,7 +3272,7 @@ def send_animation( """ Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. - + Telegram documentation: https://core.telegram.org/bots/api#sendanimation :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) @@ -3290,7 +3290,7 @@ def send_animation( :param height: Animation height :type height: :obj:`int` - + :param thumbnail: 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, @@ -3402,13 +3402,13 @@ def send_animation( def send_video_note( - self, chat_id: Union[int, str], data: Union[Any, str], - duration: Optional[int]=None, + self, chat_id: Union[int, str], data: Union[Any, str], + duration: Optional[int]=None, length: Optional[int]=None, reply_to_message_id: Optional[int]=None, # deprecated, for backward compatibility reply_markup: Optional[REPLY_MARKUP_TYPES]=None, - disable_notification: Optional[bool]=None, - timeout: Optional[int]=None, + disable_notification: Optional[bool]=None, + timeout: Optional[int]=None, thumbnail: Optional[Union[Any, str]]=None, allow_sending_without_reply: Optional[bool]=None, # deprecated, for backward compatibility protect_content: Optional[bool]=None, @@ -3425,10 +3425,10 @@ def send_video_note( Use this method to send video messages. On success, the sent Message is returned. Telegram documentation: https://core.telegram.org/bots/api#sendvideonote - + :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` - + :param data: Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. Sending video notes by a URL is currently unsupported :type data: :obj:`str` or :class:`telebot.types.InputFile` @@ -3459,7 +3459,7 @@ def send_video_note( :param thumbnail: 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 . + so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . :type thumbnail: :obj:`str` or :class:`telebot.types.InputFile` :param protect_content: Protects the contents of the sent message from forwarding and saving @@ -3529,7 +3529,7 @@ def send_video_note( business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast, direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters) ) - + def send_paid_media( self, chat_id: Union[int, str], star_count: int, media: List[types.InputPaidMedia], caption: Optional[str]=None, parse_mode: Optional[str]=None, caption_entities: Optional[List[types.MessageEntity]]=None, @@ -3612,11 +3612,11 @@ def send_paid_media( def send_media_group( - self, chat_id: Union[int, str], + self, chat_id: Union[int, str], media: List[Union[ - types.InputMediaAudio, types.InputMediaDocument, + types.InputMediaAudio, types.InputMediaDocument, types.InputMediaPhoto, types.InputMediaVideo]], - disable_notification: Optional[bool]=None, + disable_notification: Optional[bool]=None, protect_content: Optional[bool]=None, reply_to_message_id: Optional[int]=None, # deprecated, for backward compatibility timeout: Optional[int]=None, @@ -3630,7 +3630,7 @@ def send_media_group( """ Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned. - + Telegram documentation: https://core.telegram.org/bots/api#sendmediagroup :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) @@ -3713,17 +3713,17 @@ def send_media_group( def send_location( - self, chat_id: Union[int, str], - latitude: float, longitude: float, + self, chat_id: Union[int, str], + latitude: float, longitude: float, live_period: Optional[int]=None, - reply_to_message_id: Optional[int]=None, # deprecated, for backward compatibility - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, - disable_notification: Optional[bool]=None, + reply_to_message_id: Optional[int]=None, # deprecated, for backward compatibility + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + disable_notification: Optional[bool]=None, timeout: Optional[int]=None, - horizontal_accuracy: Optional[float]=None, - heading: Optional[int]=None, + horizontal_accuracy: Optional[float]=None, + heading: Optional[int]=None, proximity_alert_radius: Optional[int]=None, - allow_sending_without_reply: Optional[bool]=None, # deprecated, for backward compatibility + allow_sending_without_reply: Optional[bool]=None, # deprecated, for backward compatibility protect_content: Optional[bool]=None, message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, @@ -3839,14 +3839,14 @@ def send_location( def edit_message_live_location( - self, latitude: float, longitude: float, - chat_id: Optional[Union[int, str]]=None, + self, latitude: float, longitude: float, + chat_id: Optional[Union[int, str]]=None, message_id: Optional[int]=None, - inline_message_id: Optional[str]=None, + inline_message_id: Optional[str]=None, reply_markup: Optional[types.InlineKeyboardMarkup]=None, timeout: Optional[int]=None, - horizontal_accuracy: Optional[float]=None, - heading: Optional[int]=None, + horizontal_accuracy: Optional[float]=None, + heading: Optional[int]=None, proximity_alert_radius: Optional[int]=None, live_period: Optional[int]=None, business_connection_id: Optional[str]=None @@ -3907,9 +3907,9 @@ def edit_message_live_location( def stop_message_live_location( - self, chat_id: Optional[Union[int, str]]=None, + self, chat_id: Optional[Union[int, str]]=None, message_id: Optional[int]=None, - inline_message_id: Optional[str]=None, + inline_message_id: Optional[str]=None, reply_markup: Optional[types.InlineKeyboardMarkup]=None, timeout: Optional[int]=None, business_connection_id: Optional[str]=None) -> Union[types.Message, bool]: @@ -3918,7 +3918,7 @@ def stop_message_live_location( On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned. Telegram documentation: https://core.telegram.org/bots/api#stopmessagelivelocation - + :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` @@ -3949,14 +3949,14 @@ def stop_message_live_location( def send_venue( - self, chat_id: Union[int, str], - latitude: Optional[float], longitude: Optional[float], - title: str, address: str, - foursquare_id: Optional[str]=None, + self, chat_id: Union[int, str], + latitude: Optional[float], longitude: Optional[float], + title: str, address: str, + foursquare_id: Optional[str]=None, foursquare_type: Optional[str]=None, - disable_notification: Optional[bool]=None, + disable_notification: Optional[bool]=None, reply_to_message_id: Optional[int]=None, # deprecated, for backward compatibility - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, timeout: Optional[int]=None, allow_sending_without_reply: Optional[bool]=None, # deprecated, for backward compatibility google_place_id: Optional[str]=None, @@ -3971,12 +3971,12 @@ def send_venue( suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message: """ Use this method to send information about a venue. On success, the sent Message is returned. - + Telegram documentation: https://core.telegram.org/bots/api#sendvenue :param chat_id: Unique identifier for the target chat or username of the target channel :type chat_id: :obj:`int` or :obj:`str` - + :param latitude: Latitude of the venue :type latitude: :obj:`float` @@ -4083,12 +4083,12 @@ def send_venue( def send_contact( - self, chat_id: Union[int, str], phone_number: str, - first_name: str, last_name: Optional[str]=None, + self, chat_id: Union[int, str], phone_number: str, + first_name: str, last_name: Optional[str]=None, vcard: Optional[str]=None, - disable_notification: Optional[bool]=None, + disable_notification: Optional[bool]=None, reply_to_message_id: Optional[int]=None, # deprecated, for backward compatibility - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, timeout: Optional[int]=None, allow_sending_without_reply: Optional[bool]=None, # deprecated, for backward compatibility protect_content: Optional[bool]=None, message_thread_id: Optional[int]=None, @@ -4212,7 +4212,7 @@ def send_chat_action( :param chat_id: Unique identifier for the target chat or username of the target channel :type chat_id: :obj:`int` or :obj:`str` - + :param action: Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, @@ -4234,11 +4234,11 @@ def send_chat_action( return apihelper.send_chat_action( self.token, chat_id, action, timeout=timeout, message_thread_id=message_thread_id, business_connection_id=business_connection_id) - + @util.deprecated(deprecation_text="Use ban_chat_member instead") def kick_chat_member( - self, chat_id: Union[int, str], user_id: int, - until_date:Optional[Union[int, datetime]]=None, + self, chat_id: Union[int, str], user_id: int, + until_date:Optional[Union[int, datetime]]=None, revoke_messages: Optional[bool]=None) -> bool: """ This function is deprecated. Use `ban_chat_member` instead. @@ -4248,13 +4248,13 @@ def kick_chat_member( def ban_chat_member( - self, chat_id: Union[int, str], user_id: int, - until_date: Optional[Union[int, datetime]]=None, + self, chat_id: Union[int, str], user_id: int, + until_date: Optional[Union[int, datetime]]=None, revoke_messages: Optional[bool]=None) -> bool: """ - Use this method to ban a user in a group, a supergroup or a channel. - In the case of supergroups and channels, the user will not be able to return to the chat on their - own using invite links, etc., unless unbanned first. + Use this method to ban a user in a group, a supergroup or a channel. + In the case of supergroups and channels, the user will not be able to return to the chat on their + own using invite links, etc., unless unbanned first. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#banchatmember @@ -4271,10 +4271,10 @@ def ban_chat_member( :type until_date: :obj:`int` or :obj:`datetime` :param revoke_messages: Pass True to delete all messages from the chat for the user that is being removed. - If False, the user will be able to see messages in the group that were sent before the user was removed. + If False, the user will be able to see messages in the group that were sent before the user was removed. Always True for supergroups and channels. :type revoke_messages: :obj:`bool` - + :return: Returns True on success. :rtype: :obj:`bool` """ @@ -4283,7 +4283,7 @@ def ban_chat_member( def unban_chat_member( - self, chat_id: Union[int, str], user_id: int, + self, chat_id: Union[int, str], user_id: int, only_if_banned: Optional[bool]=False) -> bool: """ Use this method to unban a previously kicked user in a supergroup or channel. @@ -4311,15 +4311,15 @@ def unban_chat_member( def restrict_chat_member( - self, chat_id: Union[int, str], user_id: int, + self, chat_id: Union[int, str], user_id: int, until_date: Optional[Union[int, datetime]]=None, - can_send_messages: Optional[bool]=None, + can_send_messages: Optional[bool]=None, can_send_media_messages: Optional[bool]=None, - can_send_polls: Optional[bool]=None, + can_send_polls: Optional[bool]=None, can_send_other_messages: Optional[bool]=None, - can_add_web_page_previews: Optional[bool]=None, + can_add_web_page_previews: Optional[bool]=None, can_change_info: Optional[bool]=None, - can_invite_users: Optional[bool]=None, + can_invite_users: Optional[bool]=None, can_pin_messages: Optional[bool]=None, permissions: Optional[types.ChatPermissions]=None, use_independent_chat_permissions: Optional[bool]=None) -> bool: @@ -4347,10 +4347,10 @@ def restrict_chat_member( :param can_send_messages: deprecated :type can_send_messages: :obj:`bool` - + :param can_send_media_messages: deprecated :type can_send_media_messages: :obj:`bool` - + :param can_send_polls: deprecated :type can_send_polls: :obj:`bool` @@ -4401,16 +4401,16 @@ def restrict_chat_member( def promote_chat_member( self, chat_id: Union[int, str], user_id: int, - can_change_info: Optional[bool]=None, + can_change_info: Optional[bool]=None, can_post_messages: Optional[bool]=None, - can_edit_messages: Optional[bool]=None, - can_delete_messages: Optional[bool]=None, + can_edit_messages: Optional[bool]=None, + can_delete_messages: Optional[bool]=None, can_invite_users: Optional[bool]=None, - can_restrict_members: Optional[bool]=None, - can_pin_messages: Optional[bool]=None, + can_restrict_members: Optional[bool]=None, + can_pin_messages: Optional[bool]=None, can_promote_members: Optional[bool]=None, - is_anonymous: Optional[bool]=None, - can_manage_chat: Optional[bool]=None, + is_anonymous: Optional[bool]=None, + can_manage_chat: Optional[bool]=None, can_manage_video_chats: Optional[bool]=None, can_manage_voice_chats: Optional[bool]=None, can_manage_topics: Optional[bool]=None, @@ -4461,9 +4461,9 @@ def promote_chat_member( :param is_anonymous: Pass True, if the administrator's presence in the chat is hidden :type is_anonymous: :obj:`bool` - :param can_manage_chat: Pass 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. + :param can_manage_chat: Pass 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` @@ -4535,14 +4535,14 @@ def set_chat_administrator_custom_title( """ return apihelper.set_chat_administrator_custom_title(self.token, chat_id, user_id, custom_title) - + def ban_chat_sender_chat(self, chat_id: Union[int, str], sender_chat_id: Union[int, str]) -> bool: """ Use this method to ban a channel chat in a supergroup or a channel. - The owner of the chat will not be able to send messages and join live - streams on behalf of the chat, unless it is unbanned first. - The bot must be an administrator in the supergroup or channel - for this to work and must have the appropriate administrator rights. + The owner of the chat will not be able to send messages and join live + streams on behalf of the chat, unless it is unbanned first. + The bot must be an administrator in the supergroup or channel + for this to work and must have the appropriate administrator rights. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#banchatsenderchat @@ -4561,8 +4561,8 @@ def ban_chat_sender_chat(self, chat_id: Union[int, str], sender_chat_id: Union[i def unban_chat_sender_chat(self, chat_id: Union[int, str], sender_chat_id: Union[int, str]) -> bool: """ - Use this method to unban a previously banned channel chat in a supergroup or channel. - The bot must be an administrator for this to work and must have the appropriate + Use this method to unban a previously banned channel chat in a supergroup or channel. + The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns True on success. @@ -4613,7 +4613,7 @@ def set_chat_permissions( def create_chat_invite_link( self, chat_id: Union[int, str], name: Optional[str]=None, - expire_date: Optional[Union[int, datetime]]=None, + expire_date: Optional[Union[int, datetime]]=None, member_limit: Optional[int]=None, creates_join_request: Optional[bool]=None) -> types.ChatInviteLink: """ @@ -4700,7 +4700,7 @@ def create_chat_subscription_invite_link( :param chat_id: Unique identifier for the target channel chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` - + :param name: Invite link name; 0-32 characters :type name: :obj:`str` @@ -4718,7 +4718,7 @@ def create_chat_subscription_invite_link( return types.ChatInviteLink.de_json( apihelper.create_chat_subscription_invite_link(self.token, chat_id, subscription_period, subscription_price, name=name) ) - + def edit_chat_subscription_invite_link( self, chat_id: Union[int, str], invite_link: str, name: Optional[str]=None) -> types.ChatInviteLink: """ @@ -4748,7 +4748,7 @@ def revoke_chat_invite_link( self, chat_id: Union[int, str], invite_link: str) -> types.ChatInviteLink: """ Use this method to revoke an invite link created by the bot. - Note: If the primary link is revoked, a new link is automatically generated The bot must be an administrator + Note: If the primary link is revoked, a new link is automatically generated The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Telegram documentation: https://core.telegram.org/bots/api#revokechatinvitelink @@ -4787,7 +4787,7 @@ def export_chat_invite_link(self, chat_id: Union[int, str]) -> str: def approve_chat_join_request(self, chat_id: Union[str, int], user_id: Union[int, str]) -> bool: """ - Use this method to approve a chat join request. + Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success. @@ -4808,7 +4808,7 @@ def approve_chat_join_request(self, chat_id: Union[str, int], user_id: Union[int def decline_chat_join_request(self, chat_id: Union[str, int], user_id: Union[int, str]) -> bool: """ - Use this method to decline a chat join request. + Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success. @@ -4867,21 +4867,21 @@ def delete_chat_photo(self, chat_id: Union[int, str]) -> bool: """ return apihelper.delete_chat_photo(self.token, chat_id) - - def get_my_commands(self, scope: Optional[types.BotCommandScope]=None, + + def get_my_commands(self, scope: Optional[types.BotCommandScope]=None, language_code: Optional[str]=None) -> List[types.BotCommand]: """ - Use this method to get the current list of the bot's commands. + Use this method to get the current list of the bot's commands. Returns List of BotCommand on success. Telegram documentation: https://core.telegram.org/bots/api#getmycommands - :param scope: The scope of users for which the commands are relevant. + :param scope: The scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault. :type scope: :class:`telebot.types.BotCommandScope` - :param language_code: A two-letter ISO 639-1 language code. If empty, - commands will be applied to all users from the given scope, + :param language_code: A two-letter ISO 639-1 language code. If empty, + commands will be applied to all users from the given scope, for whose language there are no dedicated commands :type language_code: :obj:`str` @@ -4909,7 +4909,7 @@ def set_my_name(self, name: Optional[str]=None, language_code: Optional[str]=Non """ return apihelper.set_my_name(self.token, name=name, language_code=language_code) - + def get_my_name(self, language_code: Optional[str]=None): """ Use this method to get the current bot name for the given user language. @@ -4948,7 +4948,7 @@ def set_my_description(self, description: Optional[str]=None, language_code: Opt return apihelper.set_my_description( self.token, description=description, language_code=language_code) - + def get_my_description(self, language_code: Optional[str]=None): """ Use this method to get the current bot description for the given user language. @@ -4964,11 +4964,11 @@ def get_my_description(self, language_code: Optional[str]=None): return types.BotDescription.de_json( apihelper.get_my_description(self.token, language_code=language_code)) - + def set_my_short_description(self, short_description:Optional[str]=None, language_code:Optional[str]=None): """ Use this method to change the bot's short description, which is shown on the bot's profile page and - is sent together with the link when users share the bot. + is sent together with the link when users share the bot. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#setmyshortdescription @@ -4985,7 +4985,7 @@ def set_my_short_description(self, short_description:Optional[str]=None, languag return apihelper.set_my_short_description( self.token, short_description=short_description, language_code=language_code) - + def get_my_short_description(self, language_code: Optional[str]=None): """ Use this method to get the current bot short description for the given user language. @@ -5004,13 +5004,13 @@ def get_my_short_description(self, language_code: Optional[str]=None): def set_chat_menu_button(self, chat_id: Union[int, str]=None, menu_button: types.MenuButton=None) -> bool: """ - Use this method to change the bot's menu button in a private chat, - or the default menu button. + Use this method to change the bot's menu button in a private chat, + or the default menu button. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#setchatmenubutton - :param chat_id: Unique identifier for the target private chat. + :param chat_id: Unique identifier for the target private chat. If not specified, default bot's menu button will be changed. :type chat_id: :obj:`int` or :obj:`str` @@ -5042,13 +5042,13 @@ def get_chat_menu_button(self, chat_id: Union[int, str]=None) -> types.MenuButto apihelper.get_chat_menu_button(self.token, chat_id=chat_id)) - def set_my_default_administrator_rights(self, rights: types.ChatAdministratorRights=None, + def set_my_default_administrator_rights(self, rights: types.ChatAdministratorRights=None, for_channels: Optional[bool]=None) -> bool: """ Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are are free to modify - the list before adding the bot. + the list before adding the bot. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#setmydefaultadministratorrights @@ -5102,8 +5102,8 @@ def get_business_connection(self, business_connection_id: str) -> types.Business return types.BusinessConnection.de_json( apihelper.get_business_connection(self.token, business_connection_id) ) - - + + def set_my_commands(self, commands: List[types.BotCommand], scope: Optional[types.BotCommandScope]=None, language_code: Optional[str]=None) -> bool: @@ -5115,12 +5115,12 @@ def set_my_commands(self, commands: List[types.BotCommand], :param commands: List of BotCommand. At most 100 commands can be specified. :type commands: :obj:`list` of :class:`telebot.types.BotCommand` - :param scope: The scope of users for which the commands are relevant. + :param scope: The scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault. :type scope: :class:`telebot.types.BotCommandScope` - :param language_code: A two-letter ISO 639-1 language code. If empty, - commands will be applied to all users from the given scope, + :param language_code: A two-letter ISO 639-1 language code. If empty, + commands will be applied to all users from the given scope, for whose language there are no dedicated commands :type language_code: :obj:`str` @@ -5129,22 +5129,22 @@ def set_my_commands(self, commands: List[types.BotCommand], """ return apihelper.set_my_commands(self.token, commands, scope=scope, language_code=language_code) - - def delete_my_commands(self, scope: Optional[types.BotCommandScope]=None, + + def delete_my_commands(self, scope: Optional[types.BotCommandScope]=None, language_code: Optional[str]=None) -> bool: """ - Use this method to delete the list of the bot's commands for the given scope and user language. - After deletion, higher level commands will be shown to affected users. + Use this method to delete the list of the bot's commands for the given scope and user language. + After deletion, higher level commands will be shown to affected users. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#deletemycommands - - :param scope: The scope of users for which the commands are relevant. + + :param scope: The scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault. :type scope: :class:`telebot.types.BotCommandScope` - :param language_code: A two-letter ISO 639-1 language code. If empty, - commands will be applied to all users from the given scope, + :param language_code: A two-letter ISO 639-1 language code. If empty, + commands will be applied to all users from the given scope, for whose language there are no dedicated commands :type language_code: :obj:`str` @@ -5198,7 +5198,7 @@ def set_chat_description(self, chat_id: Union[int, str], description: Optional[s def pin_chat_message( - self, chat_id: Union[int, str], message_id: int, + self, chat_id: Union[int, str], message_id: int, disable_notification: Optional[bool]=False, business_connection_id: Optional[str]=None) -> bool: """ Use this method to pin a message in a supergroup. @@ -5273,10 +5273,10 @@ def unpin_all_chat_messages(self, chat_id: Union[int, str]) -> bool: def edit_message_text( - self, text: str, - chat_id: Optional[Union[int, str]]=None, - message_id: Optional[int]=None, - inline_message_id: Optional[str]=None, + self, text: str, + chat_id: Optional[Union[int, str]]=None, + message_id: Optional[int]=None, + inline_message_id: Optional[str]=None, parse_mode: Optional[str]=None, entities: Optional[List[types.MessageEntity]]=None, disable_web_page_preview: Optional[bool]=None, # deprecated, for backward compatibility @@ -5326,7 +5326,7 @@ def edit_message_text( :rtype: :obj:`types.Message` or :obj:`bool` """ parse_mode = self.parse_mode if (parse_mode is None) else parse_mode - + if disable_web_page_preview is not None: # show a deprecation warning logger.warning("The parameter 'disable_web_page_preview' is deprecated. Use 'link_preview_options' instead.") @@ -5357,9 +5357,9 @@ def edit_message_text( def edit_message_media( - self, media: Any, chat_id: Optional[Union[int, str]]=None, + self, media: Any, chat_id: Optional[Union[int, str]]=None, message_id: Optional[int]=None, - inline_message_id: Optional[str]=None, + inline_message_id: Optional[str]=None, reply_markup: Optional[types.InlineKeyboardMarkup]=None, business_connection_id: Optional[str]=None, timeout: Optional[int]=None) -> Union[types.Message, bool]: @@ -5368,7 +5368,7 @@ def edit_message_media( If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. - Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. Telegram documentation: https://core.telegram.org/bots/api#editmessagemedia @@ -5377,7 +5377,7 @@ def edit_message_media( :param chat_id: Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` - :param message_id: Required if inline_message_id is not specified. Identifier of the sent message + :param message_id: Required if inline_message_id is not specified. Identifier of the sent message :type message_id: :obj:`int` :param inline_message_id: Required if chat_id and message_id are not specified. Identifier of the inline message @@ -5405,9 +5405,9 @@ def edit_message_media( def edit_message_reply_markup( - self, chat_id: Optional[Union[int, str]]=None, + self, chat_id: Optional[Union[int, str]]=None, message_id: Optional[int]=None, - inline_message_id: Optional[str]=None, + inline_message_id: Optional[str]=None, reply_markup: Optional[types.InlineKeyboardMarkup]=None, business_connection_id: Optional[str]=None, timeout: Optional[int]=None) -> Union[types.Message, bool]: @@ -5447,10 +5447,10 @@ def edit_message_reply_markup( def send_game( - self, chat_id: Union[int, str], game_short_name: str, + self, chat_id: Union[int, str], game_short_name: str, disable_notification: Optional[bool]=None, reply_to_message_id: Optional[int]=None, # deprecated, for backward compatibility - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, timeout: Optional[int]=None, allow_sending_without_reply: Optional[bool]=None, # deprecated, for backward compatibility protect_content: Optional[bool]=None, @@ -5541,10 +5541,10 @@ def send_game( def set_game_score( - self, user_id: Union[int, str], score: int, - force: Optional[bool]=None, - chat_id: Optional[Union[int, str]]=None, - message_id: Optional[int]=None, + self, user_id: Union[int, str], score: int, + force: Optional[bool]=None, + chat_id: Optional[Union[int, str]]=None, + message_id: Optional[int]=None, inline_message_id: Optional[str]=None, disable_edit_message: Optional[bool]=None) -> Union[types.Message, bool]: """ @@ -5587,7 +5587,7 @@ def set_game_score( def get_game_high_scores( self, user_id: int, chat_id: Optional[Union[int, str]]=None, - message_id: Optional[int]=None, + message_id: Optional[int]=None, inline_message_id: Optional[str]=None) -> List[types.GameHighScore]: """ Use this method to get data for high score tables. Will return the score of the specified user and several of @@ -5620,20 +5620,20 @@ def get_game_high_scores( def send_invoice( - self, chat_id: Union[int, str], title: str, description: str, - invoice_payload: str, provider_token: Union[str, None], currency: str, - prices: List[types.LabeledPrice], start_parameter: Optional[str]=None, - photo_url: Optional[str]=None, photo_size: Optional[int]=None, + self, chat_id: Union[int, str], title: str, description: str, + invoice_payload: str, provider_token: Union[str, None], currency: str, + prices: List[types.LabeledPrice], start_parameter: Optional[str]=None, + photo_url: Optional[str]=None, photo_size: Optional[int]=None, photo_width: Optional[int]=None, photo_height: Optional[int]=None, - need_name: Optional[bool]=None, need_phone_number: Optional[bool]=None, + need_name: Optional[bool]=None, need_phone_number: Optional[bool]=None, need_email: Optional[bool]=None, need_shipping_address: Optional[bool]=None, - send_phone_number_to_provider: Optional[bool]=None, - send_email_to_provider: Optional[bool]=None, + send_phone_number_to_provider: Optional[bool]=None, + send_email_to_provider: Optional[bool]=None, is_flexible: Optional[bool]=None, - disable_notification: Optional[bool]=None, + disable_notification: Optional[bool]=None, reply_to_message_id: Optional[int]=None, # deprecated, for backward compatibility - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, - provider_data: Optional[str]=None, + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + provider_data: Optional[str]=None, timeout: Optional[int]=None, allow_sending_without_reply: Optional[bool]=None, # deprecated, for backward compatibility max_tip_amount: Optional[int] = None, @@ -5686,7 +5686,7 @@ def send_invoice( :param photo_size: Photo size in bytes :type photo_size: :obj:`int` - :param photo_width: Photo width + :param photo_width: Photo width :type photo_width: :obj:`int` :param photo_height: Photo height @@ -5810,9 +5810,9 @@ def send_invoice( ) def create_invoice_link(self, - title: str, description: str, payload:str, provider_token: Union[str, None], + title: str, description: str, payload:str, provider_token: Union[str, None], currency: str, prices: List[types.LabeledPrice], - max_tip_amount: Optional[int] = None, + max_tip_amount: Optional[int] = None, suggested_tip_amounts: Optional[List[int]]=None, provider_data: Optional[str]=None, photo_url: Optional[str]=None, @@ -5828,9 +5828,9 @@ def create_invoice_link(self, is_flexible: Optional[bool]=None, subscription_period: Optional[int]=None, business_connection_id: Optional[str]=None) -> str: - + """ - Use this method to create a link for an invoice. + Use this method to create a link for an invoice. Returns the created invoice link as String on success. Telegram documentation: @@ -5929,17 +5929,17 @@ def create_invoice_link(self, # noinspection PyShadowingBuiltins def send_poll( self, chat_id: Union[int, str], question: str, options: List[Union[str, types.InputPollOption]], - is_anonymous: Optional[bool]=None, type: Optional[str]=None, - allows_multiple_answers: Optional[bool]=None, + is_anonymous: Optional[bool]=None, type: Optional[str]=None, + allows_multiple_answers: Optional[bool]=None, correct_option_id: Optional[int]=None, - explanation: Optional[str]=None, - explanation_parse_mode: Optional[str]=None, - open_period: Optional[int]=None, - close_date: Optional[Union[int, datetime]]=None, + explanation: Optional[str]=None, + explanation_parse_mode: Optional[str]=None, + open_period: Optional[int]=None, + close_date: Optional[Union[int, datetime]]=None, is_closed: Optional[bool]=None, disable_notification: Optional[bool]=False, reply_to_message_id: Optional[int]=None, # deprecated, for backward compatibility - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, allow_sending_without_reply: Optional[bool]=None, # deprecated, for backward compatibility timeout: Optional[int]=None, explanation_entities: Optional[List[types.MessageEntity]]=None, @@ -6096,7 +6096,7 @@ def send_poll( def stop_poll( - self, chat_id: Union[int, str], message_id: int, + self, chat_id: Union[int, str], message_id: int, reply_markup: Optional[types.InlineKeyboardMarkup]=None, business_connection_id: Optional[str]=None) -> types.Poll: """ @@ -6125,8 +6125,8 @@ def stop_poll( def answer_shipping_query( - self, shipping_query_id: str, ok: bool, - shipping_options: Optional[List[types.ShippingOption]]=None, + self, shipping_query_id: str, ok: bool, + shipping_options: Optional[List[types.ShippingOption]]=None, error_message: Optional[str]=None) -> bool: """ Asks for an answer to a shipping question. @@ -6154,7 +6154,7 @@ def answer_shipping_query( def answer_pre_checkout_query( - self, pre_checkout_query_id: str, ok: bool, + self, pre_checkout_query_id: str, ok: bool, error_message: Optional[str]=None) -> bool: """ Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the @@ -6166,7 +6166,7 @@ def answer_pre_checkout_query( Telegram documentation: https://core.telegram.org/bots/api#answerprecheckoutquery - :param pre_checkout_query_id: Unique identifier for the query to be answered + :param pre_checkout_query_id: Unique identifier for the query to be answered :type pre_checkout_query_id: :obj:`int` :param ok: Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems. @@ -6182,11 +6182,11 @@ def answer_pre_checkout_query( """ return apihelper.answer_pre_checkout_query( self.token, pre_checkout_query_id, ok, error_message=error_message) - + def get_my_star_balance(self) -> types.StarAmount: """ Returns the bot's current Telegram Stars balance. On success, returns a StarAmount object. - + Telegram documentation: https://core.telegram.org/bots/api#getmystarbalance :return: On success, returns a StarAmount object. @@ -6213,8 +6213,8 @@ def get_star_transactions(self, offset: Optional[int]=None, limit: Optional[int] return types.StarTransactions.de_json( apihelper.get_star_transactions(self.token, offset=offset, limit=limit) ) - - + + def refund_star_payment(self, user_id: int, telegram_payment_charge_id: str) -> bool: """ Refunds a successful payment in Telegram Stars. Returns True on success. @@ -6253,10 +6253,10 @@ def edit_user_star_subscription(self, user_id: int, telegram_payment_charge_id: return apihelper.edit_user_star_subscription(self.token, user_id, telegram_payment_charge_id, is_canceled) def edit_message_caption( - self, caption: str, chat_id: Optional[Union[int, str]]=None, - message_id: Optional[int]=None, + self, caption: str, chat_id: Optional[Union[int, str]]=None, + message_id: Optional[int]=None, inline_message_id: Optional[str]=None, - parse_mode: Optional[str]=None, + parse_mode: Optional[str]=None, caption_entities: Optional[List[types.MessageEntity]]=None, reply_markup: Optional[types.InlineKeyboardMarkup]=None, show_caption_above_media: Optional[bool]=None, @@ -6348,12 +6348,12 @@ def reply_to(self, message: types.Message, text: str, **kwargs) -> types.Message def answer_inline_query( - self, inline_query_id: str, - results: List[Any], - cache_time: Optional[int]=None, - is_personal: Optional[bool]=None, + self, inline_query_id: str, + results: List[Any], + cache_time: Optional[int]=None, + is_personal: Optional[bool]=None, next_offset: Optional[str]=None, - switch_pm_text: Optional[str]=None, + switch_pm_text: Optional[str]=None, switch_pm_parameter: Optional[str]=None, button: Optional[types.InlineQueryResultsButton]=None) -> bool: """ @@ -6400,7 +6400,7 @@ def answer_inline_query( if not button and (switch_pm_text or switch_pm_parameter): logger.warning("switch_pm_text and switch_pm_parameter are deprecated for answer_inline_query. Use button instead.") button = types.InlineQueryResultsButton(text=switch_pm_text, start_parameter=switch_pm_parameter) - + return apihelper.answer_inline_query( self.token, inline_query_id, results, cache_time=cache_time, is_personal=is_personal, next_offset=next_offset, button=button) @@ -6408,7 +6408,7 @@ def answer_inline_query( def unpin_all_general_forum_topic_messages(self, chat_id: Union[int, str]) -> bool: """ - Use this method to clear the list of pinned messages in a General forum topic. + Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success. @@ -6425,8 +6425,8 @@ def unpin_all_general_forum_topic_messages(self, chat_id: Union[int, str]) -> bo def answer_callback_query( - self, callback_query_id: int, - text: Optional[str]=None, show_alert: Optional[bool]=None, + self, callback_query_id: int, + text: Optional[str]=None, show_alert: Optional[bool]=None, url: Optional[str]=None, cache_time: Optional[int]=None) -> bool: """ Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to @@ -6456,7 +6456,7 @@ def answer_callback_query( return apihelper.answer_callback_query( self.token, callback_query_id, text=text, show_alert=show_alert, url=url, cache_time=cache_time) - + def get_user_chat_boosts(self, chat_id: Union[int, str], user_id: int) -> types.UserChatBoosts: """ Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object. @@ -6479,7 +6479,7 @@ def get_user_chat_boosts(self, chat_id: Union[int, str], user_id: int) -> types. # noinspection PyShadowingBuiltins def set_sticker_set_thumbnail(self, name: str, user_id: int, thumbnail: Union[Any, str]=None, format: Optional[str]=None) -> bool: """ - Use this method to set the thumbnail of a sticker set. + Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#setstickersetthumbnail @@ -6510,11 +6510,11 @@ def set_sticker_set_thumbnail(self, name: str, user_id: int, thumbnail: Union[An return apihelper.set_sticker_set_thumbnail(self.token, name, user_id, thumbnail, format) - + @util.deprecated(deprecation_text="Use set_sticker_set_thumbnail instead") def set_sticker_set_thumb(self, name: str, user_id: int, thumb: Union[Any, str]=None): """ - Use this method to set the thumbnail of a sticker set. + Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#setstickersetthumb @@ -6538,7 +6538,7 @@ def set_sticker_set_thumb(self, name: str, user_id: int, thumb: Union[Any, str]= def get_sticker_set(self, name: str) -> types.StickerSet: """ Use this method to get a sticker set. On success, a StickerSet object is returned. - + Telegram documentation: https://core.telegram.org/bots/api#getstickerset :param name: Sticker set name @@ -6565,7 +6565,7 @@ def get_custom_emoji_stickers(self, custom_emoji_ids: List[str]) -> List[types.S result = apihelper.get_custom_emoji_stickers(self.token, custom_emoji_ids) return [types.Sticker.de_json(sticker) for sticker in result] - + def set_sticker_keywords(self, sticker: str, keywords: List[str]=None) -> bool: """ Use this method to change search keywords assigned to a regular or custom emoji sticker. @@ -6583,7 +6583,7 @@ def set_sticker_keywords(self, sticker: str, keywords: List[str]=None) -> bool: """ return apihelper.set_sticker_keywords(self.token, sticker, keywords=keywords) - + def set_sticker_mask_position(self, sticker: str, mask_position: types.MaskPosition=None) -> bool: """ Use this method to change the mask position of a mask sticker. @@ -6600,7 +6600,7 @@ def set_sticker_mask_position(self, sticker: str, mask_position: types.MaskPosit :rtype: :obj:`bool` """ return apihelper.set_sticker_mask_position(self.token, sticker, mask_position=mask_position) - + def set_custom_emoji_sticker_set_thumbnail(self, name: str, custom_emoji_id: Optional[str]=None) -> bool: """ @@ -6618,7 +6618,7 @@ def set_custom_emoji_sticker_set_thumbnail(self, name: str, custom_emoji_id: Opt """ return apihelper.set_custom_emoji_sticker_set_thumbnail(self.token, name, custom_emoji_id=custom_emoji_id) - + def set_sticker_set_title(self, name: str, title: str) -> bool: """ Use this method to set the title of a created sticker set. @@ -6635,7 +6635,7 @@ def set_sticker_set_title(self, name: str, title: str) -> bool: """ return apihelper.set_sticker_set_title(self.token, name, title) - + def delete_sticker_set(self, name:str) -> bool: """ Use this method to delete a sticker set. Returns True on success. @@ -6648,7 +6648,7 @@ def delete_sticker_set(self, name:str) -> bool: """ return apihelper.delete_sticker_set(self.token, name) - def send_gift(self, user_id: Optional[Union[str, int]] = None, gift_id: str=None, text: Optional[str]=None, text_parse_mode: Optional[str]=None, + def send_gift(self, user_id: Optional[Union[str, int]] = None, gift_id: str=None, text: Optional[str]=None, text_parse_mode: Optional[str]=None, text_entities: Optional[List[types.MessageEntity]]=None, pay_for_upgrade: Optional[bool]=None, chat_id: Optional[Union[str, int]] = None) -> bool: """ @@ -6683,13 +6683,13 @@ def send_gift(self, user_id: Optional[Union[str, int]] = None, gift_id: str=None """ if user_id is None and chat_id is None: raise ValueError("Either user_id or chat_id must be specified.") - + if gift_id is None: raise ValueError("gift_id must be specified.") - + return apihelper.send_gift(self.token, gift_id, text=text, text_parse_mode=text_parse_mode, text_entities=text_entities, pay_for_upgrade=pay_for_upgrade, chat_id=chat_id, user_id=user_id) - + def verify_user(self, user_id: int, custom_description: Optional[str]=None) -> bool: """ Verifies a user on behalf of the organization which is represented by the bot. Returns True on success. @@ -6865,12 +6865,12 @@ def set_business_account_gift_settings( :rtype: :obj:`bool` """ return apihelper.set_business_account_gift_settings(self.token, business_connection_id, show_gift_button, accepted_gift_types) - + def get_business_account_star_balance(self, business_connection_id: str) -> types.StarAmount: """ Returns the amount of Telegram Stars owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns StarAmount on success. - + Telegram documentation: https://core.telegram.org/bots/api#getbusinessaccountstarbalance :param business_connection_id: Unique identifier of the business connection @@ -6882,7 +6882,7 @@ def get_business_account_star_balance(self, business_connection_id: str) -> type return types.StarAmount.de_json( apihelper.get_business_account_star_balance(self.token, business_connection_id) ) - + def transfer_business_account_stars(self, business_connection_id: str, star_count: int) -> bool: """ Transfers Telegram Stars from the business account balance to the bot's balance. Requires the can_transfer_stars business bot right. Returns True on success. @@ -6899,7 +6899,7 @@ def transfer_business_account_stars(self, business_connection_id: str, star_coun :rtype: :obj:`bool` """ return apihelper.transfer_business_account_stars(self.token, business_connection_id, star_count) - + def get_business_account_gifts( self, business_connection_id: str, exclude_unsaved: Optional[bool]=None, @@ -6912,7 +6912,7 @@ def get_business_account_gifts( limit: Optional[int]=None) -> types.OwnedGifts: """ Returns the gifts received and owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns OwnedGifts on success. - + Telegram documentation: https://core.telegram.org/bots/api#getbusinessaccountgifts :param business_connection_id: Unique identifier of the business connection @@ -6975,7 +6975,7 @@ def convert_gift_to_stars(self, business_connection_id: str, owned_gift_id: str) :rtype: :obj:`bool` """ return apihelper.convert_gift_to_stars(self.token, business_connection_id, owned_gift_id) - + def upgrade_gift( self, business_connection_id: str, owned_gift_id: str, keep_original_details: Optional[bool]=None, @@ -7039,7 +7039,7 @@ def transfer_gift( new_owner_chat_id, star_count=star_count ) - + def post_story( self, business_connection_id: str, content: types.InputStoryContent, active_period: int, caption: Optional[str]=None, @@ -7146,7 +7146,7 @@ def edit_story( def delete_story(self, business_connection_id: str, story_id: int) -> bool: """ Deletes a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns True on success. - + Telegram documentation: https://core.telegram.org/bots/api#deletestory :param business_connection_id: Unique identifier of the business connection @@ -7195,7 +7195,7 @@ def gift_premium_subscription( text=text, text_parse_mode=text_parse_mode, text_entities=text_entities ) - + def set_business_account_profile_photo( self, business_connection_id: str, photo: types.InputProfilePhoto, is_public: Optional[bool]=None) -> bool: @@ -7274,8 +7274,8 @@ def replace_sticker_in_set(self, user_id: int, name: str, old_sticker: str, stic :rtype: :obj:`bool` """ return apihelper.replace_sticker_in_set(self.token, user_id, name, old_sticker, sticker) - - + + def set_sticker_emoji_list(self, sticker: str, emoji_list: List[str]) -> bool: """ Use this method to set the emoji list of a custom emoji sticker set. @@ -7297,7 +7297,7 @@ def upload_sticker_file(self, user_id: int, png_sticker: Union[Any, str]=None, s """ Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success. - + Telegram documentation: https://core.telegram.org/bots/api#uploadstickerfile :param user_id: User identifier of sticker set owner @@ -7311,7 +7311,7 @@ def upload_sticker_file(self, user_id: int, png_sticker: Union[Any, str]=None, s See https://core.telegram.org/stickers for technical requirements. More information on Sending Files » :type sticker: :class:`telebot.types.InputFile` - :param sticker_format: One of "static", "animated", "video". + :param sticker_format: One of "static", "animated", "video". :type sticker_format: :obj:`str` :return: On success, the sent file is returned. @@ -7321,17 +7321,17 @@ def upload_sticker_file(self, user_id: int, png_sticker: Union[Any, str]=None, s logger.warning('The parameter "png_sticker" is deprecated. Use "sticker" instead.') sticker = png_sticker sticker_format = "static" - + return types.File.de_json( apihelper.upload_sticker_file(self.token, user_id, sticker, sticker_format) ) def create_new_sticker_set( - self, user_id: int, name: str, title: str, - emojis: Optional[List[str]]=None, - png_sticker: Union[Any, str]=None, - tgs_sticker: Union[Any, str]=None, + self, user_id: int, name: str, title: str, + emojis: Optional[List[str]]=None, + png_sticker: Union[Any, str]=None, + tgs_sticker: Union[Any, str]=None, webm_sticker: Union[Any, str]=None, contains_masks: Optional[bool]=None, sticker_type: Optional[str]=None, @@ -7340,7 +7340,7 @@ def create_new_sticker_set( stickers: List[types.InputSticker]=None, sticker_format: Optional[str]=None) -> bool: """ - Use this method to create new sticker set owned by a user. + Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. Returns True on success. @@ -7404,7 +7404,7 @@ def create_new_sticker_set( sticker_format = 'video' elif png_sticker: sticker_format = 'static' - + if contains_masks is not None: logger.warning('The parameter "contains_masks" is deprecated, use "sticker_type" instead') if sticker_type is None: @@ -7425,8 +7425,8 @@ def create_new_sticker_set( def add_sticker_to_set( self, user_id: int, name: str, emojis: Union[List[str], str], - png_sticker: Optional[Union[Any, str]]=None, - tgs_sticker: Optional[Union[Any, str]]=None, + png_sticker: Optional[Union[Any, str]]=None, + tgs_sticker: Optional[Union[Any, str]]=None, webm_sticker: Optional[Union[Any, str]]=None, mask_position: Optional[types.MaskPosition]=None, sticker: Optional[types.InputSticker]=None) -> bool: @@ -7490,7 +7490,7 @@ def add_sticker_to_set( def set_sticker_position_in_set(self, sticker: str, position: int) -> bool: """ Use this method to move a sticker in a set created by the bot to a specific position . Returns True on success. - + Telegram documentation: https://core.telegram.org/bots/api#setstickerpositioninset :param sticker: File identifier of the sticker @@ -7508,7 +7508,7 @@ def set_sticker_position_in_set(self, sticker: str, position: int) -> bool: def delete_sticker_from_set(self, sticker: str) -> bool: """ Use this method to delete a sticker from a set created by the bot. Returns True on success. - + Telegram documentation: https://core.telegram.org/bots/api#deletestickerfromset :param sticker: File identifier of the sticker @@ -7668,9 +7668,9 @@ def edit_general_forum_topic(self, chat_id: Union[int, str], name: str) -> bool: Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success. - + Telegram documentation: https://core.telegram.org/bots/api#editgeneralforumtopic - + :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` @@ -7753,7 +7753,7 @@ def answer_web_app_query(self, web_app_query_id: str, result: types.InlineQueryR """ Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which - the query originated. + the query originated. On success, a SentWebAppMessage object is returned. Telegram Documentation: https://core.telegram.org/bots/api#answerwebappquery @@ -7821,7 +7821,7 @@ def register_for_reply(self, message: types.Message, callback: Callable, *args, :param args: Optional arguments for the callback function. :param kwargs: Optional keyword arguments for the callback function. - + :return: None """ self.register_for_reply_by_message_id(message.message_id, callback, *args, **kwargs) @@ -7924,8 +7924,8 @@ def set_state(self, user_id: int, state: Union[str, State], chat_id: Optional[in Added additional parameters to support topics, business connections, and message threads. - .. seealso:: - + .. seealso:: + For more details, visit the `custom_states.py example `_. :param user_id: User's identifier @@ -7957,7 +7957,7 @@ def set_state(self, user_id: int, state: Union[str, State], chat_id: Optional[in bot_id=bot_id, business_connection_id=business_connection_id, message_thread_id=message_thread_id) - def reset_data(self, user_id: int, chat_id: Optional[int]=None, + def reset_data(self, user_id: int, chat_id: Optional[int]=None, business_connection_id: Optional[str]=None, message_thread_id: Optional[int]=None, bot_id: Optional[int]=None) -> bool: """ @@ -8000,7 +8000,7 @@ def delete_state(self, user_id: int, chat_id: Optional[int]=None, business_conne :param user_id: User's identifier :type user_id: :obj:`int` - + :param chat_id: Chat's identifier :type chat_id: :obj:`int` @@ -8055,7 +8055,7 @@ def retrieve_data(self, user_id: int, chat_id: Optional[int]=None, business_conn bot_id=bot_id, business_connection_id=business_connection_id, message_thread_id=message_thread_id) - def get_state(self, user_id: int, chat_id: Optional[int]=None, + def get_state(self, user_id: int, chat_id: Optional[int]=None, business_connection_id: Optional[str]=None, message_thread_id: Optional[int]=None, bot_id: Optional[int]=None) -> str: """ @@ -8093,9 +8093,9 @@ def get_state(self, user_id: int, chat_id: Optional[int]=None, bot_id=bot_id, business_connection_id=business_connection_id, message_thread_id=message_thread_id) - def add_data(self, user_id: int, chat_id: Optional[int]=None, + def add_data(self, user_id: int, chat_id: Optional[int]=None, business_connection_id: Optional[str]=None, - message_thread_id: Optional[int]=None, + message_thread_id: Optional[int]=None, bot_id: Optional[int]=None, **kwargs) -> None: """ @@ -8142,7 +8142,7 @@ def register_next_step_handler_by_chat_id( :type callback: :obj:`Callable[[telebot.types.Message], None]` :param args: Args to pass in callback func - + :param kwargs: Args to pass in callback func :return: None @@ -8312,7 +8312,7 @@ def register_middleware_handler(self, callback, update_types=None): bot = TeleBot('TOKEN') bot.register_middleware_handler(print_channel_post_text, update_types=['channel_post', 'edited_channel_post']) - + :param callback: Function that will be used as a middleware handler. :type callback: :obj:`function` @@ -8492,7 +8492,7 @@ def register_message_handler(self, callback: Callable, content_types: Optional[L logger.warning("register_message_handler: 'content_types' filter should be List of strings (content types), not string.") content_types = [content_types] - + handler_dict = self._build_handler_dict(callback, chat_types=chat_types, @@ -8564,7 +8564,7 @@ def add_edited_message_handler(self, handler_dict): """ Adds the edit message handler Note that you should use register_edited_message_handler to add edited_message_handler to the bot. - + :meta private: :param handler_dict: @@ -8686,7 +8686,7 @@ def add_channel_post_handler(self, handler_dict): Note that you should use register_channel_post_handler to add channel_post_handler to the bot. :meta private: - + :param handler_dict: :return: """ @@ -8906,7 +8906,7 @@ def register_message_reaction_handler(self, callback: Callable, func: Callable=N :param pass_bot: True if you need to pass TeleBot instance to handler(useful for separating handlers into different files) :type pass_bot: :obj:`bool` - + :param kwargs: Optional keyword arguments(custom filters) :return: None @@ -8934,7 +8934,7 @@ def decorator(handler): return decorator - + def add_message_reaction_count_handler(self, handler_dict): """ Adds message reaction count handler @@ -8960,7 +8960,7 @@ def register_message_reaction_count_handler(self, callback: Callable, func: Call :param pass_bot: True if you need to pass TeleBot instance to handler(useful for separating handlers into different files) :type pass_bot: :obj:`bool` - + :param kwargs: Optional keyword arguments(custom filters) :return: None @@ -8969,7 +8969,7 @@ def register_message_reaction_count_handler(self, callback: Callable, func: Call self.add_message_reaction_count_handler(handler_dict) - def inline_handler(self, func, **kwargs): + def inline_handler(self, func=None, **kwargs): """ Handles new incoming inline query. As a parameter to the decorator function, it passes :class:`telebot.types.InlineQuery` object. @@ -9031,7 +9031,7 @@ def chosen_inline_handler(self, func, **kwargs): :param func: Function executed as a filter :type func: :obj:`function` - + :param kwargs: Optional keyword arguments(custom filters) :return: None @@ -9087,7 +9087,7 @@ def callback_query_handler(self, func=None, **kwargs): :type func: :obj:`function` :param kwargs: Optional keyword arguments(custom filters) - + :return: None """ def decorator(handler): @@ -9141,7 +9141,7 @@ def shipping_query_handler(self, func, **kwargs): :type func: :obj:`function` :param kwargs: Optional keyword arguments(custom filters) - + :return: None """ def decorator(handler): @@ -9218,7 +9218,7 @@ def add_pre_checkout_query_handler(self, handler_dict): """ self.pre_checkout_query_handlers.append(handler_dict) - + def register_pre_checkout_query_handler(self, callback: Callable, func: Callable, pass_bot: Optional[bool]=False, **kwargs): """ Registers pre-checkout request handler. @@ -9253,9 +9253,9 @@ def decorator(handler): handler_dict = self._build_handler_dict(handler, func=func, **kwargs) self.add_purchased_paid_media_handler(handler_dict) return handler - + return decorator - + def add_purchased_paid_media_handler(self, handler_dict): """ Adds a purchased paid media handler @@ -9274,7 +9274,7 @@ def register_purchased_paid_media_handler(self, callback: Callable, func: Callab :param callback: function to be called :type callback: :obj:`function` - + :param func: Function executed as a filter :type func: :obj:`function` @@ -9351,7 +9351,7 @@ def poll_answer_handler(self, func=None, **kwargs): :type func: :obj:`function` :param kwargs: Optional keyword arguments(custom filters) - + :return: None """ def decorator(handler): @@ -9518,7 +9518,7 @@ def chat_join_request_handler(self, func=None, **kwargs): :type func: :obj:`function` :param kwargs: Optional keyword arguments(custom filters) - + :return: None """ def decorator(handler): @@ -9566,7 +9566,7 @@ def register_chat_join_request_handler( def chat_boost_handler(self, func=None, **kwargs): """ - Handles new incoming chat boost state. + Handles new incoming chat boost state. it passes :class:`telebot.types.ChatBoostUpdated` object. :param func: Function executed as a filter @@ -9603,7 +9603,7 @@ def register_chat_boost_handler( :param callback: function to be called :type callback: :obj:`function` - + :param func: Function executed as a filter :type func: :obj:`function` @@ -9619,7 +9619,7 @@ def register_chat_boost_handler( def removed_chat_boost_handler(self, func=None, **kwargs): """ - Handles new incoming chat boost state. + Handles new incoming chat boost state. it passes :class:`telebot.types.ChatBoostRemoved` object. :param func: Function executed as a filter @@ -9635,7 +9635,7 @@ def decorator(handler): return decorator - + def add_removed_chat_boost_handler(self, handler_dict): """ Adds a removed_chat_boost handler. @@ -9656,7 +9656,7 @@ def register_removed_chat_boost_handler( :param callback: function to be called :type callback: :obj:`function` - + :param func: Function executed as a filter :type func: :obj:`function` @@ -9684,7 +9684,7 @@ def decorator(handler): handler_dict = self._build_handler_dict(handler, func=func, **kwargs) self.add_business_connection_handler(handler_dict) return handler - + return decorator @@ -9852,7 +9852,7 @@ def register_business_message_handler(self, :return: None """ - handler_dict = self._build_handler_dict(callback, content_types=content_types, commands=commands, regexp=regexp, func=func, + handler_dict = self._build_handler_dict(callback, content_types=content_types, commands=commands, regexp=regexp, func=func, pass_bot=pass_bot, **kwargs) self.add_business_message_handler(handler_dict) @@ -9912,7 +9912,7 @@ def add_edited_business_message_handler(self, handler_dict): """ Adds the edit message handler Note that you should use register_edited_business_message_handler to add edited_business_message_handler to the bot. - + :meta private: :param handler_dict: @@ -9989,7 +9989,7 @@ def decorator(handler): self.add_deleted_business_messages_handler(handler_dict) return handler - + return decorator @@ -10109,7 +10109,7 @@ def _get_middlewares(self, update_type): :return: """ middlewares = None - if self.middlewares: + if self.middlewares: middlewares = [i for i in self.middlewares if update_type in i.update_types] return middlewares diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index 33783893f..81cdc955d 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -26,7 +26,7 @@ logger = logging.getLogger('TeleBot') REPLY_MARKUP_TYPES = Union[ - types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, + types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply] @@ -76,7 +76,7 @@ class AsyncTeleBot: from telebot.async_telebot import AsyncTeleBot bot = AsyncTeleBot('token') # get token from @BotFather - # now you can register other handlers/update listeners, + # now you can register other handlers/update listeners, # and use bot methods. # Remember to use async/await keywords when necessary. @@ -114,7 +114,7 @@ class AsyncTeleBot: :param allow_sending_without_reply: Deprecated - Use reply_parameters instead. Default value for allow_sending_without_reply, defaults to None :type allow_sending_without_reply: :obj:`bool`, optional - + :param colorful_logs: Outputs colorful logs :type colorful_logs: :obj:`bool`, optional @@ -134,7 +134,7 @@ def __init__(self, token: str, parse_mode: Optional[str]=None, offset: Optional[ allow_sending_without_reply: Optional[bool]=None, colorful_logs: Optional[bool]=False, validate_token: Optional[bool]=True) -> None: - + # update-related self.token = token self.offset = offset @@ -148,7 +148,7 @@ def __init__(self, token: str, parse_mode: Optional[str]=None, offset: Optional[ raise ImportError( 'Install coloredlogs module to use colorful_logs option.' ) - + # properties self.parse_mode = parse_mode self.disable_web_page_preview = disable_web_page_preview @@ -194,9 +194,9 @@ def __init__(self, token: str, parse_mode: Optional[str]=None, offset: Optional[ if validate_token: util.validate_token(self.token) - + self.bot_id: Union[int, None] = util.extract_bot_id(self.token) # subject to change, unspecified - + @property def user(self): @@ -237,7 +237,7 @@ async def get_updates(self, offset: Optional[int]=None, limit: Optional[int]=Non :return: An Array of Update objects is returned. :rtype: :obj:`list` of :class:`telebot.types.Update` - """ + """ json_updates = await asyncio_helper.get_updates(self.token, offset, limit, timeout, allowed_updates, request_timeout) return [types.Update.de_json(ju) for ju in json_updates] @@ -255,7 +255,7 @@ def _setup_change_detector(self, path_to_watch: str) -> None: if path is None: # Make it possible to specify --path argument to the script path = sys.argv[sys.argv.index('--path') + 1] if '--path' in sys.argv else '.' - + self.event_observer = Observer() self.event_observer.schedule(self.event_handler, path, recursive=True) self.event_observer.start() @@ -268,7 +268,7 @@ async def polling(self, non_stop: bool=True, skip_pending=False, interval: int=0 This allows the bot to retrieve Updates automagically and notify listeners and message handlers accordingly. Warning: Do not call this function more than once! - + Always gets updates. .. note:: @@ -277,7 +277,7 @@ async def polling(self, non_stop: bool=True, skip_pending=False, interval: int=0 :param non_stop: Do not stop polling when an ApiException occurs. :type non_stop: :obj:`bool` - + :param skip_pending: skip old updates :type skip_pending: :obj:`bool` @@ -286,17 +286,17 @@ async def polling(self, non_stop: bool=True, skip_pending=False, interval: int=0 :param timeout: Request connection timeout :type timeout: :obj:`int` - + :param request_timeout: Timeout in seconds for get_updates(Defaults to None) :type request_timeout: :obj:`int` :param allowed_updates: A list of the update types you want your bot to receive. - For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. - See util.update_types for a complete list of available update types. - Specify an empty list to receive all update types except chat_member (default). + For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. + See util.update_types for a complete list of available update types. + Specify an empty list to receive all update types except chat_member (default). If not specified, the previous setting will be used. - - Please note that this parameter doesn't affect updates created before the call to the get_updates, + + Please note that this parameter doesn't affect updates created before the call to the get_updates, so unwanted updates may be received for a short period of time. :type allowed_updates: :obj:`list` of :obj:`str` @@ -308,7 +308,7 @@ async def polling(self, non_stop: bool=True, skip_pending=False, interval: int=0 :param path_to_watch: Path to watch for changes. Defaults to current directory :type path_to_watch: :obj:`str` - + :return: """ if none_stop is not None: @@ -346,12 +346,12 @@ async def infinity_polling(self, timeout: Optional[int]=20, skip_pending: Option :type logger_level: :obj:`int` :param allowed_updates: A list of the update types you want your bot to receive. - For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. - See util.update_types for a complete list of available update types. - Specify an empty list to receive all update types except chat_member (default). + For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. + See util.update_types for a complete list of available update types. + Specify an empty list to receive all update types except chat_member (default). If not specified, the previous setting will be used. - - Please note that this parameter doesn't affect updates created before the call to the get_updates, + + Please note that this parameter doesn't affect updates created before the call to the get_updates, so unwanted updates may be received for a short period of time. :type allowed_updates: :obj:`list` of :obj:`str` @@ -402,7 +402,7 @@ def __hide_token(self, message: str) -> str: return message.replace(code, "*" * len(code)) else: return message - + async def _handle_error_interval(self, error_interval: float): logger.debug('Waiting for %s seconds before retrying', error_interval) await asyncio.sleep(error_interval) @@ -439,7 +439,7 @@ async def _process_polling(self, non_stop: bool=False, interval: int=0, timeout: logger.warning("Setting non_stop to False will stop polling on API and system exceptions.") self._user = await self.get_me() - + logger.info('Starting your bot with username: [@%s]', self.user.username) self._polling = True @@ -469,7 +469,7 @@ async def _process_polling(self, non_stop: bool=False, interval: int=0, timeout: if non_stop: error_interval = await self._handle_error_interval(error_interval) - + if non_stop or handled: continue else: @@ -837,7 +837,7 @@ async def process_new_poll_answer(self, poll_answers): :meta private: """ await self._process_updates(self.poll_answer_handlers, poll_answers, 'poll_answer') - + async def process_new_my_chat_member(self, my_chat_members): """ :meta private: @@ -885,7 +885,7 @@ async def process_new_edited_business_message(self, new_edited_business_messages :meta private: """ await self._process_updates(self.edited_business_message_handlers, new_edited_business_messages, 'edited_business_message') - + async def process_new_deleted_business_messages(self, new_deleted_business_messages): """ :meta private: @@ -906,7 +906,7 @@ async def _get_middlewares(self, update_type): middlewares = [middleware for middleware in self.middlewares if update_type in middleware.update_types] return middlewares return None - + async def __notify_update(self, new_messages): if len(self.update_listener) == 0: return @@ -945,7 +945,7 @@ async def update_listener(new_messages): print(message.text) # Prints message text bot.set_update_listener(update_listener) - + :return: None """ self.update_listener.append(func) @@ -1033,7 +1033,7 @@ def setup_middleware(self, middleware: BaseMiddleware): :param middleware: Middleware-class. :type middleware: :class:`telebot.asyncio_handler_backends.BaseMiddleware` - + :return: None """ if not hasattr(middleware, 'update_types'): @@ -1106,7 +1106,7 @@ async def default_command(message): :param func: Optional lambda function. The lambda receives the message to test as the first parameter. It must return True if the command should handle the message. - + :param content_types: Supported message content types. Must be a list. Defaults to ['text']. :type content_types: :obj:`list` of :obj:`str` @@ -1147,7 +1147,7 @@ def add_message_handler(self, handler_dict): """ Adds a message handler. Note that you should use register_message_handler to add message_handler. - + :meta private: :param handler_dict: @@ -1371,7 +1371,7 @@ def add_channel_post_handler(self, handler_dict): :return: """ self.channel_post_handlers.append(handler_dict) - + def register_channel_post_handler(self, callback: Callable[[Any], Awaitable], content_types: Optional[List[str]]=None, commands: Optional[List[str]]=None, regexp: Optional[str]=None, func: Optional[Callable]=None, pass_bot: Optional[bool]=False, **kwargs): """ @@ -1535,7 +1535,7 @@ def decorator(handler): return handler return decorator - + def add_message_reaction_handler(self, handler_dict): """ Adds message reaction handler. @@ -1560,7 +1560,7 @@ def register_message_reaction_handler(self, callback: Callable[[Any], Awaitable] :param pass_bot: True if you need to pass TeleBot instance to handler(useful for separating handlers into different files) :type pass_bot: :obj:`bool` - + :param kwargs: Optional keyword arguments(custom filters) :return: None @@ -1587,7 +1587,7 @@ def decorator(handler): return handler return decorator - + def add_message_reaction_count_handler(self, handler_dict): """ Adds message reaction count handler @@ -1612,7 +1612,7 @@ def register_message_reaction_count_handler(self, callback: Callable[[Any], Awai :param pass_bot: True if you need to pass TeleBot instance to handler(useful for separating handlers into different files) :type pass_bot: :obj:`bool` - + :param kwargs: Optional keyword arguments(custom filters) :return: None @@ -1621,7 +1621,7 @@ def register_message_reaction_count_handler(self, callback: Callable[[Any], Awai self.add_message_reaction_count_handler(handler_dict) - def inline_handler(self, func, **kwargs): + def inline_handler(self, func=None, **kwargs): """ Handles new incoming inline query. As a parameter to the decorator function, it passes :class:`telebot.types.InlineQuery` object. @@ -1681,7 +1681,7 @@ def chosen_inline_handler(self, func, **kwargs): :param func: Function executed as a filter :type func: :obj:`function` - + :param kwargs: Optional keyword arguments(custom filters) :return: None @@ -1735,7 +1735,7 @@ def callback_query_handler(self, func=None, **kwargs): :type func: :obj:`function` :param kwargs: Optional keyword arguments(custom filters) - + :return: None """ @@ -1787,7 +1787,7 @@ def shipping_query_handler(self, func, **kwargs): :type func: :obj:`function` :param kwargs: Optional keyword arguments(custom filters) - + :return: None """ @@ -1861,7 +1861,7 @@ def add_pre_checkout_query_handler(self, handler_dict): :return: """ self.pre_checkout_query_handlers.append(handler_dict) - + def register_pre_checkout_query_handler(self, callback: Callable[[Any], Awaitable], func: Callable, pass_bot: Optional[bool]=False, **kwargs): """ Registers pre-checkout request handler. @@ -1896,9 +1896,9 @@ def decorator(handler): handler_dict = self._build_handler_dict(handler, func=func, **kwargs) self.add_purchased_paid_media_handler(handler_dict) return handler - + return decorator - + def add_purchased_paid_media_handler(self, handler_dict): """ Adds a purchased paid media handler @@ -1917,7 +1917,7 @@ def register_purchased_paid_media_handler(self, callback: Callable, func: Callab :param callback: function to be called :type callback: :obj:`function` - + :param func: Function executed as a filter :type func: :obj:`function` @@ -1992,7 +1992,7 @@ def poll_answer_handler(self, func=None, **kwargs): :type func: :obj:`function` :param kwargs: Optional keyword arguments(custom filters) - + :return: None """ @@ -2152,7 +2152,7 @@ def chat_join_request_handler(self, func=None, **kwargs): :type func: :obj:`function` :param kwargs: Optional keyword arguments(custom filters) - + :return: None """ @@ -2198,7 +2198,7 @@ def register_chat_join_request_handler(self, callback: Callable[[Any], Awaitable def chat_boost_handler(self, func=None, **kwargs): """ - Handles new incoming chat boost state. + Handles new incoming chat boost state. it passes :class:`telebot.types.ChatBoostUpdated` object. :param func: Function executed as a filter @@ -2213,7 +2213,7 @@ def decorator(handler): return handler return decorator - + def add_chat_boost_handler(self, handler_dict): """ Adds a chat_boost handler. @@ -2232,7 +2232,7 @@ def register_chat_boost_handler(self, callback: Callable, func: Optional[Callabl :param callback: function to be called :type callback: :obj:`function` - + :param func: Function executed as a filter :type func: :obj:`function` @@ -2247,7 +2247,7 @@ def register_chat_boost_handler(self, callback: Callable, func: Optional[Callabl def removed_chat_boost_handler(self, func=None, **kwargs): """ - Handles new incoming chat boost state. + Handles new incoming chat boost state. it passes :class:`telebot.types.ChatBoostRemoved` object. :param func: Function executed as a filter @@ -2262,7 +2262,7 @@ def decorator(handler): return handler return decorator - + def add_removed_chat_boost_handler(self, handler_dict): """ Adds a removed_chat_boost handler. @@ -2281,7 +2281,7 @@ def register_removed_chat_boost_handler(self, callback: Callable, func: Optional :param callback: function to be called :type callback: :obj:`function` - + :param func: Function executed as a filter :type func: :obj:`function` @@ -2309,9 +2309,9 @@ def decorator(handler): handler_dict = self._build_handler_dict(handler, func=func, **kwargs) self.add_business_connection_handler(handler_dict) return handler - + return decorator - + def add_business_connection_handler(self, handler_dict): """ Adds a business_connection handler. @@ -2426,7 +2426,7 @@ def decorator(handler): return handler return decorator - + def add_business_message_handler(self, handler_dict): """ Adds a business_message handler. @@ -2476,8 +2476,8 @@ def register_business_message_handler(self, pass_bot=pass_bot,**kwargs) self.add_business_message_handler(handler_dict) - - + + def edited_business_message_handler(self, commands=None, regexp=None, func=None, content_types=None, **kwargs): """ @@ -2534,7 +2534,7 @@ def add_edited_business_message_handler(self, handler_dict): """ Adds the edit message handler Note that you should use register_edited_business_message_handler to add edited_business_message_handler to the bot. - + :meta private: :param handler_dict: @@ -2594,7 +2594,7 @@ def register_edited_business_message_handler(self, callback: Callable, content_t **kwargs) self.add_edited_business_message_handler(handler_dict) - + def deleted_business_messages_handler(self, func=None, **kwargs): """ Handles new incoming deleted messages state. @@ -2611,9 +2611,9 @@ def decorator(handler): self.add_deleted_business_messages_handler(handler_dict) return handler - + return decorator - + def add_deleted_business_messages_handler(self, handler_dict): """ Adds a deleted_business_messages handler. @@ -2670,7 +2670,7 @@ async def skip_updates(self): return True # all methods begin here - + async def get_me(self) -> types.User: """ Returns basic information about the bot in form of a User object. @@ -2683,9 +2683,9 @@ async def get_me(self) -> types.User: async def get_file(self, file_id: Optional[str]) -> types.File: """ Use this method to get basic info about a file and prepare it for downloading. - For the moment, bots can download files of up to 20MB in size. - On success, a File object is returned. - It is guaranteed that the link will be valid for at least 1 hour. + For the moment, bots can download files of up to 20MB in size. + On success, a File object is returned. + 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 get_file again. Telegram documentation: https://core.telegram.org/bots/api#getfile @@ -2715,7 +2715,7 @@ async def download_file(self, file_path: Optional[str]) -> bytes: :param file_path: Path where the file should be downloaded. :type file_path: str - + :return: bytes :rtype: :obj:`bytes` """ @@ -2723,11 +2723,11 @@ async def download_file(self, file_path: Optional[str]) -> bytes: async def log_out(self) -> bool: """ - Use this method to log out from the cloud Bot API server before launching the bot locally. + Use this method to log out from the cloud Bot API server before launching the bot locally. You MUST log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. - After a successful call, you can immediately log in on a local server, - but will not be able to log in back to the cloud Bot API server for 10 minutes. + After a successful call, you can immediately log in on a local server, + but will not be able to log in back to the cloud Bot API server for 10 minutes. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#logout @@ -2736,13 +2736,13 @@ async def log_out(self) -> bool: :rtype: :obj:`bool` """ return await asyncio_helper.log_out(self.token) - + async def close(self) -> bool: """ - Use this method to close the bot instance before moving it from one local server to another. + Use this method to close the bot instance before moving it from one local server to another. You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart. - The method will return error 429 in the first 10 minutes after the bot is launched. + The method will return error 429 in the first 10 minutes after the bot is launched. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#close @@ -2790,15 +2790,15 @@ async def set_webhook(self, url: Optional[str]=None, certificate: Optional[Union Defaults to 40. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput, defaults to None :type max_connections: :obj:`int`, optional - + :param allowed_updates: A JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member (default). If not specified, the previous setting will be used. - + Please note that this parameter doesn't affect updates created before the call to the setWebhook, so unwanted updates may be received for a short period of time. Defaults to None - + :type allowed_updates: :obj:`list`, optional :param ip_address: The fixed IP address which will be used to send webhook requests instead of the IP address @@ -2941,7 +2941,7 @@ async def get_webhook_info(self, timeout: Optional[int]=None) -> types.WebhookIn async def set_message_reaction(self, chat_id: Union[int, str], message_id: int, reaction: Optional[List[types.ReactionType]]=None, is_big: Optional[bool]=None) -> bool: """ - Use this method to change the chosen reactions on a message. + Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Returns True on success. @@ -2965,7 +2965,7 @@ async def set_message_reaction(self, chat_id: Union[int, str], message_id: int, result = await asyncio_helper.set_message_reaction(self.token, chat_id, message_id, reaction, is_big) return result - async def get_user_profile_photos(self, user_id: int, offset: Optional[int]=None, + async def get_user_profile_photos(self, user_id: int, offset: Optional[int]=None, limit: Optional[int]=None) -> types.UserProfilePhotos: """ Use this method to get a list of profile pictures for a user. @@ -2988,7 +2988,7 @@ async def get_user_profile_photos(self, user_id: int, offset: Optional[int]=None """ result = await asyncio_helper.get_user_profile_photos(self.token, user_id, offset, limit) return types.UserProfilePhotos.de_json(result) - + async def set_user_emoji_status(self, user_id: int, emoji_status_custom_emoji_id: Optional[str]=None, emoji_status_expiration_date: Optional[int]=None) -> bool: """ Use this method to change the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. @@ -3045,7 +3045,7 @@ async def get_chat_administrators(self, chat_id: Union[int, str]) -> List[types. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. - Telegram documentation: https://core.telegram.org/bots/api#getchatadministrators + Telegram documentation: https://core.telegram.org/bots/api#getchatadministrators :param chat_id: Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) @@ -3075,7 +3075,7 @@ async def get_chat_members_count(self, chat_id: Union[int, str]) -> int: """ result = await asyncio_helper.get_chat_member_count(self.token, chat_id) return result - + async def get_chat_member_count(self, chat_id: Union[int, str]) -> int: """ Use this method to get the number of members in a chat. @@ -3096,7 +3096,7 @@ async def set_chat_sticker_set(self, chat_id: Union[int, str], sticker_set_name: Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success. - + Telegram documentation: https://core.telegram.org/bots/api#setchatstickerset :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) @@ -3116,7 +3116,7 @@ async def delete_chat_sticker_set(self, chat_id: Union[int, str]) -> bool: Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success. - + Telegram documentation: https://core.telegram.org/bots/api#deletechatstickerset :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) @@ -3132,7 +3132,7 @@ async def answer_web_app_query(self, web_app_query_id: str, result: types.Inline """ Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which - the query originated. + the query originated. On success, a SentWebAppMessage object is returned. Telegram Documentation: https://core.telegram.org/bots/api#answerwebappquery @@ -3182,7 +3182,7 @@ async def save_prepared_inline_message(self, user_id: int, result: types.InlineQ async def get_chat_member(self, chat_id: Union[int, str], user_id: int) -> types.ChatMember: """ Use this method to get information about a member of a chat. Returns a ChatMember object on success. - + Telegram documentation: https://core.telegram.org/bots/api#getchatmember :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) @@ -3198,13 +3198,13 @@ async def get_chat_member(self, chat_id: Union[int, str], user_id: int) -> types return types.ChatMember.de_json(result) async def send_message( - self, chat_id: Union[int, str], text: str, - parse_mode: Optional[str]=None, + self, chat_id: Union[int, str], text: str, + parse_mode: Optional[str]=None, entities: Optional[List[types.MessageEntity]]=None, - disable_web_page_preview: Optional[bool]=None, - disable_notification: Optional[bool]=None, + disable_web_page_preview: Optional[bool]=None, + disable_notification: Optional[bool]=None, protect_content: Optional[bool]=None, - reply_to_message_id: Optional[int]=None, + reply_to_message_id: Optional[int]=None, allow_sending_without_reply: Optional[bool]=None, reply_markup: Optional[REPLY_MARKUP_TYPES]=None, timeout: Optional[int]=None, @@ -3220,7 +3220,7 @@ async def send_message( Use this method to send text messages. Warning: Do not send more than about 4096 characters each message, otherwise you'll risk an HTTP 414 error. - If you must send more than 4096 characters, + If you must send more than 4096 characters, use the `split_string` or `smart_split` function in util.py. Telegram documentation: https://core.telegram.org/bots/api#sendmessage @@ -3294,11 +3294,11 @@ async def send_message( disable_web_page_preview = self.disable_web_page_preview if (disable_web_page_preview is None) else disable_web_page_preview disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + if allow_sending_without_reply is not None: logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.") - + if reply_to_message_id: # show a deprecation warning logger.warning("The parameter 'reply_to_message_id' is deprecated. Use 'reply_parameters' instead.") @@ -3319,7 +3319,7 @@ async def send_message( if disable_web_page_preview is not None: # show a deprecation warning logger.warning("The parameter 'disable_web_page_preview' is deprecated. Use 'link_preview_options' instead.") - + if link_preview_options: # show a conflict warning logger.warning("Both 'link_preview_options' and 'disable_web_page_preview' parameters are set: conflicting, 'disable_web_page_preview' is deprecated") @@ -3348,7 +3348,7 @@ async def send_message( ) async def forward_message( - self, chat_id: Union[int, str], from_chat_id: Union[int, str], + self, chat_id: Union[int, str], from_chat_id: Union[int, str], message_id: int, disable_notification: Optional[bool]=None, protect_content: Optional[bool]=None, timeout: Optional[int]=None, @@ -3375,7 +3375,7 @@ async def forward_message( :param video_start_timestamp: New start timestamp for the forwarded video in the message :type video_start_timestamp: :obj:`int` - + :param protect_content: Protects the contents of the forwarded message from forwarding and saving :type protect_content: :obj:`bool` @@ -3408,17 +3408,17 @@ async def forward_message( ) async def copy_message( - self, chat_id: Union[int, str], - from_chat_id: Union[int, str], - message_id: int, - caption: Optional[str]=None, - parse_mode: Optional[str]=None, + self, chat_id: Union[int, str], + from_chat_id: Union[int, str], + message_id: int, + caption: Optional[str]=None, + parse_mode: Optional[str]=None, caption_entities: Optional[List[types.MessageEntity]]=None, - disable_notification: Optional[bool]=None, + disable_notification: Optional[bool]=None, protect_content: Optional[bool]=None, - reply_to_message_id: Optional[int]=None, + reply_to_message_id: Optional[int]=None, allow_sending_without_reply: Optional[bool]=None, - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, timeout: Optional[int]=None, message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, @@ -3479,7 +3479,7 @@ async def copy_message( :param message_thread_id: Identifier of a message thread, in which the message will be sent :type message_thread_id: :obj:`int` - + :param reply_parameters: Reply parameters. :type reply_parameters: :class:`telebot.types.ReplyParameters` @@ -3498,7 +3498,7 @@ async def copy_message( for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters` - + :return: On success, the MessageId of the sent message is returned. :rtype: :class:`telebot.types.MessageID` """ @@ -3508,7 +3508,7 @@ async def copy_message( if allow_sending_without_reply is not None: logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.") - + if reply_to_message_id: # show a deprecation warning logger.warning("The parameter 'reply_to_message_id' is deprecated. Use 'reply_parameters' instead.") @@ -3581,7 +3581,7 @@ async def decline_suggested_post(self, chat_id: int, message_id: int, comment: O return await asyncio_helper.decline_suggested_post(self.token, chat_id, message_id, comment=comment) - async def delete_message(self, chat_id: Union[int, str], message_id: int, + async def delete_message(self, chat_id: Union[int, str], message_id: int, timeout: Optional[int]=None) -> bool: """ Use this method to delete a message, including service messages, with the following limitations: @@ -3609,10 +3609,10 @@ async def delete_message(self, chat_id: Union[int, str], message_id: int, :rtype: :obj:`bool` """ return await asyncio_helper.delete_message(self.token, chat_id, message_id, timeout) - + async def delete_messages(self, chat_id: Union[int, str], message_ids: List[int]): """ - Use this method to delete multiple messages simultaneously. + Use this method to delete multiple messages simultaneously. If some of the specified messages can't be found, they are skipped. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#deletemessages @@ -3627,7 +3627,7 @@ async def delete_messages(self, chat_id: Union[int, str], message_ids: List[int] """ return await asyncio_helper.delete_messages(self.token, chat_id, message_ids) - + async def forward_messages(self, chat_id: Union[str, int], from_chat_id: Union[str, int], message_ids: List[int], disable_notification: Optional[bool]=None, message_thread_id: Optional[int]=None, protect_content: Optional[bool]=None, direct_messages_topic_id: Optional[int]=None) -> List[types.MessageID]: @@ -3669,7 +3669,7 @@ async def forward_messages(self, chat_id: Union[str, int], from_chat_id: Union[s result = await asyncio_helper.forward_messages(self.token, chat_id, from_chat_id, message_ids, disable_notification, message_thread_id, protect_content, direct_messages_topic_id=direct_messages_topic_id) return [types.MessageID.de_json(message_id) for message_id in result] - + async def copy_messages(self, chat_id: Union[str, int], from_chat_id: Union[str, int], message_ids: List[int], disable_notification: Optional[bool] = None, message_thread_id: Optional[int] = None, protect_content: Optional[bool] = None, remove_caption: Optional[bool] = None, @@ -3715,7 +3715,7 @@ async def copy_messages(self, chat_id: Union[str, int], from_chat_id: Union[str, result = await asyncio_helper.copy_messages(self.token, chat_id, from_chat_id, message_ids, disable_notification, message_thread_id, protect_content, remove_caption, direct_messages_topic_id) return [types.MessageID.de_json(message_id) for message_id in result] - + async def send_checklist( self, business_connection_id: str, chat_id: Union[int, str], checklist: types.InputChecklist, @@ -3759,7 +3759,7 @@ async def send_checklist( """ disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + if reply_parameters and (reply_parameters.allow_sending_without_reply is None): reply_parameters.allow_sending_without_reply = self.allow_sending_without_reply @@ -3768,7 +3768,7 @@ async def send_checklist( self.token, business_connection_id, chat_id, checklist, disable_notification=disable_notification, protect_content=protect_content, message_effect_id=message_effect_id, reply_parameters=reply_parameters, reply_markup=reply_markup)) - + async def edit_message_checklist( self, business_connection_id: str, chat_id: Union[int, str], message_id: int, checklist: types.InputChecklist, @@ -3803,9 +3803,9 @@ async def edit_message_checklist( async def send_dice( self, chat_id: Union[int, str], - emoji: Optional[str]=None, disable_notification: Optional[bool]=None, + emoji: Optional[str]=None, disable_notification: Optional[bool]=None, reply_to_message_id: Optional[int]=None, - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, timeout: Optional[int]=None, allow_sending_without_reply: Optional[bool]=None, protect_content: Optional[bool]=None, @@ -3850,7 +3850,7 @@ async def send_dice( :param message_thread_id: The identifier of a message thread, unique within the chat to which the message with the thread identifier belongs :type message_thread_id: :obj:`int` - + :param reply_parameters: Reply parameters. :type reply_parameters: :class:`telebot.types.ReplyParameters` @@ -3878,11 +3878,11 @@ async def send_dice( """ disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + if allow_sending_without_reply is not None: logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.") - + if reply_to_message_id: # show a deprecation warning logger.warning("The parameter 'reply_to_message_id' is deprecated. Use 'reply_parameters' instead.") @@ -3909,12 +3909,12 @@ async def send_dice( ) async def send_photo( - self, chat_id: Union[int, str], photo: Union[Any, str], + self, chat_id: Union[int, str], photo: Union[Any, str], caption: Optional[str]=None, parse_mode: Optional[str]=None, caption_entities: Optional[List[types.MessageEntity]]=None, disable_notification: Optional[bool]=None, protect_content: Optional[bool]=None, - reply_to_message_id: Optional[int]=None, + reply_to_message_id: Optional[int]=None, allow_sending_without_reply: Optional[bool]=None, reply_markup: Optional[REPLY_MARKUP_TYPES]=None, timeout: Optional[int]=None, @@ -3931,7 +3931,7 @@ async def send_photo( Use this method to send photos. On success, the sent Message is returned. Telegram documentation: https://core.telegram.org/bots/api#sendphoto - + :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` @@ -3974,7 +3974,7 @@ async def send_photo( :param has_spoiler: Pass True, if the photo should be sent as a spoiler :type has_spoiler: :obj:`bool` - + :param reply_parameters: Reply parameters. :type reply_parameters: :class:`telebot.types.ReplyParameters` @@ -4006,11 +4006,11 @@ async def send_photo( parse_mode = self.parse_mode if (parse_mode is None) else parse_mode disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + if allow_sending_without_reply is not None: logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.") - + if reply_to_message_id: # show a deprecation warning logger.warning("The parameter 'reply_to_message_id' is deprecated. Use 'reply_parameters' instead.") @@ -4039,14 +4039,14 @@ async def send_photo( ) async def send_audio( - self, chat_id: Union[int, str], audio: Union[Any, str], - caption: Optional[str]=None, duration: Optional[int]=None, + self, chat_id: Union[int, str], audio: Union[Any, str], + caption: Optional[str]=None, duration: Optional[int]=None, performer: Optional[str]=None, title: Optional[str]=None, - reply_to_message_id: Optional[int]=None, - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, - parse_mode: Optional[str]=None, + reply_to_message_id: Optional[int]=None, + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + parse_mode: Optional[str]=None, disable_notification: Optional[bool]=None, - timeout: Optional[int]=None, + timeout: Optional[int]=None, thumbnail: Optional[Union[Any, str]]=None, caption_entities: Optional[List[types.MessageEntity]]=None, allow_sending_without_reply: Optional[bool]=None, @@ -4067,7 +4067,7 @@ async def send_audio( For sending voice messages, use the send_voice method instead. Telegram documentation: https://core.telegram.org/bots/api#sendaudio - + :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` @@ -4124,7 +4124,7 @@ async def send_audio( :param thumb: Deprecated. Use thumbnail instead :type thumb: :obj:`str` or :class:`telebot.types.InputFile` - + :param reply_parameters: Reply parameters. :type reply_parameters: :class:`telebot.types.ReplyParameters` @@ -4153,7 +4153,7 @@ async def send_audio( parse_mode = self.parse_mode if (parse_mode is None) else parse_mode disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + if thumb is not None and thumbnail is None: thumbnail = thumb @@ -4161,7 +4161,7 @@ async def send_audio( if allow_sending_without_reply is not None: logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.") - + if reply_to_message_id: # show a deprecation warning logger.warning("The parameter 'reply_to_message_id' is deprecated. Use 'reply_parameters' instead.") @@ -4189,12 +4189,12 @@ async def send_audio( ) async def send_voice( - self, chat_id: Union[int, str], voice: Union[Any, str], - caption: Optional[str]=None, duration: Optional[int]=None, - reply_to_message_id: Optional[int]=None, + self, chat_id: Union[int, str], voice: Union[Any, str], + caption: Optional[str]=None, duration: Optional[int]=None, + reply_to_message_id: Optional[int]=None, reply_markup: Optional[REPLY_MARKUP_TYPES]=None, - parse_mode: Optional[str]=None, - disable_notification: Optional[bool]=None, + parse_mode: Optional[str]=None, + disable_notification: Optional[bool]=None, timeout: Optional[int]=None, caption_entities: Optional[List[types.MessageEntity]]=None, allow_sending_without_reply: Optional[bool]=None, @@ -4210,7 +4210,7 @@ async def send_voice( Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS, or in .MP3 format, or in .M4A format (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. Telegram documentation: https://core.telegram.org/bots/api#sendvoice - + :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` @@ -4252,7 +4252,7 @@ async def send_voice( :param message_thread_id: Identifier of a message thread, in which the message will be sent :type message_thread_id: :obj:`int` - + :param reply_parameters: Reply parameters. :type reply_parameters: :class:`telebot.types.ReplyParameters` @@ -4280,11 +4280,11 @@ async def send_voice( parse_mode = self.parse_mode if (parse_mode is None) else parse_mode disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + if allow_sending_without_reply is not None: logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.") - + if reply_to_message_id: # show a deprecation warning logger.warning("The parameter 'reply_to_message_id' is deprecated. Use 'reply_parameters' instead.") @@ -4313,12 +4313,12 @@ async def send_voice( async def send_document( self, chat_id: Union[int, str], document: Union[Any, str], - reply_to_message_id: Optional[int]=None, - caption: Optional[str]=None, + reply_to_message_id: Optional[int]=None, + caption: Optional[str]=None, reply_markup: Optional[REPLY_MARKUP_TYPES]=None, - parse_mode: Optional[str]=None, - disable_notification: Optional[bool]=None, - timeout: Optional[int]=None, + parse_mode: Optional[str]=None, + disable_notification: Optional[bool]=None, + timeout: Optional[int]=None, thumbnail: Optional[Union[Any, str]]=None, caption_entities: Optional[List[types.MessageEntity]]=None, allow_sending_without_reply: Optional[bool]=None, @@ -4338,7 +4338,7 @@ async def send_document( Use this method to send general files. Telegram documentation: https://core.telegram.org/bots/api#senddocument - + :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` @@ -4392,7 +4392,7 @@ async def send_document( :param thumb: Deprecated. Use thumbnail instead :type thumb: :obj:`str` or :class:`telebot.types.InputFile` - + :param reply_parameters: Reply parameters. :type reply_parameters: :class:`telebot.types.ReplyParameters` @@ -4421,7 +4421,7 @@ async def send_document( parse_mode = self.parse_mode if (parse_mode is None) else parse_mode disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + if data and not(document): # function typo miss compatibility @@ -4434,7 +4434,7 @@ async def send_document( if allow_sending_without_reply is not None: logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.") - + if reply_to_message_id: # show a deprecation warning logger.warning("The parameter 'reply_to_message_id' is deprecated. Use 'reply_parameters' instead.") @@ -4455,7 +4455,7 @@ async def send_document( if isinstance(document, types.InputFile) and visible_file_name: # inputfile name ignored, warn logger.warning('Cannot use both InputFile and visible_file_name. InputFile name will be ignored.') - + return types.Message.de_json( await asyncio_helper.send_data( self.token, chat_id, document, 'document', @@ -4469,10 +4469,10 @@ async def send_document( ) async def send_sticker( - self, chat_id: Union[int, str], sticker: Union[Any, str], - reply_to_message_id: Optional[int]=None, + self, chat_id: Union[int, str], sticker: Union[Any, str], + reply_to_message_id: Optional[int]=None, reply_markup: Optional[REPLY_MARKUP_TYPES]=None, - disable_notification: Optional[bool]=None, + disable_notification: Optional[bool]=None, timeout: Optional[int]=None, allow_sending_without_reply: Optional[bool]=None, protect_content: Optional[bool]=None, @@ -4526,7 +4526,7 @@ async def send_sticker( :param emoji: Emoji associated with the sticker; only for just uploaded stickers :type emoji: :obj:`str` - + :param reply_parameters: Reply parameters. :type reply_parameters: :class:`telebot.types.ReplyParameters` @@ -4554,7 +4554,7 @@ async def send_sticker( """ disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + if data and not(sticker): # function typo miss compatibility @@ -4563,7 +4563,7 @@ async def send_sticker( if allow_sending_without_reply is not None: logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.") - + if reply_to_message_id: # show a deprecation warning logger.warning("The parameter 'reply_to_message_id' is deprecated. Use 'reply_parameters' instead.") @@ -4585,7 +4585,7 @@ async def send_sticker( await asyncio_helper.send_data( self.token, chat_id, sticker, 'sticker', reply_markup=reply_markup, - disable_notification=disable_notification, timeout=timeout, + disable_notification=disable_notification, timeout=timeout, protect_content=protect_content, message_thread_id=message_thread_id, emoji=emoji, reply_parameters=reply_parameters, business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast, suggested_post_parameters=suggested_post_parameters, direct_messages_topic_id=direct_messages_topic_id @@ -4593,18 +4593,18 @@ async def send_sticker( ) async def send_video( - self, chat_id: Union[int, str], video: Union[Any, str], + self, chat_id: Union[int, str], video: Union[Any, str], duration: Optional[int]=None, width: Optional[int]=None, height: Optional[int]=None, - thumbnail: Optional[Union[Any, str]]=None, - caption: Optional[str]=None, - parse_mode: Optional[str]=None, + thumbnail: Optional[Union[Any, str]]=None, + caption: Optional[str]=None, + parse_mode: Optional[str]=None, caption_entities: Optional[List[types.MessageEntity]]=None, - supports_streaming: Optional[bool]=None, + supports_streaming: Optional[bool]=None, disable_notification: Optional[bool]=None, protect_content: Optional[bool]=None, - reply_to_message_id: Optional[int]=None, + reply_to_message_id: Optional[int]=None, allow_sending_without_reply: Optional[bool]=None, reply_markup: Optional[REPLY_MARKUP_TYPES]=None, timeout: Optional[int]=None, @@ -4623,7 +4623,7 @@ async def send_video( suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message: """ Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). - + Telegram documentation: https://core.telegram.org/bots/api#sendvideo :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) @@ -4651,7 +4651,7 @@ async def send_video( :param start_timestamp: Start timestamp for the video in the message :type start_timestamp: :obj:`int` - + :param caption: Video caption (may also be used when resending videos by file_id), 0-1024 characters after entities parsing :type caption: :obj:`str` @@ -4695,7 +4695,7 @@ async def send_video( :param thumb: Deprecated. Use thumbnail instead :type thumb: :obj:`str` or :class:`telebot.types.InputFile` - + :param reply_parameters: Reply parameters. :type reply_parameters: :class:`telebot.types.ReplyParameters` @@ -4726,11 +4726,11 @@ async def send_video( parse_mode = self.parse_mode if (parse_mode is None) else parse_mode disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + if allow_sending_without_reply is not None: logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.") - + if reply_to_message_id: # show a deprecation warning logger.warning("The parameter 'reply_to_message_id' is deprecated. Use 'reply_parameters' instead.") @@ -4766,19 +4766,19 @@ async def send_video( direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters)) async def send_animation( - self, chat_id: Union[int, str], animation: Union[Any, str], + self, chat_id: Union[int, str], animation: Union[Any, str], duration: Optional[int]=None, width: Optional[int]=None, height: Optional[int]=None, thumbnail: Optional[Union[Any, str]]=None, - caption: Optional[str]=None, + caption: Optional[str]=None, parse_mode: Optional[str]=None, caption_entities: Optional[List[types.MessageEntity]]=None, disable_notification: Optional[bool]=None, protect_content: Optional[bool]=None, reply_to_message_id: Optional[int]=None, allow_sending_without_reply: Optional[bool]=None, - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, timeout: Optional[int]=None, message_thread_id: Optional[int]=None, has_spoiler: Optional[bool]=None, @@ -4793,7 +4793,7 @@ async def send_animation( """ Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. - + Telegram documentation: https://core.telegram.org/bots/api#sendanimation :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) @@ -4811,7 +4811,7 @@ async def send_animation( :param height: Animation height :type height: :obj:`int` - + :param thumbnail: 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, @@ -4855,7 +4855,7 @@ async def send_animation( :param thumb: Deprecated. Use thumbnail instead :type thumb: :obj:`str` or :class:`telebot.types.InputFile` - + :param reply_parameters: Reply parameters. :type reply_parameters: :class:`telebot.types.ReplyParameters` @@ -4887,11 +4887,11 @@ async def send_animation( parse_mode = self.parse_mode if (parse_mode is None) else parse_mode disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + if allow_sending_without_reply is not None: logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.") - + if reply_to_message_id: # show a deprecation warning logger.warning("The parameter 'reply_to_message_id' is deprecated. Use 'reply_parameters' instead.") @@ -4922,13 +4922,13 @@ async def send_animation( direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters)) async def send_video_note( - self, chat_id: Union[int, str], data: Union[Any, str], - duration: Optional[int]=None, + self, chat_id: Union[int, str], data: Union[Any, str], + duration: Optional[int]=None, length: Optional[int]=None, - reply_to_message_id: Optional[int]=None, + reply_to_message_id: Optional[int]=None, reply_markup: Optional[REPLY_MARKUP_TYPES]=None, - disable_notification: Optional[bool]=None, - timeout: Optional[int]=None, + disable_notification: Optional[bool]=None, + timeout: Optional[int]=None, thumbnail: Optional[Union[Any, str]]=None, allow_sending_without_reply: Optional[bool]=None, protect_content: Optional[bool]=None, @@ -4945,10 +4945,10 @@ async def send_video_note( Use this method to send video messages. On success, the sent Message is returned. Telegram documentation: https://core.telegram.org/bots/api#sendvideonote - + :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` - + :param data: Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. Sending video notes by a URL is currently unsupported :type data: :obj:`str` or :class:`telebot.types.InputFile` @@ -4976,7 +4976,7 @@ async def send_video_note( :param thumbnail: 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 . + so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . :type thumbnail: :obj:`str` or :class:`telebot.types.InputFile` :param allow_sending_without_reply: Deprecated - Use reply_parameters instead. Pass True, if the message should be sent even if the specified replied-to message is not found @@ -4990,7 +4990,7 @@ async def send_video_note( :param thumb: Deprecated. Use thumbnail instead :type thumb: :obj:`str` or :class:`telebot.types.InputFile` - + :param reply_parameters: Reply parameters. :type reply_parameters: :class:`telebot.types.ReplyParameters` @@ -5018,11 +5018,11 @@ async def send_video_note( """ disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + if allow_sending_without_reply is not None: logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.") - + if reply_to_message_id: # show a deprecation warning logger.warning("The parameter 'reply_to_message_id' is deprecated. Use 'reply_parameters' instead.") @@ -5134,13 +5134,13 @@ async def send_paid_media( ) async def send_media_group( - self, chat_id: Union[int, str], + self, chat_id: Union[int, str], media: List[Union[ - types.InputMediaAudio, types.InputMediaDocument, + types.InputMediaAudio, types.InputMediaDocument, types.InputMediaPhoto, types.InputMediaVideo]], - disable_notification: Optional[bool]=None, + disable_notification: Optional[bool]=None, protect_content: Optional[bool]=None, - reply_to_message_id: Optional[int]=None, + reply_to_message_id: Optional[int]=None, timeout: Optional[int]=None, allow_sending_without_reply: Optional[bool]=None, message_thread_id: Optional[int]=None, @@ -5153,7 +5153,7 @@ async def send_media_group( """ Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned. - + Telegram documentation: https://core.telegram.org/bots/api#sendmediagroup :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) @@ -5179,7 +5179,7 @@ async def send_media_group( :param message_thread_id: Identifier of a message thread, in which the messages will be sent :type message_thread_id: :obj:`int` - + :param reply_parameters: Reply parameters. :type reply_parameters: :class:`telebot.types.ReplyParameters` @@ -5212,11 +5212,11 @@ async def send_media_group( media_item.parse_mode = self.parse_mode disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + if allow_sending_without_reply is not None: logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.") - + if reply_to_message_id: # show a deprecation warning logger.warning("The parameter 'reply_to_message_id' is deprecated. Use 'reply_parameters' instead.") @@ -5241,16 +5241,16 @@ async def send_media_group( return [types.Message.de_json(msg) for msg in result] async def send_location( - self, chat_id: Union[int, str], - latitude: float, longitude: float, - live_period: Optional[int]=None, - reply_to_message_id: Optional[int]=None, - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, - disable_notification: Optional[bool]=None, + self, chat_id: Union[int, str], + latitude: float, longitude: float, + live_period: Optional[int]=None, + reply_to_message_id: Optional[int]=None, + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + disable_notification: Optional[bool]=None, timeout: Optional[int]=None, - horizontal_accuracy: Optional[float]=None, - heading: Optional[int]=None, - proximity_alert_radius: Optional[int]=None, + horizontal_accuracy: Optional[float]=None, + heading: Optional[int]=None, + proximity_alert_radius: Optional[int]=None, allow_sending_without_reply: Optional[bool]=None, protect_content: Optional[bool]=None, message_thread_id: Optional[int]=None, @@ -5302,13 +5302,13 @@ async def send_location( :param allow_sending_without_reply: Deprecated - Use reply_parameters instead. Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`bool` - + :param protect_content: Protects the contents of the sent message from forwarding and saving :type protect_content: :obj:`bool` :param message_thread_id: Identifier of a message thread, in which the message will be sent :type message_thread_id: :obj:`int` - + :param reply_parameters: Reply parameters. :type reply_parameters: :class:`telebot.types.ReplyParameters` @@ -5336,11 +5336,11 @@ async def send_location( """ disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + if allow_sending_without_reply is not None: logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.") - + if reply_to_message_id: # show a deprecation warning logger.warning("The parameter 'reply_to_message_id' is deprecated. Use 'reply_parameters' instead.") @@ -5369,14 +5369,14 @@ async def send_location( ) async def edit_message_live_location( - self, latitude: float, longitude: float, - chat_id: Optional[Union[int, str]]=None, + self, latitude: float, longitude: float, + chat_id: Optional[Union[int, str]]=None, message_id: Optional[int]=None, - inline_message_id: Optional[str]=None, + inline_message_id: Optional[str]=None, reply_markup: Optional[types.InlineKeyboardMarkup]=None, timeout: Optional[int]=None, - horizontal_accuracy: Optional[float]=None, - heading: Optional[int]=None, + horizontal_accuracy: Optional[float]=None, + heading: Optional[int]=None, proximity_alert_radius: Optional[int]=None, live_period: Optional[int]=None, business_connection_id: Optional[str]=None @@ -5436,9 +5436,9 @@ async def edit_message_live_location( ) async def stop_message_live_location( - self, chat_id: Optional[Union[int, str]]=None, + self, chat_id: Optional[Union[int, str]]=None, message_id: Optional[int]=None, - inline_message_id: Optional[str]=None, + inline_message_id: Optional[str]=None, reply_markup: Optional[types.InlineKeyboardMarkup]=None, timeout: Optional[int]=None, business_connection_id: Optional[str]=None) -> types.Message: @@ -5447,7 +5447,7 @@ async def stop_message_live_location( On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned. Telegram documentation: https://core.telegram.org/bots/api#stopmessagelivelocation - + :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` @@ -5475,14 +5475,14 @@ async def stop_message_live_location( self.token, chat_id, message_id, inline_message_id, reply_markup, timeout, business_connection_id)) async def send_venue( - self, chat_id: Union[int, str], - latitude: float, longitude: float, - title: str, address: str, - foursquare_id: Optional[str]=None, + self, chat_id: Union[int, str], + latitude: float, longitude: float, + title: str, address: str, + foursquare_id: Optional[str]=None, foursquare_type: Optional[str]=None, - disable_notification: Optional[bool]=None, - reply_to_message_id: Optional[int]=None, - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + disable_notification: Optional[bool]=None, + reply_to_message_id: Optional[int]=None, + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, timeout: Optional[int]=None, allow_sending_without_reply: Optional[bool]=None, google_place_id: Optional[str]=None, @@ -5497,12 +5497,12 @@ async def send_venue( suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message: """ Use this method to send information about a venue. On success, the sent Message is returned. - + Telegram documentation: https://core.telegram.org/bots/api#sendvenue :param chat_id: Unique identifier for the target chat or username of the target channel :type chat_id: :obj:`int` or :obj:`str` - + :param latitude: Latitude of the venue :type latitude: :obj:`float` @@ -5551,7 +5551,7 @@ async def send_venue( :param message_thread_id: The thread to which the message will be sent :type message_thread_id: :obj:`int` - + :param reply_parameters: Reply parameters. :type reply_parameters: :class:`telebot.types.ReplyParameters` @@ -5560,7 +5560,7 @@ async def send_venue( :param message_effect_id: Unique identifier of the message effect :type message_effect_id: :obj:`str` - + :param allow_paid_broadcast: Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance :type allow_paid_broadcast: :obj:`bool` @@ -5579,11 +5579,11 @@ async def send_venue( """ disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + if allow_sending_without_reply is not None: logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.") - + if reply_to_message_id: # show a deprecation warning logger.warning("The parameter 'reply_to_message_id' is deprecated. Use 'reply_parameters' instead.") @@ -5608,15 +5608,14 @@ async def send_venue( google_place_id, google_place_type, protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast, direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters) ) - async def send_contact( - self, chat_id: Union[int, str], phone_number: str, - first_name: str, last_name: Optional[str]=None, + self, chat_id: Union[int, str], phone_number: str, + first_name: str, last_name: Optional[str]=None, vcard: Optional[str]=None, - disable_notification: Optional[bool]=None, - reply_to_message_id: Optional[int]=None, - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + disable_notification: Optional[bool]=None, + reply_to_message_id: Optional[int]=None, + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, timeout: Optional[int]=None, allow_sending_without_reply: Optional[bool]=None, protect_content: Optional[bool]=None, @@ -5670,7 +5669,7 @@ async def send_contact( :param message_thread_id: The thread to which the message will be sent :type message_thread_id: :obj:`int` - + :param reply_parameters: Reply parameters. :type reply_parameters: :class:`telebot.types.ReplyParameters` @@ -5698,11 +5697,11 @@ async def send_contact( """ disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + if allow_sending_without_reply is not None: logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.") - + if reply_to_message_id: # show a deprecation warning logger.warning("The parameter 'reply_to_message_id' is deprecated. Use 'reply_parameters' instead.") @@ -5727,7 +5726,6 @@ async def send_contact( protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast, direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters) ) - async def send_chat_action( self, chat_id: Union[int, str], action: str, timeout: Optional[int]=None, message_thread_id: Optional[int]=None, @@ -5744,7 +5742,7 @@ async def send_chat_action( :param chat_id: Unique identifier for the target chat or username of the target channel :type chat_id: :obj:`int` or :obj:`str` - + :param action: Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, @@ -5766,8 +5764,8 @@ async def send_chat_action( return await asyncio_helper.send_chat_action(self.token, chat_id, action, timeout, message_thread_id, business_connection_id) async def kick_chat_member( - self, chat_id: Union[int, str], user_id: int, - until_date:Optional[Union[int, datetime]]=None, + self, chat_id: Union[int, str], user_id: int, + until_date:Optional[Union[int, datetime]]=None, revoke_messages: Optional[bool]=None) -> bool: """ This function is deprecated. Use `ban_chat_member` instead @@ -5776,13 +5774,13 @@ async def kick_chat_member( return await asyncio_helper.ban_chat_member(self.token, chat_id, user_id, until_date, revoke_messages) async def ban_chat_member( - self, chat_id: Union[int, str], user_id: int, - until_date:Optional[Union[int, datetime]]=None, + self, chat_id: Union[int, str], user_id: int, + until_date:Optional[Union[int, datetime]]=None, revoke_messages: Optional[bool]=None) -> bool: """ - Use this method to ban a user in a group, a supergroup or a channel. - In the case of supergroups and channels, the user will not be able to return to the chat on their - own using invite links, etc., unless unbanned first. + Use this method to ban a user in a group, a supergroup or a channel. + In the case of supergroups and channels, the user will not be able to return to the chat on their + own using invite links, etc., unless unbanned first. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#banchatmember @@ -5799,17 +5797,17 @@ async def ban_chat_member( :type until_date: :obj:`int` or :obj:`datetime` :param revoke_messages: Bool: Pass True to delete all messages from the chat for the user that is being removed. - If False, the user will be able to see messages in the group that were sent before the user was removed. + If False, the user will be able to see messages in the group that were sent before the user was removed. Always True for supergroups and channels. :type revoke_messages: :obj:`bool` - + :return: Returns True on success. :rtype: :obj:`bool` """ return await asyncio_helper.ban_chat_member(self.token, chat_id, user_id, until_date, revoke_messages) async def unban_chat_member( - self, chat_id: Union[int, str], user_id: int, + self, chat_id: Union[int, str], user_id: int, only_if_banned: Optional[bool]=False) -> bool: """ Use this method to unban a previously kicked user in a supergroup or channel. @@ -5836,15 +5834,15 @@ async def unban_chat_member( return await asyncio_helper.unban_chat_member(self.token, chat_id, user_id, only_if_banned) async def restrict_chat_member( - self, chat_id: Union[int, str], user_id: int, + self, chat_id: Union[int, str], user_id: int, until_date: Optional[Union[int, datetime]]=None, - can_send_messages: Optional[bool]=None, + can_send_messages: Optional[bool]=None, can_send_media_messages: Optional[bool]=None, - can_send_polls: Optional[bool]=None, + can_send_polls: Optional[bool]=None, can_send_other_messages: Optional[bool]=None, - can_add_web_page_previews: Optional[bool]=None, + can_add_web_page_previews: Optional[bool]=None, can_change_info: Optional[bool]=None, - can_invite_users: Optional[bool]=None, + can_invite_users: Optional[bool]=None, can_pin_messages: Optional[bool]=None, permissions: Optional[types.ChatPermissions]=None, use_independent_chat_permissions: Optional[bool]=None) -> bool: @@ -5872,10 +5870,10 @@ async def restrict_chat_member( :param can_send_messages: deprecated :type can_send_messages: :obj:`bool` - + :param can_send_media_messages: deprecated :type can_send_media_messages: :obj:`bool` - + :param can_send_polls: deprecated :type can_send_polls: :obj:`bool` @@ -5923,17 +5921,17 @@ async def restrict_chat_member( self.token, chat_id, user_id, permissions, until_date, use_independent_chat_permissions) async def promote_chat_member( - self, chat_id: Union[int, str], user_id: int, - can_change_info: Optional[bool]=None, + self, chat_id: Union[int, str], user_id: int, + can_change_info: Optional[bool]=None, can_post_messages: Optional[bool]=None, - can_edit_messages: Optional[bool]=None, - can_delete_messages: Optional[bool]=None, + can_edit_messages: Optional[bool]=None, + can_delete_messages: Optional[bool]=None, can_invite_users: Optional[bool]=None, - can_restrict_members: Optional[bool]=None, - can_pin_messages: Optional[bool]=None, + can_restrict_members: Optional[bool]=None, + can_pin_messages: Optional[bool]=None, can_promote_members: Optional[bool]=None, - is_anonymous: Optional[bool]=None, - can_manage_chat: Optional[bool]=None, + is_anonymous: Optional[bool]=None, + can_manage_chat: Optional[bool]=None, can_manage_video_chats: Optional[bool]=None, can_manage_voice_chats: Optional[bool]=None, can_manage_topics: Optional[bool]=None, @@ -5984,9 +5982,9 @@ async def promote_chat_member( :param is_anonymous: Pass True, if the administrator's presence in the chat is hidden :type is_anonymous: :obj:`bool` - :param can_manage_chat: Pass 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. + :param can_manage_chat: Pass 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` @@ -6059,10 +6057,10 @@ async def set_chat_administrator_custom_title( async def ban_chat_sender_chat(self, chat_id: Union[int, str], sender_chat_id: Union[int, str]) -> bool: """ Use this method to ban a channel chat in a supergroup or a channel. - The owner of the chat will not be able to send messages and join live - streams on behalf of the chat, unless it is unbanned first. - The bot must be an administrator in the supergroup or channel - for this to work and must have the appropriate administrator rights. + The owner of the chat will not be able to send messages and join live + streams on behalf of the chat, unless it is unbanned first. + The bot must be an administrator in the supergroup or channel + for this to work and must have the appropriate administrator rights. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#banchatsenderchat @@ -6080,8 +6078,8 @@ async def ban_chat_sender_chat(self, chat_id: Union[int, str], sender_chat_id: U async def unban_chat_sender_chat(self, chat_id: Union[int, str], sender_chat_id: Union[int, str]) -> bool: """ - Use this method to unban a previously banned channel chat in a supergroup or channel. - The bot must be an administrator for this to work and must have the appropriate + Use this method to unban a previously banned channel chat in a supergroup or channel. + The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns True on success. @@ -6129,7 +6127,7 @@ async def set_chat_permissions( async def create_chat_invite_link( self, chat_id: Union[int, str], name: Optional[str]=None, - expire_date: Optional[Union[int, datetime]]=None, + expire_date: Optional[Union[int, datetime]]=None, member_limit: Optional[int]=None, creates_join_request: Optional[bool]=None) -> types.ChatInviteLink: """ @@ -6201,7 +6199,7 @@ async def edit_chat_invite_link( return types.ChatInviteLink.de_json( await asyncio_helper.edit_chat_invite_link(self.token, chat_id, invite_link, name, expire_date, member_limit, creates_join_request) ) - + async def create_chat_subscription_invite_link( self, chat_id: Union[int, str], subscription_period: int, subscription_price: int, name: Optional[str]=None) -> types.ChatInviteLink: @@ -6215,7 +6213,7 @@ async def create_chat_subscription_invite_link( :param chat_id: Unique identifier for the target channel chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` - + :param name: Invite link name; 0-32 characters :type name: :obj:`str` @@ -6263,7 +6261,7 @@ async def revoke_chat_invite_link( self, chat_id: Union[int, str], invite_link: str) -> types.ChatInviteLink: """ Use this method to revoke an invite link created by the bot. - Note: If the primary link is revoked, a new link is automatically generated The bot must be an administrator + Note: If the primary link is revoked, a new link is automatically generated The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Telegram documentation: https://core.telegram.org/bots/api#revokechatinvitelink @@ -6301,7 +6299,7 @@ async def export_chat_invite_link(self, chat_id: Union[int, str]) -> str: async def approve_chat_join_request(self, chat_id: Union[str, int], user_id: Union[int, str]) -> bool: """ - Use this method to approve a chat join request. + Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success. @@ -6321,7 +6319,7 @@ async def approve_chat_join_request(self, chat_id: Union[str, int], user_id: Uni async def decline_chat_join_request(self, chat_id: Union[str, int], user_id: Union[int, str]) -> bool: """ - Use this method to decline a chat join request. + Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success. @@ -6377,7 +6375,7 @@ async def delete_chat_photo(self, chat_id: Union[int, str]) -> bool: :rtype: :obj:`bool` """ return await asyncio_helper.delete_chat_photo(self.token, chat_id) - + async def set_my_description(self, description: Optional[str]=None, language_code: Optional[str]=None): """ Use this method to change the bot's description, which is shown in @@ -6408,11 +6406,11 @@ async def get_my_description(self, language_code: Optional[str]=None): """ result = await asyncio_helper.get_my_description(self.token, language_code) return types.BotDescription.de_json(result) - + async def set_my_short_description(self, short_description:Optional[str]=None, language_code:Optional[str]=None): """ Use this method to change the bot's short description, which is shown on the bot's profile page and - is sent together with the link when users share the bot. + is sent together with the link when users share the bot. Returns True on success. :param short_description: New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language. @@ -6426,7 +6424,7 @@ async def set_my_short_description(self, short_description:Optional[str]=None, l """ return await asyncio_helper.set_my_short_description(self.token, short_description, language_code) - + async def get_my_short_description(self, language_code: Optional[str]=None): """ Use this method to get the current bot short description for the given user language. @@ -6439,21 +6437,21 @@ async def get_my_short_description(self, language_code: Optional[str]=None): """ result = await asyncio_helper.get_my_short_description(self.token, language_code) return types.BotShortDescription.de_json(result) - - async def get_my_commands(self, scope: Optional[types.BotCommandScope], + + async def get_my_commands(self, scope: Optional[types.BotCommandScope], language_code: Optional[str]) -> List[types.BotCommand]: """ - Use this method to get the current list of the bot's commands. + Use this method to get the current list of the bot's commands. Returns List of BotCommand on success. Telegram documentation: https://core.telegram.org/bots/api#getmycommands - :param scope: The scope of users for which the commands are relevant. + :param scope: The scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault. :type scope: :class:`telebot.types.BotCommandScope` - :param language_code: A two-letter ISO 639-1 language code. If empty, - commands will be applied to all users from the given scope, + :param language_code: A two-letter ISO 639-1 language code. If empty, + commands will be applied to all users from the given scope, for whose language there are no dedicated commands :type language_code: :obj:`str` @@ -6497,16 +6495,16 @@ async def get_my_name(self, language_code: Optional[str]=None): result = await asyncio_helper.get_my_name(self.token, language_code) return types.BotName.de_json(result) - async def set_chat_menu_button(self, chat_id: Union[int, str]=None, + async def set_chat_menu_button(self, chat_id: Union[int, str]=None, menu_button: types.MenuButton=None) -> bool: """ - Use this method to change the bot's menu button in a private chat, - or the default menu button. + Use this method to change the bot's menu button in a private chat, + or the default menu button. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#setchatmenubutton - :param chat_id: Unique identifier for the target private chat. + :param chat_id: Unique identifier for the target private chat. If not specified, default bot's menu button will be changed. :type chat_id: :obj:`int` or :obj:`str` @@ -6537,13 +6535,13 @@ async def get_chat_menu_button(self, chat_id: Union[int, str]=None) -> types.Men return types.MenuButton.de_json(await asyncio_helper.get_chat_menu_button(self.token, chat_id)) - async def set_my_default_administrator_rights(self, rights: types.ChatAdministratorRights=None, + async def set_my_default_administrator_rights(self, rights: types.ChatAdministratorRights=None, for_channels: bool=None) -> bool: """ Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are are free to modify - the list before adding the bot. + the list before adding the bot. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#setmydefaultadministratorrights @@ -6561,7 +6559,7 @@ async def set_my_default_administrator_rights(self, rights: types.ChatAdministra """ return await asyncio_helper.set_my_default_administrator_rights(self.token, rights, for_channels) - + async def get_my_default_administrator_rights(self, for_channels: bool=None) -> types.ChatAdministratorRights: """ @@ -6576,9 +6574,9 @@ async def get_my_default_administrator_rights(self, for_channels: bool=None) -> :return: Returns ChatAdministratorRights on success. :rtype: :class:`telebot.types.ChatAdministratorRights` """ - + return types.ChatAdministratorRights.de_json(await asyncio_helper.get_my_default_administrator_rights(self.token, for_channels)) - + async def get_business_connection(self, business_connection_id: str) -> types.BusinessConnection: """ Use this method to get information about the connection of the bot with a business account. @@ -6597,9 +6595,9 @@ async def get_business_connection(self, business_connection_id: str) -> types.Bu return types.BusinessConnection.de_json( result ) - - async def set_my_commands(self, commands: List[types.BotCommand], + + async def set_my_commands(self, commands: List[types.BotCommand], scope: Optional[types.BotCommandScope]=None, language_code: Optional[str]=None) -> bool: """ @@ -6610,12 +6608,12 @@ async def set_my_commands(self, commands: List[types.BotCommand], :param commands: List of BotCommand. At most 100 commands can be specified. :type commands: :obj:`list` of :class:`telebot.types.BotCommand` - :param scope: The scope of users for which the commands are relevant. + :param scope: The scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault. :type scope: :class:`telebot.types.BotCommandScope` - :param language_code: A two-letter ISO 639-1 language code. If empty, - commands will be applied to all users from the given scope, + :param language_code: A two-letter ISO 639-1 language code. If empty, + commands will be applied to all users from the given scope, for whose language there are no dedicated commands :type language_code: :obj:`str` @@ -6623,22 +6621,22 @@ async def set_my_commands(self, commands: List[types.BotCommand], :rtype: :obj:`bool` """ return await asyncio_helper.set_my_commands(self.token, commands, scope, language_code) - - async def delete_my_commands(self, scope: Optional[types.BotCommandScope]=None, + + async def delete_my_commands(self, scope: Optional[types.BotCommandScope]=None, language_code: Optional[int]=None) -> bool: """ - Use this method to delete the list of the bot's commands for the given scope and user language. - After deletion, higher level commands will be shown to affected users. + Use this method to delete the list of the bot's commands for the given scope and user language. + After deletion, higher level commands will be shown to affected users. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#deletemycommands - - :param scope: The scope of users for which the commands are relevant. + + :param scope: The scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault. :type scope: :class:`telebot.types.BotCommandScope` - :param language_code: A two-letter ISO 639-1 language code. If empty, - commands will be applied to all users from the given scope, + :param language_code: A two-letter ISO 639-1 language code. If empty, + commands will be applied to all users from the given scope, for whose language there are no dedicated commands :type language_code: :obj:`str` @@ -6689,7 +6687,7 @@ async def set_chat_description(self, chat_id: Union[int, str], description: Opti return await asyncio_helper.set_chat_description(self.token, chat_id, description) async def pin_chat_message( - self, chat_id: Union[int, str], message_id: int, + self, chat_id: Union[int, str], message_id: int, disable_notification: Optional[bool]=False, business_connection_id: Optional[str]=None) -> bool: """ Use this method to pin a message in a supergroup. @@ -6760,10 +6758,10 @@ async def unpin_all_chat_messages(self, chat_id: Union[int, str]) -> bool: return await asyncio_helper.unpin_all_chat_messages(self.token, chat_id) async def edit_message_text( - self, text: str, - chat_id: Optional[Union[int, str]]=None, - message_id: Optional[int]=None, - inline_message_id: Optional[str]=None, + self, text: str, + chat_id: Optional[Union[int, str]]=None, + message_id: Optional[int]=None, + inline_message_id: Optional[str]=None, parse_mode: Optional[str]=None, entities: Optional[List[types.MessageEntity]]=None, disable_web_page_preview: Optional[bool]=None, @@ -6841,9 +6839,9 @@ async def edit_message_text( return types.Message.de_json(result) async def edit_message_media( - self, media: Any, chat_id: Optional[Union[int, str]]=None, + self, media: Any, chat_id: Optional[Union[int, str]]=None, message_id: Optional[int]=None, - inline_message_id: Optional[str]=None, + inline_message_id: Optional[str]=None, reply_markup: Optional[types.InlineKeyboardMarkup]=None, business_connection_id: Optional[str]=None, timeout: Optional[int]=None) -> Union[types.Message, bool]: @@ -6852,7 +6850,7 @@ async def edit_message_media( If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. - Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. Telegram documentation: https://core.telegram.org/bots/api#editmessagemedia @@ -6861,7 +6859,7 @@ async def edit_message_media( :param chat_id: Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` - :param message_id: Required if inline_message_id is not specified. Identifier of the sent message + :param message_id: Required if inline_message_id is not specified. Identifier of the sent message :type message_id: :obj:`int` :param inline_message_id: Required if chat_id and message_id are not specified. Identifier of the inline message @@ -6886,9 +6884,9 @@ async def edit_message_media( return types.Message.de_json(result) async def edit_message_reply_markup( - self, chat_id: Optional[Union[int, str]]=None, + self, chat_id: Optional[Union[int, str]]=None, message_id: Optional[int]=None, - inline_message_id: Optional[str]=None, + inline_message_id: Optional[str]=None, reply_markup: Optional[types.InlineKeyboardMarkup]=None, business_connection_id: Optional[str]=None, timeout: Optional[int]=None) -> Union[types.Message, bool]: @@ -6925,10 +6923,10 @@ async def edit_message_reply_markup( return types.Message.de_json(result) async def send_game( - self, chat_id: Union[int, str], game_short_name: str, + self, chat_id: Union[int, str], game_short_name: str, disable_notification: Optional[bool]=None, - reply_to_message_id: Optional[int]=None, - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + reply_to_message_id: Optional[int]=None, + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, timeout: Optional[int]=None, allow_sending_without_reply: Optional[bool]=None, protect_content: Optional[bool]=None, @@ -6951,7 +6949,7 @@ async def send_game( :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :type disable_notification: :obj:`bool` - :param reply_to_message_id: Deprecated - Use reply_parameters instead. If the message is a reply, ID of the original message + :param reply_to_message_id: Deprecated - Use reply_parameters instead. If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`int` :param reply_markup: Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. @@ -6968,7 +6966,7 @@ async def send_game( :param message_thread_id: Identifier of the thread to which the message will be sent. :type message_thread_id: :obj:`int` - + :param reply_parameters: Reply parameters. :type reply_parameters: :class:`telebot.types.ReplyParameters` @@ -6987,11 +6985,11 @@ async def send_game( """ disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + if allow_sending_without_reply is not None: logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.") - + if reply_to_message_id: # show a deprecation warning logger.warning("The parameter 'reply_to_message_id' is deprecated. Use 'reply_parameters' instead.") @@ -7011,15 +7009,15 @@ async def send_game( result = await asyncio_helper.send_game( self.token, chat_id, game_short_name, disable_notification, - reply_markup, timeout, + reply_markup, timeout, protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast) return types.Message.de_json(result) async def set_game_score( - self, user_id: Union[int, str], score: int, - force: Optional[bool]=None, - chat_id: Optional[Union[int, str]]=None, - message_id: Optional[int]=None, + self, user_id: Union[int, str], score: int, + force: Optional[bool]=None, + chat_id: Optional[Union[int, str]]=None, + message_id: Optional[int]=None, inline_message_id: Optional[str]=None, disable_edit_message: Optional[bool]=None) -> Union[types.Message, bool]: """ @@ -7059,7 +7057,7 @@ async def set_game_score( async def get_game_high_scores( self, user_id: int, chat_id: Optional[Union[int, str]]=None, - message_id: Optional[int]=None, + message_id: Optional[int]=None, inline_message_id: Optional[str]=None) -> List[types.GameHighScore]: """ Use this method to get data for high score tables. Will return the score of the specified user and several of @@ -7090,20 +7088,20 @@ async def get_game_high_scores( return [types.GameHighScore.de_json(r) for r in result] async def send_invoice( - self, chat_id: Union[int, str], title: str, description: str, - invoice_payload: str, provider_token: Union[str, None], currency: str, - prices: List[types.LabeledPrice], start_parameter: Optional[str]=None, - photo_url: Optional[str]=None, photo_size: Optional[int]=None, + self, chat_id: Union[int, str], title: str, description: str, + invoice_payload: str, provider_token: Union[str, None], currency: str, + prices: List[types.LabeledPrice], start_parameter: Optional[str]=None, + photo_url: Optional[str]=None, photo_size: Optional[int]=None, photo_width: Optional[int]=None, photo_height: Optional[int]=None, - need_name: Optional[bool]=None, need_phone_number: Optional[bool]=None, + need_name: Optional[bool]=None, need_phone_number: Optional[bool]=None, need_email: Optional[bool]=None, need_shipping_address: Optional[bool]=None, - send_phone_number_to_provider: Optional[bool]=None, - send_email_to_provider: Optional[bool]=None, + send_phone_number_to_provider: Optional[bool]=None, + send_email_to_provider: Optional[bool]=None, is_flexible: Optional[bool]=None, - disable_notification: Optional[bool]=None, - reply_to_message_id: Optional[int]=None, - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, - provider_data: Optional[str]=None, + disable_notification: Optional[bool]=None, + reply_to_message_id: Optional[int]=None, + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + provider_data: Optional[str]=None, timeout: Optional[int]=None, allow_sending_without_reply: Optional[bool]=None, max_tip_amount: Optional[int] = None, @@ -7156,7 +7154,7 @@ async def send_invoice( :param photo_size: Photo size in bytes :type photo_size: :obj:`int` - :param photo_width: Photo width + :param photo_width: Photo width :type photo_width: :obj:`int` :param photo_height: Photo height @@ -7216,7 +7214,7 @@ async def send_invoice( :param message_thread_id: The identifier of a message thread, in which the invoice message will be sent :type message_thread_id: :obj:`int` - + :param reply_parameters: Reply parameters. :type reply_parameters: :class:`telebot.types.ReplyParameters` @@ -7241,11 +7239,11 @@ async def send_invoice( """ disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + if allow_sending_without_reply is not None: logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.") - + if reply_to_message_id: # show a deprecation warning logger.warning("The parameter 'reply_to_message_id' is deprecated. Use 'reply_parameters' instead.") @@ -7277,9 +7275,9 @@ async def send_invoice( async def create_invoice_link(self, - title: str, description: str, payload:str, provider_token: Union[str, None], + title: str, description: str, payload:str, provider_token: Union[str, None], currency: str, prices: List[types.LabeledPrice], - max_tip_amount: Optional[int] = None, + max_tip_amount: Optional[int] = None, suggested_tip_amounts: Optional[List[int]]=None, provider_data: Optional[str]=None, photo_url: Optional[str]=None, @@ -7295,14 +7293,14 @@ async def create_invoice_link(self, is_flexible: Optional[bool]=None, subscription_period: Optional[int]=None, business_connection_id: Optional[str]=None) -> str: - + """ - Use this method to create a link for an invoice. + Use this method to create a link for an invoice. Returns the created invoice link as String on success. Telegram documentation: https://core.telegram.org/bots/api#createinvoicelink - + :param business_connection_id: Unique identifier of the business connection on behalf of which the link will be created :type business_connection_id: :obj:`str` @@ -7393,18 +7391,18 @@ async def create_invoice_link(self, # noinspection PyShadowingBuiltins async def send_poll( self, chat_id: Union[int, str], question: str, options: List[Union[str, types.InputPollOption]], - is_anonymous: Optional[bool]=None, type: Optional[str]=None, - allows_multiple_answers: Optional[bool]=None, + is_anonymous: Optional[bool]=None, type: Optional[str]=None, + allows_multiple_answers: Optional[bool]=None, correct_option_id: Optional[int]=None, - explanation: Optional[str]=None, - explanation_parse_mode: Optional[str]=None, - open_period: Optional[int]=None, - close_date: Optional[Union[int, datetime]]=None, + explanation: Optional[str]=None, + explanation_parse_mode: Optional[str]=None, + open_period: Optional[int]=None, + close_date: Optional[Union[int, datetime]]=None, is_closed: Optional[bool]=None, disable_notification: Optional[bool]=False, - reply_to_message_id: Optional[int]=None, - reply_markup: Optional[REPLY_MARKUP_TYPES]=None, - allow_sending_without_reply: Optional[bool]=None, + reply_to_message_id: Optional[int]=None, + reply_markup: Optional[REPLY_MARKUP_TYPES]=None, + allow_sending_without_reply: Optional[bool]=None, timeout: Optional[int]=None, explanation_entities: Optional[List[types.MessageEntity]]=None, protect_content: Optional[bool]=None, @@ -7484,7 +7482,7 @@ async def send_poll( :param message_thread_id: The identifier of a message thread, in which the poll will be sent :type message_thread_id: :obj:`int` - + :param reply_parameters: Reply parameters. :type reply_parameters: :class:`telebot.types.ReplyParameters` @@ -7509,13 +7507,13 @@ async def send_poll( """ disable_notification = self.disable_notification if (disable_notification is None) else disable_notification protect_content = self.protect_content if (protect_content is None) else protect_content - + explanation_parse_mode = self.parse_mode if (explanation_parse_mode is None) else explanation_parse_mode question_parse_mode = self.parse_mode if (question_parse_mode is None) else question_parse_mode if allow_sending_without_reply is not None: logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.") - + if reply_to_message_id: # show a deprecation warning logger.warning("The parameter 'reply_to_message_id' is deprecated. Use 'reply_parameters' instead.") @@ -7559,7 +7557,7 @@ async def send_poll( message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)) async def stop_poll( - self, chat_id: Union[int, str], message_id: int, + self, chat_id: Union[int, str], message_id: int, reply_markup: Optional[types.InlineKeyboardMarkup]=None, business_connection_id: Optional[str]=None) -> types.Poll: """ @@ -7585,8 +7583,8 @@ async def stop_poll( return types.Poll.de_json(await asyncio_helper.stop_poll(self.token, chat_id, message_id, reply_markup, business_connection_id)) async def answer_shipping_query( - self, shipping_query_id: str, ok: bool, - shipping_options: Optional[List[types.ShippingOption]]=None, + self, shipping_query_id: str, ok: bool, + shipping_options: Optional[List[types.ShippingOption]]=None, error_message: Optional[str]=None) -> bool: """ Asks for an answer to a shipping question. @@ -7612,7 +7610,7 @@ async def answer_shipping_query( return await asyncio_helper.answer_shipping_query(self.token, shipping_query_id, ok, shipping_options, error_message) async def answer_pre_checkout_query( - self, pre_checkout_query_id: str, ok: bool, + self, pre_checkout_query_id: str, ok: bool, error_message: Optional[str]=None) -> bool: """ Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the @@ -7624,7 +7622,7 @@ async def answer_pre_checkout_query( Telegram documentation: https://core.telegram.org/bots/api#answerprecheckoutquery - :param pre_checkout_query_id: Unique identifier for the query to be answered + :param pre_checkout_query_id: Unique identifier for the query to be answered :type pre_checkout_query_id: :obj:`int` :param ok: Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems. @@ -7647,7 +7645,7 @@ async def get_my_star_balance(self) -> types.StarAmount: On success, returns a StarAmount object. """ return types.StarAmount.de_json(await asyncio_helper.get_my_star_balance(self.token)) - + async def get_star_transactions(self, offset: Optional[int]=None, limit: Optional[int]=None) -> types.StarTransactions: """ Returns the bot's Telegram Star transactions in chronological order. @@ -7665,7 +7663,7 @@ async def get_star_transactions(self, offset: Optional[int]=None, limit: Optiona """ return types.StarTransactions.de_json(await asyncio_helper.get_star_transactions(self.token, offset, limit)) - + async def refund_star_payment(self, user_id: int, telegram_payment_charge_id: str) -> bool: """ Refunds a successful payment in Telegram Stars. Returns True on success. @@ -7704,10 +7702,10 @@ async def edit_user_star_subscription(self, user_id: int, telegram_payment_charg return await asyncio_helper.edit_user_star_subscription(self.token, user_id, telegram_payment_charge_id, is_canceled) async def edit_message_caption( - self, caption: str, chat_id: Optional[Union[int, str]]=None, - message_id: Optional[int]=None, + self, caption: str, chat_id: Optional[Union[int, str]]=None, + message_id: Optional[int]=None, inline_message_id: Optional[str]=None, - parse_mode: Optional[str]=None, + parse_mode: Optional[str]=None, caption_entities: Optional[List[types.MessageEntity]]=None, reply_markup: Optional[types.InlineKeyboardMarkup]=None, show_caption_above_media: Optional[bool]=None, @@ -7764,7 +7762,7 @@ async def edit_message_caption( async def reply_to(self, message: types.Message, text: str, **kwargs) -> types.Message: """ Convenience function for `send_message(message.chat.id, text, reply_parameters=(message.message_id...), **kwargs)` - + :param message: Instance of :class:`telebot.types.Message` :type message: :obj:`types.Message` @@ -7795,12 +7793,12 @@ async def reply_to(self, message: types.Message, text: str, **kwargs) -> types.M return await self.send_message(message.chat.id, text, reply_parameters=reply_parameters, **kwargs) async def answer_inline_query( - self, inline_query_id: str, - results: List[Any], - cache_time: Optional[int]=None, - is_personal: Optional[bool]=None, + self, inline_query_id: str, + results: List[Any], + cache_time: Optional[int]=None, + is_personal: Optional[bool]=None, next_offset: Optional[str]=None, - switch_pm_text: Optional[str]=None, + switch_pm_text: Optional[str]=None, switch_pm_parameter: Optional[str]=None, button: Optional[types.InlineQueryResultsButton]=None) -> bool: """ @@ -7853,7 +7851,7 @@ async def answer_inline_query( async def unpin_all_general_forum_topic_messages(self, chat_id: Union[int, str]) -> bool: """ - Use this method to clear the list of pinned messages in a General forum topic. + Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success. @@ -7870,8 +7868,8 @@ async def unpin_all_general_forum_topic_messages(self, chat_id: Union[int, str]) return await asyncio_helper.unpin_all_general_forum_topic_messages(self.token, chat_id) async def answer_callback_query( - self, callback_query_id: int, - text: Optional[str]=None, show_alert: Optional[bool]=None, + self, callback_query_id: int, + text: Optional[str]=None, show_alert: Optional[bool]=None, url: Optional[str]=None, cache_time: Optional[int]=None) -> bool: """ Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to @@ -7899,14 +7897,14 @@ async def answer_callback_query( :rtype: :obj:`bool` """ return await asyncio_helper.answer_callback_query(self.token, callback_query_id, text, show_alert, url, cache_time) - + # getUserChatBoosts # Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object. # Parameter Type Required Description # chat_id Integer or String Yes Unique identifier for the chat or username of the channel (in the format @channelusername) # user_id Integer Yes Unique identifier of the target user - + async def get_user_chat_boosts(self, chat_id: Union[int, str], user_id: int) -> types.UserChatBoosts: """ Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object. @@ -7925,11 +7923,11 @@ async def get_user_chat_boosts(self, chat_id: Union[int, str], user_id: int) -> result = await asyncio_helper.get_user_chat_boosts(self.token, chat_id, user_id) return types.UserChatBoosts.de_json(result) - + async def set_sticker_set_thumbnail(self, name: str, user_id: int, thumbnail: Union[Any, str]=None, format: Optional[str]=None) -> bool: """ - Use this method to set the thumbnail of a sticker set. + Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#setstickersetthumbnail @@ -7955,11 +7953,11 @@ async def set_sticker_set_thumbnail(self, name: str, user_id: int, thumbnail: Un logger.warning("Deprecation warning. 'format' parameter is required in set_sticker_set_thumbnail. Setting format to 'static'.") format = "static" return await asyncio_helper.set_sticker_set_thumbnail(self.token, name, user_id, thumbnail, format) - + @util.deprecated(deprecation_text="Use set_sticker_set_thumbnail instead") async def set_sticker_set_thumb(self, name: str, user_id: int, thumb: Union[Any, str]=None): """ - Use this method to set the thumbnail of a sticker set. + Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only. Returns True on success. Telegram documentation: https://core.telegram.org/bots/api#setstickersetthumb @@ -7982,7 +7980,7 @@ async def set_sticker_set_thumb(self, name: str, user_id: int, thumb: Union[Any, async def get_sticker_set(self, name: str) -> types.StickerSet: """ Use this method to get a sticker set. On success, a StickerSet object is returned. - + Telegram documentation: https://core.telegram.org/bots/api#getstickerset :param name: Sticker set name @@ -7993,7 +7991,7 @@ async def get_sticker_set(self, name: str) -> types.StickerSet: """ result = await asyncio_helper.get_sticker_set(self.token, name) return types.StickerSet.de_json(result) - + async def set_sticker_keywords(self, sticker: str, keywords: List[str]=None) -> bool: """ Use this method to change search keywords assigned to a regular or custom emoji sticker. @@ -8010,7 +8008,7 @@ async def set_sticker_keywords(self, sticker: str, keywords: List[str]=None) -> :rtype: :obj:`bool` """ return await asyncio_helper.set_sticker_keywords(self.token, sticker, keywords) - + async def set_sticker_mask_position(self, sticker: str, mask_position: types.MaskPosition=None) -> bool: """ Use this method to change the mask position of a mask sticker. @@ -8046,7 +8044,7 @@ async def upload_sticker_file(self, user_id: int, png_sticker: Union[Any, str]=N """ Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success. - + Telegram documentation: https://core.telegram.org/bots/api#uploadstickerfile :param user_id: User identifier of sticker set owner @@ -8060,7 +8058,7 @@ async def upload_sticker_file(self, user_id: int, png_sticker: Union[Any, str]=N See https://core.telegram.org/stickers for technical requirements. More information on Sending Files » :type sticker: :class:`telebot.types.InputFile` - :param sticker_format: One of "static", "animated", "video". + :param sticker_format: One of "static", "animated", "video". :type sticker_format: :obj:`str` :return: On success, the sent file is returned. @@ -8070,10 +8068,10 @@ async def upload_sticker_file(self, user_id: int, png_sticker: Union[Any, str]=N logger.warning('The parameter "png_sticker" is deprecated. Use "sticker" instead.') sticker = png_sticker sticker_format = "static" - + result = await asyncio_helper.upload_sticker_file(self.token, user_id, sticker, sticker_format) return types.File.de_json(result) - + async def set_custom_emoji_sticker_set_thumbnail(self, name: str, custom_emoji_id: Optional[str]=None) -> bool: """ Use this method to set the thumbnail of a custom emoji sticker set. @@ -8089,7 +8087,7 @@ async def set_custom_emoji_sticker_set_thumbnail(self, name: str, custom_emoji_i :rtype: :obj:`bool` """ return await asyncio_helper.set_custom_emoji_sticker_set_thumbnail(self.token, name, custom_emoji_id) - + async def set_sticker_set_title(self, name: str, title: str) -> bool: """ Use this method to set the title of a created sticker set. @@ -8155,13 +8153,13 @@ async def send_gift(self, user_id: Optional[Union[str, int]] = None, gift_id: st """ if user_id is None and chat_id is None: raise ValueError("Either user_id or chat_id must be specified.") - + if gift_id is None: raise ValueError("gift_id must be specified.") - + return await asyncio_helper.send_gift(self.token, gift_id, text, text_parse_mode, text_entities, pay_for_upgrade=pay_for_upgrade, chat_id=chat_id, user_id=user_id) - + async def verify_user(self, user_id: int, custom_description: Optional[str]=None) -> bool: """ Verifies a user on behalf of the organization which is represented by the bot. Returns True on success. @@ -8225,7 +8223,7 @@ async def remove_chat_verification(self, chat_id: int) -> bool: :rtype: :obj:`bool` """ return await asyncio_helper.remove_chat_verification(self.token, chat_id) - + async def read_business_message(self, business_connection_id: str, chat_id: Union[int, str], message_id: int) -> bool: """ Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns True on success. @@ -8317,7 +8315,7 @@ async def set_business_account_bio(self, business_connection_id: str, bio: Optio :rtype: :obj:`bool` """ return await asyncio_helper.set_business_account_bio(self.token, business_connection_id, bio=bio) - + async def set_business_account_gift_settings( self, business_connection_id: str, show_gift_button: bool, accepted_gift_types: types.AcceptedGiftTypes) -> bool: """ @@ -8338,11 +8336,11 @@ async def set_business_account_gift_settings( :rtype: :obj:`bool` """ return await asyncio_helper.set_business_account_gift_settings(self.token, business_connection_id, show_gift_button, accepted_gift_types) - + async def get_business_account_star_balance(self, business_connection_id: str) -> types.StarAmount: """ Returns the amount of Telegram Stars owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns StarAmount on success. - + Telegram documentation: https://core.telegram.org/bots/api#getbusinessaccountstarbalance :param business_connection_id: Unique identifier of the business connection @@ -8354,7 +8352,7 @@ async def get_business_account_star_balance(self, business_connection_id: str) - return types.StarAmount.de_json( await asyncio_helper.get_business_account_star_balance(self.token, business_connection_id) ) - + async def transfer_business_account_stars(self, business_connection_id: str, star_count: int) -> bool: """ Transfers Telegram Stars from the business account balance to the bot's balance. Requires the can_transfer_stars business bot right. Returns True on success. @@ -8371,7 +8369,7 @@ async def transfer_business_account_stars(self, business_connection_id: str, sta :rtype: :obj:`bool` """ return await asyncio_helper.transfer_business_account_stars(self.token, business_connection_id, star_count) - + async def get_business_account_gifts( self, business_connection_id: str, exclude_unsaved: Optional[bool]=None, @@ -8384,7 +8382,7 @@ async def get_business_account_gifts( limit: Optional[int]=None) -> types.OwnedGifts: """ Returns the gifts received and owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns OwnedGifts on success. - + Telegram documentation: https://core.telegram.org/bots/api#getbusinessaccountgifts :param business_connection_id: Unique identifier of the business connection @@ -8430,7 +8428,7 @@ async def get_business_account_gifts( limit=limit ) ) - + async def convert_gift_to_stars(self, business_connection_id: str, owned_gift_id: str) -> bool: """ Converts a given regular gift to Telegram Stars. Requires the can_convert_gifts_to_stars business bot right. Returns True on success. @@ -8447,7 +8445,7 @@ async def convert_gift_to_stars(self, business_connection_id: str, owned_gift_id :rtype: :obj:`bool` """ return await asyncio_helper.convert_gift_to_stars(self.token, business_connection_id, owned_gift_id) - + async def upgrade_gift( self, business_connection_id: str, owned_gift_id: str, keep_original_details: Optional[bool]=None, @@ -8511,7 +8509,7 @@ async def transfer_gift( new_owner_chat_id, star_count=star_count ) - + async def post_story( self, business_connection_id: str, content: types.InputStoryContent, active_period: int, caption: Optional[str]=None, @@ -8618,7 +8616,7 @@ async def edit_story( async def delete_story(self, business_connection_id: str, story_id: int) -> bool: """ Deletes a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns True on success. - + Telegram documentation: https://core.telegram.org/bots/api#deletestory :param business_connection_id: Unique identifier of the business connection @@ -8631,7 +8629,7 @@ async def delete_story(self, business_connection_id: str, story_id: int) -> bool :rtype: :obj:`bool` """ return await asyncio_helper.delete_story(self.token, business_connection_id, story_id) - + async def set_business_account_profile_photo( self, business_connection_id: str, photo: types.InputProfilePhoto, is_public: Optional[bool]=None) -> bool: @@ -8673,7 +8671,7 @@ async def remove_business_account_profile_photo( :rtype: :obj:`bool` """ return await asyncio_helper.remove_business_account_profile_photo(self.token, business_connection_id, is_public=is_public) - + async def gift_premium_subscription( self, user_id: int, month_count: int, star_count: int, text: Optional[str]=None, text_parse_mode: Optional[str]=None, @@ -8722,7 +8720,7 @@ async def get_available_gifts(self) -> types.Gifts: return types.Gifts.de_json(await asyncio_helper.get_available_gifts(self.token)) - + async def replace_sticker_in_set(self, user_id: int, name: str, old_sticker: str, sticker: types.InputSticker) -> bool: """ Use this method to replace an existing sticker in a sticker set with a new one. The method is equivalent to calling deleteStickerFromSet, then addStickerToSet, @@ -8767,10 +8765,10 @@ async def set_sticker_emoji_list(self, name: str, emoji_list: List[str]) -> bool async def create_new_sticker_set( - self, user_id: int, name: str, title: str, + self, user_id: int, name: str, title: str, emojis: Optional[List[str]]=None, - png_sticker: Union[Any, str]=None, - tgs_sticker: Union[Any, str]=None, + png_sticker: Union[Any, str]=None, + tgs_sticker: Union[Any, str]=None, webm_sticker: Union[Any, str]=None, contains_masks: Optional[bool]=None, sticker_type: Optional[str]=None, @@ -8779,7 +8777,7 @@ async def create_new_sticker_set( stickers: List[types.InputSticker]=None, sticker_format: Optional[str]=None) -> bool: """ - Use this method to create new sticker set owned by a user. + Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. Returns True on success. @@ -8843,7 +8841,7 @@ async def create_new_sticker_set( sticker_format = 'video' elif png_sticker: sticker_format = 'static' - + if contains_masks is not None: logger.warning('The parameter "contains_masks" is deprecated, use "sticker_type" instead') if sticker_type is None: @@ -8854,7 +8852,7 @@ async def create_new_sticker_set( if stickers is None: raise ValueError('You must pass at least one sticker') stickers = [types.InputSticker(sticker=stickers, emoji_list=emojis, mask_position=mask_position)] - + if sticker_format: logger.warning('The parameter "sticker_format" is deprecated since Bot API 7.2. Stickers can now be mixed') @@ -8864,8 +8862,8 @@ async def create_new_sticker_set( async def add_sticker_to_set( self, user_id: int, name: str, emojis: Union[List[str], str]=None, - png_sticker: Optional[Union[Any, str]]=None, - tgs_sticker: Optional[Union[Any, str]]=None, + png_sticker: Optional[Union[Any, str]]=None, + tgs_sticker: Optional[Union[Any, str]]=None, webm_sticker: Optional[Union[Any, str]]=None, mask_position: Optional[types.MaskPosition]=None, sticker: Optional[types.InputSticker]=None) -> bool: @@ -8929,7 +8927,7 @@ async def add_sticker_to_set( async def set_sticker_position_in_set(self, sticker: str, position: int) -> bool: """ Use this method to move a sticker in a set created by the bot to a specific position . Returns True on success. - + Telegram documentation: https://core.telegram.org/bots/api#setstickerpositioninset :param sticker: File identifier of the sticker @@ -8946,7 +8944,7 @@ async def set_sticker_position_in_set(self, sticker: str, position: int) -> bool async def delete_sticker_from_set(self, sticker: str) -> bool: """ Use this method to delete a sticker from a set created by the bot. Returns True on success. - + Telegram documentation: https://core.telegram.org/bots/api#deletestickerfromset :param sticker: File identifier of the sticker @@ -9097,9 +9095,9 @@ async def edit_general_forum_topic(self, chat_id: Union[int, str], name: str) -> Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success. - + Telegram documentation: https://core.telegram.org/bots/api#editgeneralforumtopic - + :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` @@ -9190,7 +9188,7 @@ async def set_state(self, user_id: int, state: Union[int, str, State], chat_id: Added additional parameters to support topics, business connections, and message threads. - .. seealso:: + .. seealso:: For more details, visit the `custom_states.py example `_. @@ -9223,7 +9221,7 @@ async def set_state(self, user_id: int, state: Union[int, str, State], chat_id: bot_id=bot_id, business_connection_id=business_connection_id, message_thread_id=message_thread_id) - async def reset_data(self, user_id: int, chat_id: Optional[int]=None, + async def reset_data(self, user_id: int, chat_id: Optional[int]=None, business_connection_id: Optional[str]=None, message_thread_id: Optional[int]=None, bot_id: Optional[int]=None) -> bool: """ @@ -9262,7 +9260,7 @@ async def delete_state(self, user_id: int, chat_id: Optional[int]=None, business :param user_id: User's identifier :type user_id: :obj:`int` - + :param chat_id: Chat's identifier :type chat_id: :obj:`int` @@ -9316,7 +9314,7 @@ def retrieve_data(self, user_id: int, chat_id: Optional[int]=None, business_conn bot_id=bot_id, business_connection_id=business_connection_id, message_thread_id=message_thread_id) - async def get_state(self, user_id: int, chat_id: Optional[int]=None, + async def get_state(self, user_id: int, chat_id: Optional[int]=None, business_connection_id: Optional[str]=None, message_thread_id: Optional[int]=None, bot_id: Optional[int]=None) -> str: """ @@ -9324,7 +9322,7 @@ async def get_state(self, user_id: int, chat_id: Optional[int]=None, Not recommended to use this method. But it is ok for debugging. .. warning:: - + Even if you are using :class:`telebot.types.State`, this method will return a string. When comparing(not recommended), you should compare this string with :class:`telebot.types.State`.name @@ -9354,9 +9352,9 @@ async def get_state(self, user_id: int, chat_id: Optional[int]=None, bot_id=bot_id, business_connection_id=business_connection_id, message_thread_id=message_thread_id) - async def add_data(self, user_id: int, chat_id: Optional[int]=None, + async def add_data(self, user_id: int, chat_id: Optional[int]=None, business_connection_id: Optional[str]=None, - message_thread_id: Optional[int]=None, + message_thread_id: Optional[int]=None, bot_id: Optional[int]=None, **kwargs) -> None: """ diff --git a/telebot/types.py b/telebot/types.py index 3f01fec54..b0dffd358 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -95,7 +95,7 @@ def check_json(json_type, dict_copy = True): 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! :return: Dictionary parsed from json or original dict @@ -121,9 +121,9 @@ class Update(JsonDeserializable): Telegram Documentation: https://core.telegram.org/bots/api#update - :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 + :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` @@ -150,8 +150,8 @@ class Update(JsonDeserializable): :param inline_query: Optional. New incoming inline query :type inline_query: :class:`telebot.types.InlineQuery` - :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 + :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` @@ -161,30 +161,30 @@ class Update(JsonDeserializable): :param shipping_query: Optional. New incoming shipping query. Only for invoices with flexible price :type shipping_query: :class:`telebot.types.ShippingQuery` - :param pre_checkout_query: Optional. New incoming pre-checkout query. Contains full information about + :param pre_checkout_query: Optional. New incoming pre-checkout query. Contains full information about checkout :type pre_checkout_query: :class:`telebot.types.PreCheckoutQuery` :purchased_paid_media: Optional. A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat :type purchased_paid_media: :class:`telebot.types.PaidMediaPurchased` - :param poll: Optional. New poll state. Bots receive only updates about stopped polls and polls, which are sent by the + :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` - :param poll_answer: Optional. A user changed their answer in a non-anonymous poll. Bots receive new votes only in + :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` - :param my_chat_member: Optional. The bot's chat member status was updated in a chat. For private chats, this update + :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` - :param chat_member: Optional. A chat member's status was updated in a chat. The bot must be an administrator in the + :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` - :param chat_join_request: Optional. A request to join the chat has been sent. The bot must have the + :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` @@ -297,7 +297,7 @@ class ChatMemberUpdated(JsonDeserializable): :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 + :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` @@ -320,7 +320,7 @@ def de_json(cls, json_string): obj['new_chat_member'] = ChatMember.de_json(obj['new_chat_member']) obj['invite_link'] = ChatInviteLink.de_json(obj.get('invite_link')) return cls(**obj) - + def __init__(self, chat, from_user, date, old_chat_member, new_chat_member, invite_link=None, via_join_request=None, via_chat_folder_invite_link=None, **kwargs): @@ -352,7 +352,7 @@ def difference(self) -> Dict[str, List]: if new[key] != old[key]: dif[key] = [old[key], new[key]] return dif - + class ChatJoinRequest(JsonDeserializable): """ @@ -393,7 +393,7 @@ def de_json(cls, json_string): obj['from_user'] = User.de_json(obj['from']) obj['invite_link'] = ChatInviteLink.de_json(obj.get('invite_link')) return cls(**obj) - + def __init__(self, chat, from_user, user_chat_id, date, bio=None, invite_link=None, **kwargs): self.chat: Chat = chat self.from_user: User = from_user @@ -421,23 +421,23 @@ class WebhookInfo(JsonDeserializable): :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 + :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 + :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 + :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 + :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 + :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` @@ -450,7 +450,7 @@ def de_json(cls, json_string): obj = cls.check_json(json_string, dict_copy=False) return cls(**obj) - def __init__(self, url, has_custom_certificate, pending_update_count, ip_address=None, + def __init__(self, url, has_custom_certificate, pending_update_count, ip_address=None, last_error_date=None, last_error_message=None, last_synchronization_error_date=None, max_connections=None, allowed_updates=None, **kwargs): self.url: str = url @@ -470,8 +470,8 @@ class User(JsonDeserializable, Dictionaryable, JsonSerializable): 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 + :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` @@ -499,7 +499,7 @@ class User(JsonDeserializable, Dictionaryable, JsonSerializable): :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 + :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` @@ -523,8 +523,8 @@ def de_json(cls, json_string): # noinspection PyShadowingBuiltins def __init__(self, id, is_bot, first_name, last_name=None, username=None, language_code=None, - can_join_groups=None, can_read_all_group_messages=None, supports_inline_queries=None, - is_premium=None, added_to_attachment_menu=None, can_connect_to_business=None, + can_join_groups=None, can_read_all_group_messages=None, supports_inline_queries=None, + is_premium=None, added_to_attachment_menu=None, can_connect_to_business=None, has_main_web_app=None, **kwargs): self.id: int = id self.is_bot: bool = is_bot @@ -592,8 +592,8 @@ class ChatFullInfo(JsonDeserializable): 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 + :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` @@ -735,9 +735,9 @@ class ChatFullInfo(JsonDeserializable): Custom emoji from this set can be used by all users and bots in the group. Returned only in getChat. :param custom_emoji_sticker_set_name: :obj:`str` - :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 + :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` @@ -779,17 +779,17 @@ def de_json(cls, json_string): def __init__(self, id, type, title=None, username=None, first_name=None, last_name=None, photo=None, bio=None, has_private_forwards=None, - description=None, invite_link=None, pinned_message=None, + description=None, invite_link=None, pinned_message=None, permissions=None, slow_mode_delay=None, message_auto_delete_time=None, has_protected_content=None, sticker_set_name=None, - can_set_sticker_set=None, linked_chat_id=None, location=None, - join_to_send_messages=None, join_by_request=None, has_restricted_voice_and_video_messages=None, + can_set_sticker_set=None, linked_chat_id=None, location=None, + join_to_send_messages=None, join_by_request=None, has_restricted_voice_and_video_messages=None, is_forum=None, max_reaction_count=None, active_usernames=None, emoji_status_custom_emoji_id=None, - has_hidden_members=None, has_aggressive_anti_spam_enabled=None, emoji_status_expiration_date=None, + has_hidden_members=None, has_aggressive_anti_spam_enabled=None, emoji_status_expiration_date=None, available_reactions=None, accent_color_id=None, background_custom_emoji_id=None, profile_accent_color_id=None, - profile_background_custom_emoji_id=None, has_visible_history=None, + profile_background_custom_emoji_id=None, has_visible_history=None, unrestrict_boost_count=None, custom_emoji_sticker_set_name=None, business_intro=None, business_location=None, - business_opening_hours=None, personal_chat=None, birthdate=None, + business_opening_hours=None, personal_chat=None, birthdate=None, can_send_paid_media=None, accepted_gift_types=None, is_direct_messages=None, parent_chat=None, **kwargs): self.id: int = id @@ -895,7 +895,7 @@ class WebAppData(JsonDeserializable, Dictionaryable): :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 + :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` @@ -1547,7 +1547,7 @@ def de_json(cls, json_string): if 'suggested_post_refunded' in obj: opts['suggested_post_refunded'] = SuggestedPostRefunded.de_json(obj['suggested_post_refunded']) content_type = 'suggested_post_refunded' - + return cls(message_id, from_user, date, chat, content_type, opts, json_string) @classmethod @@ -1910,7 +1910,7 @@ class PhotoSize(JsonDeserializable): :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 + :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` @@ -1949,7 +1949,7 @@ class Audio(JsonDeserializable): :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 + :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` @@ -1968,8 +1968,8 @@ class Audio(JsonDeserializable): :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 + :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` @@ -1985,11 +1985,11 @@ def de_json(cls, json_string): obj = cls.check_json(json_string) if 'thumbnail' in obj and 'file_id' in obj['thumbnail']: obj['thumbnail'] = PhotoSize.de_json(obj['thumbnail']) - else: + else: obj['thumbnail'] = None return cls(**obj) - def __init__(self, file_id, file_unique_id, duration, performer=None, title=None, file_name=None, mime_type=None, + def __init__(self, file_id, file_unique_id, duration, performer=None, title=None, file_name=None, mime_type=None, file_size=None, thumbnail=None, **kwargs): self.file_id: str = file_id self.file_unique_id: str = file_unique_id @@ -2016,7 +2016,7 @@ class Voice(JsonDeserializable): :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 + :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` @@ -2026,8 +2026,8 @@ class Voice(JsonDeserializable): :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 + :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` @@ -2057,7 +2057,7 @@ class Document(JsonDeserializable): :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 + :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` @@ -2070,8 +2070,8 @@ class Document(JsonDeserializable): :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 + :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` @@ -2084,7 +2084,7 @@ def de_json(cls, json_string): obj = cls.check_json(json_string) if 'thumbnail' in obj and 'file_id' in obj['thumbnail']: obj['thumbnail'] = PhotoSize.de_json(obj['thumbnail']) - else: + else: obj['thumbnail'] = None return cls(**obj) @@ -2111,7 +2111,7 @@ class Video(JsonDeserializable): :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 + :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` @@ -2139,8 +2139,8 @@ class Video(JsonDeserializable): :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 + :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` @@ -2186,7 +2186,7 @@ class VideoNote(JsonDeserializable): :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 + :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` @@ -2242,8 +2242,8 @@ class Contact(JsonDeserializable): :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 + :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` @@ -2282,14 +2282,14 @@ class Location(JsonDeserializable, JsonSerializable, Dictionaryable): :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; + :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 + :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` @@ -2310,10 +2310,10 @@ def __init__(self, longitude, latitude, horizontal_accuracy=None, self.live_period: Optional[int] = live_period self.heading: Optional[int] = heading self.proximity_alert_radius: Optional[int] = proximity_alert_radius - + def to_json(self): return json.dumps(self.to_dict()) - + def to_dict(self): return { "longitude": self.longitude, @@ -2343,7 +2343,7 @@ class Venue(JsonDeserializable): :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”, + :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` @@ -2363,7 +2363,7 @@ def de_json(cls, json_string): obj['location'] = Location.de_json(obj['location']) return cls(**obj) - def __init__(self, location, title, address, foursquare_id=None, foursquare_type=None, + def __init__(self, location, title, address, foursquare_id=None, foursquare_type=None, google_place_id=None, google_place_type=None, **kwargs): self.location: Location = location self.title: str = title @@ -2412,16 +2412,16 @@ class File(JsonDeserializable): :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 + :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 + :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 + :param file_path: Optional. File path. Use https://api.telegram.org/file/bot/ to get the file. :type file_path: :obj:`str` @@ -2448,11 +2448,11 @@ class ForceReply(JsonSerializable): 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 + :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; + :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` @@ -2484,16 +2484,16 @@ class ReplyKeyboardRemove(JsonSerializable): 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 + :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 + :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` @@ -2555,21 +2555,21 @@ class ReplyKeyboardMarkup(JsonSerializable): Telegram Documentation: https://core.telegram.org/bots/api#replykeyboardmarkup - :param keyboard: :obj:`list` of button rows, each represented by an :obj:`list` of + :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 + :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 + :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 + :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` @@ -2583,7 +2583,7 @@ class ReplyKeyboardMarkup(JsonSerializable): :param is_persistent: 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. @@ -2592,7 +2592,7 @@ class ReplyKeyboardMarkup(JsonSerializable): """ max_row_keys = 12 - def __init__(self, resize_keyboard: Optional[bool]=None, one_time_keyboard: Optional[bool]=None, + def __init__(self, resize_keyboard: Optional[bool]=None, one_time_keyboard: Optional[bool]=None, selective: Optional[bool]=None, row_width: int=3, input_field_placeholder: Optional[str]=None, is_persistent: Optional[bool]=None): if row_width > self.max_row_keys: @@ -2634,7 +2634,7 @@ def add(self, *args, row_width=None) -> 'ReplyKeyboardMarkup': if not DISABLE_KEYLEN_ERROR: logger.error('Telegram does not support reply keyboard row width over %d.' % self.max_row_keys) row_width = self.max_row_keys - + for row in service_utils.chunks(args, row_width): button_array = [] for button in row: @@ -2696,8 +2696,8 @@ def __init__(self, type=None): def to_dict(self): return {'type': self.type} - - + + class KeyboardButtonRequestUsers(Dictionaryable): """ This object defines the criteria used to request a suitable user. @@ -2867,23 +2867,23 @@ class KeyboardButton(Dictionaryable, JsonSerializable): 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 + :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 + :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. + :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 + :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 + :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` @@ -2901,7 +2901,7 @@ class KeyboardButton(Dictionaryable, JsonSerializable): :return: Instance of the class :rtype: :class:`telebot.types.KeyboardButton` """ - def __init__(self, text: str, request_contact: Optional[bool]=None, + def __init__(self, text: str, request_contact: Optional[bool]=None, request_location: Optional[bool]=None, request_poll: Optional[KeyboardButtonPollType]=None, web_app: Optional[WebAppInfo]=None, request_user: Optional[KeyboardButtonRequestUser]=None, request_chat: Optional[KeyboardButtonRequestChat]=None, request_users: Optional[KeyboardButtonRequestUsers]=None): @@ -2961,7 +2961,7 @@ class InlineKeyboardMarkup(Dictionaryable, JsonSerializable, JsonDeserializable) Telegram Documentation: https://core.telegram.org/bots/api#inlinekeyboardmarkup - :param keyboard: :obj:`list` of button rows, each represented by an :obj:`list` of + :param keyboard: :obj:`list` of button rows, each represented by an :obj:`list` of :class:`telebot.types.InlineKeyboardButton` objects :type keyboard: :obj:`list` of :obj:`list` of :class:`telebot.types.InlineKeyboardButton` @@ -2972,7 +2972,7 @@ class InlineKeyboardMarkup(Dictionaryable, JsonSerializable, JsonDeserializable) :rtype: :class:`telebot.types.InlineKeyboardMarkup` """ max_row_keys = 8 - + @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -2985,7 +2985,7 @@ def __init__(self, keyboard=None, row_width=3): # 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) row_width = self.max_row_keys - + self.row_width: int = row_width self.keyboard: List[List[InlineKeyboardButton]] = keyboard or [] @@ -2999,7 +2999,7 @@ def add(self, *args, row_width=None) -> 'InlineKeyboardMarkup': When row_width is set to 2, the result: {keyboard: [["A", "B"], ["C"]]} 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` @@ -3011,18 +3011,18 @@ def add(self, *args, row_width=None) -> 'InlineKeyboardMarkup': """ if row_width is None: row_width = self.row_width - + 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) row_width = self.max_row_keys - + for row in service_utils.chunks(args, row_width): button_array = [button for button in row] self.keyboard.append(button_array) - + return self - + def row(self, *args) -> 'InlineKeyboardMarkup': """ Adds a list of InlineKeyboardButton to the keyboard. @@ -3031,14 +3031,14 @@ def row(self, *args) -> 'InlineKeyboardMarkup': InlineKeyboardMarkup.row("A").row("B", "C").to_json() outputs: '{keyboard: [["A"], ["B", "C"]]}' 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): @@ -3059,32 +3059,32 @@ class InlineKeyboardButton(Dictionaryable, JsonSerializable, JsonDeserializable) :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 + :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 + :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 + :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 + :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 + :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` @@ -3092,11 +3092,11 @@ class InlineKeyboardButton(Dictionaryable, JsonSerializable, JsonDeserializable) specified type, open that chat and insert the bot's username and the specified inline query in the input field :type switch_inline_query_chosen_chat: :class:`telebot.types.SwitchInlineQueryChosenChat` - :param callback_game: Optional. Description of the game that will be launched when the user presses the + :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 + :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` @@ -3118,7 +3118,7 @@ def de_json(cls, json_string): obj['switch_inline_query_chosen_chat'] = SwitchInlineQueryChosenChat.de_json(obj.get('switch_inline_query_chosen_chat')) if 'copy_text' in obj: obj['copy_text'] = CopyTextButton.de_json(obj.get('copy_text')) - + return cls(**obj) def __init__(self, text: str, url: Optional[str]=None, callback_data: Optional[str]=None, web_app: Optional[WebAppInfo]=None, @@ -3171,22 +3171,22 @@ class LoginUrl(Dictionaryable, JsonSerializable, JsonDeserializable): 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 + :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 + :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 + :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` @@ -3236,15 +3236,15 @@ class CallbackQuery(JsonDeserializable): :param message: Optional. Message sent by the bot with the callback button that originated the query :type message: :class:`telebot.types.Message` or :class:`telebot.types.InaccessibleMessage` - :param inline_message_id: Optional. Identifier of the message sent via the bot in inline mode, that originated the + :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 + :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 + :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` @@ -3283,27 +3283,27 @@ def __init__( self.data: Optional[str] = data self.game_short_name: Optional[str] = game_short_name self.json = json_string - - + + 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 + :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 + :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 + :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 + :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` @@ -3327,7 +3327,7 @@ class ChatMember(JsonDeserializable, ABC): """ 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` @@ -3412,8 +3412,8 @@ class ChatMemberAdministrator(ChatMember): :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. + :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` @@ -3426,8 +3426,8 @@ class ChatMemberAdministrator(ChatMember): :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 + :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` @@ -3682,15 +3682,15 @@ class ChatPermissions(JsonDeserializable, JsonSerializable, Dictionaryable): :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 + :param can_send_other_messages: Optional. 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: Optional. True, if the user is allowed to add web page previews to their + :param can_add_web_page_previews: Optional. True, if the user is allowed to add web page previews to their 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. + :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` @@ -3702,7 +3702,7 @@ class ChatPermissions(JsonDeserializable, JsonSerializable, Dictionaryable): :param can_manage_topics: Optional. True, if the user is allowed to create forum topics. If omitted defaults to the value of can_pin_messages - :type can_manage_topics: :obj:`bool` + :type can_manage_topics: :obj:`bool` :param can_send_media_messages: deprecated. :type can_send_media_messages: :obj:`bool` @@ -3721,7 +3721,7 @@ def __init__(self, can_send_messages=None, can_send_media_messages=None,can_send can_send_videos=None, can_send_video_notes=None, can_send_voice_notes=None, can_send_polls=None, can_send_other_messages=None, can_add_web_page_previews=None, can_change_info=None, - can_invite_users=None, can_pin_messages=None, + can_invite_users=None, can_pin_messages=None, can_manage_topics=None, **kwargs): self.can_send_messages: Optional[bool] = can_send_messages self.can_send_polls: Optional[bool] = can_send_polls @@ -3784,7 +3784,7 @@ def to_dict(self): json_dict['can_pin_messages'] = self.can_pin_messages if self.can_manage_topics is not None: json_dict['can_manage_topics'] = self.can_manage_topics - + return json_dict @@ -3794,7 +3794,7 @@ class BotCommand(JsonSerializable, JsonDeserializable, Dictionaryable): 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 + :param command: Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and underscores. :type command: :obj:`str` @@ -3971,7 +3971,7 @@ class BotCommandScopeChat(BotCommandScope): :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 + :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` @@ -3992,7 +3992,7 @@ class BotCommandScopeChatAdministrators(BotCommandScope): :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 + :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` @@ -4013,7 +4013,7 @@ class BotCommandScopeChatMember(BotCommandScope): :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 + :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` @@ -4048,9 +4048,9 @@ class InlineQuery(JsonDeserializable): :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 + :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` @@ -4087,11 +4087,11 @@ class InputTextMessageContent(Dictionaryable): :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 + :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 + :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` @@ -4198,7 +4198,7 @@ class InputVenueMessageContent(Dictionaryable): :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, + :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` @@ -4211,7 +4211,7 @@ class InputVenueMessageContent(Dictionaryable): :return: Instance of the class :rtype: :class:`telebot.types.InputVenueMessageContent` """ - def __init__(self, latitude, longitude, title, address, foursquare_id=None, foursquare_type=None, + 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 self.longitude: float = longitude @@ -4288,7 +4288,7 @@ class InputInvoiceMessageContent(Dictionaryable): :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 + :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` @@ -4299,26 +4299,26 @@ class InputInvoiceMessageContent(Dictionaryable): :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 + :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 + :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 + :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 + :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 + :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` @@ -4340,7 +4340,7 @@ class InputInvoiceMessageContent(Dictionaryable): :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 + :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` @@ -4356,7 +4356,7 @@ class InputInvoiceMessageContent(Dictionaryable): :return: Instance of the class :rtype: :class:`telebot.types.InputInvoiceMessageContent` """ - + def __init__(self, title: str, description: str, payload: str, provider_token: Optional[str], currency: str, prices: List[LabeledPrice], max_tip_amount: Optional[int] = None, suggested_tip_amounts: Optional[List[int]] = None, provider_data: Optional[str] = None, photo_url: Optional[str] = None, photo_size: Optional[int] = None, photo_width: Optional[int] = None, photo_height: Optional[int] = None, @@ -4382,10 +4382,10 @@ def __init__(self, title: str, description: str, payload: str, provider_token: O self.send_phone_number_to_provider: Optional[bool] = send_phone_number_to_provider self.send_email_to_provider: Optional[bool] = send_email_to_provider self.is_flexible: Optional[bool] = is_flexible - + def to_dict(self): json_dict = { - 'title': self.title, + 'title': self.title, 'description': self.description, 'payload': self.payload, 'provider_token': self.provider_token, @@ -4393,33 +4393,33 @@ def to_dict(self): 'prices': [LabeledPrice.to_dict(lp) for lp in self.prices] } if self.max_tip_amount: - json_dict['max_tip_amount'] = self.max_tip_amount + json_dict['max_tip_amount'] = self.max_tip_amount if self.suggested_tip_amounts: - json_dict['suggested_tip_amounts'] = self.suggested_tip_amounts + json_dict['suggested_tip_amounts'] = self.suggested_tip_amounts if self.provider_data: - json_dict['provider_data'] = self.provider_data + json_dict['provider_data'] = self.provider_data if self.photo_url: - json_dict['photo_url'] = self.photo_url + json_dict['photo_url'] = self.photo_url if self.photo_size: - json_dict['photo_size'] = self.photo_size + json_dict['photo_size'] = self.photo_size if self.photo_width: - json_dict['photo_width'] = self.photo_width + json_dict['photo_width'] = self.photo_width if self.photo_height: - json_dict['photo_height'] = self.photo_height + json_dict['photo_height'] = self.photo_height if self.need_name is not None: - json_dict['need_name'] = self.need_name + json_dict['need_name'] = self.need_name if self.need_phone_number is not None: - json_dict['need_phone_number'] = self.need_phone_number + json_dict['need_phone_number'] = self.need_phone_number if self.need_email is not None: - json_dict['need_email'] = self.need_email + json_dict['need_email'] = self.need_email if self.need_shipping_address is not None: - json_dict['need_shipping_address'] = self.need_shipping_address + json_dict['need_shipping_address'] = self.need_shipping_address if self.send_phone_number_to_provider is not None: - json_dict['send_phone_number_to_provider'] = self.send_phone_number_to_provider + json_dict['send_phone_number_to_provider'] = self.send_phone_number_to_provider if self.send_email_to_provider is not None: - json_dict['send_email_to_provider'] = self.send_email_to_provider + json_dict['send_email_to_provider'] = self.send_email_to_provider if self.is_flexible is not None: - json_dict['is_flexible'] = self.is_flexible + json_dict['is_flexible'] = self.is_flexible return json_dict InputMessageContent = Union[InputTextMessageContent, InputLocationMessageContent, InputVenueMessageContent, InputContactMessageContent, InputInvoiceMessageContent] @@ -4439,7 +4439,7 @@ class ChosenInlineResult(JsonDeserializable): :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 + :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` @@ -4494,7 +4494,7 @@ class InlineQueryResultBase(ABC, Dictionaryable, JsonSerializable): Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresult """ - + def __init__(self, type: str, id: str, title: Optional[str] = None, caption: Optional[str] = None, input_message_content: Optional[InputMessageContent] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, caption_entities: Optional[List[MessageEntity]] = None, parse_mode: Optional[str] = None): self.type: str = type @@ -4535,7 +4535,7 @@ class SentWebAppMessage(JsonDeserializable, Dictionaryable): 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 + :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` @@ -4601,11 +4601,11 @@ class InlineQueryResultArticle(InlineQueryResultBase): :return: Instance of the class :rtype: :class:`telebot.types.InlineQueryResultArticle` """ - + def __init__(self, id: str, title: str, input_message_content: InputMessageContent, reply_markup: Optional[InlineKeyboardMarkup] = None, url: Optional[str] = None, hide_url: Optional[bool] = None, description: Optional[str] = None, thumbnail_url: Optional[str] = None, thumbnail_width: Optional[int] = None, thumbnail_height: Optional[int] = None): - + super().__init__('article', id, title = title, input_message_content = input_message_content, reply_markup = reply_markup) self.url: Optional[str] = url self.hide_url: Optional[bool] = hide_url @@ -4685,11 +4685,11 @@ class InlineQueryResultPhoto(InlineQueryResultBase): :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 + :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 + :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` @@ -4768,7 +4768,7 @@ class InlineQueryResultGif(InlineQueryResultBase): :param thumbnail_url: URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result :type thumbnail_url: :obj:`str` - :param thumbnail_mime_type: Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or + :param thumbnail_mime_type: Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg” :type thumbnail_mime_type: :obj:`str` @@ -4781,7 +4781,7 @@ class InlineQueryResultGif(InlineQueryResultBase): :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 + :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` @@ -4802,7 +4802,7 @@ def __init__(self, id: str, gif_url: str, thumbnail_url: str, gif_width: Optiona reply_markup: Optional[InlineKeyboardMarkup] = None, input_message_content: Optional[InputMessageContent] = None, gif_duration: Optional[int] = None, parse_mode: Optional[str] = None, thumbnail_mime_type: Optional[str] = None, show_caption_above_media: Optional[bool] = None): - + 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) @@ -4869,7 +4869,7 @@ class InlineQueryResultMpeg4Gif(InlineQueryResultBase): :param thumbnail_url: URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result :type thumbnail_url: :obj:`str` - :param thumbnail_mime_type: Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or + :param thumbnail_mime_type: Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg” :type thumbnail_mime_type: :obj:`str` @@ -4882,7 +4882,7 @@ class InlineQueryResultMpeg4Gif(InlineQueryResultBase): :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 + :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` @@ -4902,7 +4902,7 @@ def __init__(self, id: str, mpeg4_url: str, thumbnail_url: str, mpeg4_width: Opt title: Optional[str] = None, caption: Optional[str] = None, caption_entities: Optional[List[MessageEntity]] = None, parse_mode: Optional[str] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, input_message_content: Optional[InputMessageContent] = None, mpeg4_duration: Optional[int] = None, thumbnail_mime_type: Optional[str] = None, show_caption_above_media: Optional[bool] = None): - + 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) @@ -4969,11 +4969,11 @@ class InlineQueryResultVideo(InlineQueryResultBase): :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 + :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 + :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` @@ -4992,7 +4992,7 @@ class InlineQueryResultVideo(InlineQueryResultBase): :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 + :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` @@ -5007,7 +5007,7 @@ def __init__(self, id: str, video_url: str, mime_type: str, thumbnail_url: str, parse_mode: Optional[str] = None, video_width: Optional[int] = None, video_height: Optional[int] = None, video_duration: Optional[int] = None, description: Optional[str] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, input_message_content: Optional[InputMessageContent] = None, show_caption_above_media: Optional[bool] = None): - + 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) @@ -5063,11 +5063,11 @@ class InlineQueryResultAudio(InlineQueryResultBase): :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 + :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 + :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` @@ -5089,7 +5089,7 @@ class InlineQueryResultAudio(InlineQueryResultBase): def __init__(self, id: str, audio_url: str, title: str, caption: Optional[str] = None, caption_entities: Optional[List[MessageEntity]] = None, parse_mode: Optional[str] = None, performer: Optional[str] = None, audio_duration: Optional[int] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, input_message_content: Optional[InputMessageContent] = None): - + super().__init__('audio', id, title = title, caption = caption, input_message_content = input_message_content, reply_markup = reply_markup, parse_mode = parse_mode, caption_entities = caption_entities) @@ -5129,11 +5129,11 @@ class InlineQueryResultVoice(InlineQueryResultBase): :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 + :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 + :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` @@ -5152,7 +5152,7 @@ class InlineQueryResultVoice(InlineQueryResultBase): def __init__(self, id: str, voice_url: str, title: str, caption: Optional[str] = None, caption_entities: Optional[List[MessageEntity]] = None, parse_mode: Optional[str] = None, voice_duration: Optional[int] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, input_message_content: Optional[InputMessageContent] = None): - + super().__init__('voice', id, title = title, caption = caption, input_message_content = input_message_content, reply_markup = reply_markup, parse_mode = parse_mode, caption_entities = caption_entities) @@ -5186,11 +5186,11 @@ class InlineQueryResultDocument(InlineQueryResultBase): :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 + :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 + :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` @@ -5225,7 +5225,7 @@ def __init__(self, id: str, title: str, document_url: str, mime_type: str, capti parse_mode: Optional[str] = None, description: Optional[str] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, input_message_content: Optional[InputMessageContent] = None, thumbnail_url: Optional[str] = None, thumbnail_width: Optional[int] = None, thumbnail_height: Optional[int] = None): - + super().__init__('document', id, title = title, caption = caption, input_message_content = input_message_content, reply_markup = reply_markup, parse_mode = parse_mode, caption_entities = caption_entities) @@ -5323,7 +5323,7 @@ def __init__(self, id: str, title: str, latitude: float, longitude: float, horiz reply_markup: Optional[InlineKeyboardMarkup] = None, input_message_content: Optional[InputMessageContent] = None, thumbnail_url: Optional[str] = None, thumbnail_width: Optional[int] = None, thumbnail_height: Optional[int] = None, heading: Optional[int] = None, proximity_alert_radius: Optional[int] = None): - + super().__init__('location', id, title = title, input_message_content = input_message_content, reply_markup = reply_markup) self.latitude: float = latitude @@ -5400,7 +5400,7 @@ class InlineQueryResultVenue(InlineQueryResultBase): :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, + :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` @@ -5526,7 +5526,7 @@ class InlineQueryResultContact(InlineQueryResultBase): :return: Instance of the class :rtype: :class:`telebot.types.InlineQueryResultContact` """ - + def __init__(self, id: str, phone_number: str, first_name: str, last_name: Optional[str] = None, vcard: Optional[str] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, input_message_content: Optional[InputMessageContent] = None, thumbnail_url: Optional[str] = None, thumbnail_width: Optional[int] = None, thumbnail_height: Optional[int] = None): @@ -5671,11 +5671,11 @@ class InlineQueryResultCachedPhoto(InlineQueryResultCachedBase): :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 + :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 + :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` @@ -5737,7 +5737,7 @@ class InlineQueryResultCachedGif(InlineQueryResultCachedBase): :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 + :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` @@ -5757,7 +5757,7 @@ def __init__(self, id: str, gif_file_id: str, title: Optional[str] = None, descr caption: Optional[str] = None, caption_entities: Optional[List[MessageEntity]] = None, parse_mode: Optional[str] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, input_message_content: Optional[InputMessageContent] = None, show_caption_above_media: Optional[bool] = None): - + InlineQueryResultCachedBase.__init__(self) self.type: str = 'gif' self.id: str = id @@ -5798,7 +5798,7 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResultCachedBase): :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 + :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` @@ -5818,7 +5818,7 @@ def __init__(self, id: str, mpeg4_file_id: str, title: Optional[str] = None, des caption: Optional[str] = None, caption_entities: Optional[List[MessageEntity]] = None, parse_mode: Optional[str] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, input_message_content: Optional[InputMessageContent] = None, show_caption_above_media: Optional[bool] = None): - + InlineQueryResultCachedBase.__init__(self) self.type: str = 'mpeg4_gif' self.id: str = id @@ -5895,11 +5895,11 @@ class InlineQueryResultCachedDocument(InlineQueryResultCachedBase): :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 + :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 + :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` @@ -5917,7 +5917,7 @@ def __init__(self, id: str, document_file_id: str, title: str, description: Opti caption: Optional[str] = None, caption_entities: Optional[List[MessageEntity]] = None, parse_mode: Optional[str] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, input_message_content: Optional[InputMessageContent] = None): - + InlineQueryResultCachedBase.__init__(self) self.type: str = 'document' self.id: str = id @@ -5957,11 +5957,11 @@ class InlineQueryResultCachedVideo(InlineQueryResultCachedBase): :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 + :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 + :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` @@ -5982,7 +5982,7 @@ def __init__(self, id: str, video_file_id: str, title: str, description: Optiona caption: Optional[str] = None, caption_entities: Optional[List[MessageEntity]] = None, parse_mode: Optional[str] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, input_message_content: Optional[InputMessageContent] = None, show_caption_above_media: Optional[bool] = None): - + InlineQueryResultCachedBase.__init__(self) self.type: str = 'video' self.id: str = id @@ -6020,11 +6020,11 @@ class InlineQueryResultCachedVoice(InlineQueryResultCachedBase): :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 + :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 + :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` @@ -6037,7 +6037,7 @@ class InlineQueryResultCachedVoice(InlineQueryResultCachedBase): :return: Instance of the class :rtype: :class:`telebot.types.InlineQueryResultCachedVoice` """ - + def __init__(self, id: str, voice_file_id: str, title: str, caption: Optional[str] = None, caption_entities: Optional[List[MessageEntity]] = None, parse_mode: Optional[str] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, input_message_content: Optional[InputMessageContent] = None): @@ -6052,7 +6052,7 @@ def __init__(self, id: str, voice_file_id: str, title: str, caption: Optional[st self.input_message_content: Optional[InputMessageContent] = input_message_content self.parse_mode: Optional[str] = parse_mode self.payload_dic['voice_file_id'] = voice_file_id - + # noinspection PyUnresolvedReferences,PyShadowingBuiltins @@ -6074,11 +6074,11 @@ class InlineQueryResultCachedAudio(InlineQueryResultCachedBase): :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 + :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 + :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` @@ -6091,7 +6091,7 @@ class InlineQueryResultCachedAudio(InlineQueryResultCachedBase): :return: Instance of the class :rtype: :class:`telebot.types.InlineQueryResultCachedAudio` """ - + def __init__(self, id: str, audio_file_id: str, caption: Optional[str] = None, caption_entities: Optional[List[MessageEntity]] = None, parse_mode: Optional[str] = None, reply_markup: Optional[InlineKeyboardMarkup] = None, input_message_content: Optional[InputMessageContent] = None): @@ -6124,8 +6124,8 @@ class Game(JsonDeserializable): :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 + :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` @@ -6187,7 +6187,7 @@ class Animation(JsonDeserializable): :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 + :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` @@ -6209,8 +6209,8 @@ class Animation(JsonDeserializable): :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 + :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` @@ -6227,7 +6227,7 @@ def de_json(cls, json_string): obj['thumbnail'] = None return cls(**obj) - def __init__(self, file_id, file_unique_id, width=None, height=None, duration=None, + def __init__(self, file_id, file_unique_id, width=None, height=None, duration=None, thumbnail=None, file_name=None, mime_type=None, file_size=None, **kwargs): self.file_id: str = file_id self.file_unique_id: str = file_unique_id @@ -6287,8 +6287,8 @@ class LabeledPrice(JsonSerializable, Dictionaryable): :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 + :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` @@ -6326,8 +6326,8 @@ class Invoice(JsonDeserializable): :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 + :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` @@ -6452,7 +6452,7 @@ def __init__(self, id, title): def add_price(self, *args) -> 'ShippingOption': """ Add LabeledPrice to ShippingOption - + :param args: LabeledPrices :type args: :obj:`LabeledPrice` @@ -6479,8 +6479,8 @@ class SuccessfulPayment(JsonDeserializable): :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 + :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` @@ -6519,7 +6519,7 @@ def de_json(cls, json_string): return cls(**obj) def __init__(self, currency, total_amount, invoice_payload, shipping_option_id=None, order_info=None, - telegram_payment_charge_id=None, provider_payment_charge_id=None, + telegram_payment_charge_id=None, provider_payment_charge_id=None, subscription_expiration_date=None, is_recurring=None, is_first_recurring=None, **kwargs): self.currency: str = currency self.total_amount: int = total_amount @@ -6586,8 +6586,8 @@ class PreCheckoutQuery(JsonDeserializable): :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 + :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` @@ -6699,7 +6699,7 @@ class Sticker(JsonDeserializable): :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 + :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` @@ -6763,8 +6763,8 @@ def de_json(cls, json_string): obj['premium_animation'] = File.de_json(obj['premium_animation']) return cls(**obj) - def __init__(self, file_id, file_unique_id, type, width, height, is_animated, - is_video, thumbnail=None, emoji=None, set_name=None, mask_position=None, file_size=None, + def __init__(self, file_id, file_unique_id, type, width, height, is_animated, + is_video, thumbnail=None, emoji=None, set_name=None, mask_position=None, file_size=None, premium_animation=None, custom_emoji_id=None, needs_repainting=None, **kwargs): self.file_id: str = file_id self.file_unique_id: str = file_unique_id @@ -6794,15 +6794,15 @@ class MaskPosition(Dictionaryable, JsonDeserializable, JsonSerializable): 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 + :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, + :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 + :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 @@ -6895,7 +6895,7 @@ def convert_input_media(self): """ if service_utils.is_string(self.media): return self.to_json(), None - + media_dict = {self._media_name: self.media} if self._thumbnail_name: media_dict[self._thumbnail_name] = self.thumbnail @@ -6909,19 +6909,19 @@ class InputMediaPhoto(InputMedia): Telegram Documentation: https://core.telegram.org/bots/api#inputmediaphoto - :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 + :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 + :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 + :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` @@ -6939,7 +6939,7 @@ def __init__(self, media: Union[str, InputFile], caption: Optional[str] = None, has_spoiler: Optional[bool] = None, show_caption_above_media: Optional[bool] = None): if service_utils.is_pil_image(media): media = service_utils.pil_image_to_file(media) - + super(InputMediaPhoto, self).__init__( type="photo", media=media, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities) @@ -6961,15 +6961,15 @@ class InputMediaVideo(InputMedia): Telegram Documentation: https://core.telegram.org/bots/api#inputmediavideo - :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 + :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 thumbnail: 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 + :param thumbnail: 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 thumbnail: InputFile or :obj:`str` @@ -6984,11 +6984,11 @@ class InputMediaVideo(InputMedia): :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 + :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 + :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` @@ -7063,26 +7063,26 @@ class InputMediaAnimation(InputMedia): Telegram Documentation: https://core.telegram.org/bots/api#inputmediaanimation - :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 + :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 thumbnail: 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 + 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 thumbnail: 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 + :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 + :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` @@ -7145,26 +7145,26 @@ class InputMediaAudio(InputMedia): Telegram Documentation: https://core.telegram.org/bots/api#inputmediaaudio - :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 + :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 thumbnail: 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 + :param thumbnail: 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 thumbnail: 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 + :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 + :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` @@ -7213,29 +7213,29 @@ class InputMediaDocument(InputMedia): Telegram Documentation: https://core.telegram.org/bots/api#inputmediadocument :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 + 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 thumbnail: 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 + :param thumbnail: 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 thumbnail: 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 + :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 + :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 + :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` @@ -7458,8 +7458,7 @@ class PollAnswer(JsonSerializable, JsonDeserializable, Dictionaryable): :param user: Optional. 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. + :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 @@ -7478,7 +7477,7 @@ def de_json(cls, json_string): def __init__(self, poll_id: str, option_ids: List[int], user: Optional[User] = None, voter_chat: Optional[Chat] = None, **kwargs): self.poll_id: str = poll_id self.user: Optional[User] = user - self.option_ids: Optional[List[int]] = option_ids + self.option_ids: List[int] = option_ids self.voter_chat: Optional[Chat] = voter_chat @@ -7496,7 +7495,7 @@ def to_dict(self): if self.voter_chat: json_dict["voter_chat"] = self.voter_chat return json_dict - + class ChatLocation(JsonSerializable, JsonDeserializable, Dictionaryable): @@ -7520,14 +7519,14 @@ def de_json(cls, json_string): obj = cls.check_json(json_string) obj['location'] = Location.de_json(obj['location']) return cls(**obj) - + def __init__(self, location: Location, address: str, **kwargs): self.location: Location = location self.address: str = address def to_json(self): return json.dumps(self.to_dict()) - + def to_dict(self): return { "location": self.location.to_dict(), @@ -7541,7 +7540,7 @@ class ChatInviteLink(JsonSerializable, JsonDeserializable, Dictionaryable): 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 + :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` @@ -7563,7 +7562,7 @@ class ChatInviteLink(JsonSerializable, JsonDeserializable, Dictionaryable): :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 + :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` @@ -7579,7 +7578,7 @@ def de_json(cls, json_string): obj = cls.check_json(json_string) obj['creator'] = User.de_json(obj['creator']) return cls(**obj) - + def __init__(self, invite_link: str, creator: User, creates_join_request: bool, is_primary: bool, is_revoked: bool, name: Optional[str] = None, expire_date: Optional[int] = None, member_limit: Optional[int] = None, pending_join_request_count: Optional[int] = None, **kwargs): @@ -7592,10 +7591,10 @@ def __init__(self, invite_link: str, creator: User, creates_join_request: bool, self.expire_date: Optional[int] = expire_date self.member_limit: Optional[int] = member_limit self.pending_join_request_count: Optional[int] = pending_join_request_count - + def to_json(self): return json.dumps(self.to_dict()) - + def to_dict(self): json_dict = { "invite_link": self.invite_link, @@ -7638,7 +7637,7 @@ def de_json(cls, json_string): if json_string is None: return None obj = cls.check_json(json_string, dict_copy=False) return cls(**obj) - + def __init__(self, traveler, watcher, distance, **kwargs): self.traveler: User = traveler self.watcher: User = watcher @@ -7652,7 +7651,7 @@ class VideoChatStarted(JsonDeserializable): @classmethod def de_json(cls, json_string): return cls() - + def __init__(self): pass @@ -7672,7 +7671,7 @@ class VideoChatScheduled(JsonDeserializable): 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 + :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` @@ -7684,7 +7683,7 @@ def de_json(cls, json_string): if json_string is None: return None obj = cls.check_json(json_string, dict_copy=False) return cls(**obj) - + def __init__(self, start_date, **kwargs): self.start_date: int = start_date @@ -7715,7 +7714,7 @@ def de_json(cls, json_string): if json_string is None: return None obj = cls.check_json(json_string, dict_copy=False) return cls(**obj) - + def __init__(self, duration, **kwargs): self.duration: int = duration @@ -7748,7 +7747,7 @@ def de_json(cls, json_string): obj = cls.check_json(json_string) obj['users'] = [User.de_json(u) for u in obj['users']] return cls(**obj) - + def __init__(self, users=None, **kwargs): self.users: List[User] = users @@ -7773,7 +7772,7 @@ class MessageAutoDeleteTimerChanged(JsonDeserializable): :return: Instance of the class :rtype: :class:`telebot.types.MessageAutoDeleteTimerChanged` - """ + """ @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -7791,7 +7790,7 @@ class MenuButton(JsonDeserializable, JsonSerializable, Dictionaryable): * :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. """ @@ -7805,7 +7804,7 @@ def de_json(cls, json_string): 'default': MenuButtonDefault } return types[obj['type']](**obj) - + def to_json(self): """ :meta private: @@ -7838,7 +7837,7 @@ def __init__(self, type: str = None, **kwargs): def to_dict(self): return {'type': self.type} - + def to_json(self): return json.dumps(self.to_dict()) @@ -7856,7 +7855,7 @@ class MenuButtonWebApp(MenuButton): :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 + :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. Alternatively, a t.me link to a Web App of the bot can be specified in the object instead of the Web App's URL, in which case the Web App will be opened as if the user pressed the link. @@ -7900,7 +7899,7 @@ def to_dict(self): def to_json(self): return json.dumps(self.to_dict()) - + class ChatAdministratorRights(JsonDeserializable, JsonSerializable, Dictionaryable): """ Represents the rights of an administrator in a chat. @@ -7910,8 +7909,8 @@ class ChatAdministratorRights(JsonDeserializable, JsonSerializable, Dictionaryab :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. + :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` @@ -7924,8 +7923,8 @@ class ChatAdministratorRights(JsonDeserializable, JsonSerializable, Dictionaryab :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 + :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` @@ -7938,7 +7937,7 @@ class ChatAdministratorRights(JsonDeserializable, JsonSerializable, Dictionaryab :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 + :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` @@ -7970,7 +7969,7 @@ def de_json(cls, json_string): obj = cls.check_json(json_string) return cls(**obj) - def __init__(self, is_anonymous: bool, can_manage_chat: bool, + def __init__(self, is_anonymous: bool, can_manage_chat: bool, can_delete_messages: bool, can_manage_video_chats: bool, can_restrict_members: bool, can_promote_members: bool, can_change_info: bool, can_invite_users: bool, can_post_messages: Optional[bool]=None, can_edit_messages: Optional[bool]=None, @@ -7979,7 +7978,7 @@ def __init__(self, is_anonymous: bool, can_manage_chat: bool, can_delete_stories: Optional[bool]=None, can_manage_direct_messages: Optional[bool]=None, **kwargs ) -> None: - + self.is_anonymous: bool = is_anonymous self.can_manage_chat: bool = can_manage_chat self.can_delete_messages: bool = can_delete_messages @@ -8026,17 +8025,17 @@ def to_dict(self): json_dict['can_manage_direct_messages'] = self.can_manage_direct_messages return json_dict - + def to_json(self): return json.dumps(self.to_dict()) - + class InputFile: """ A class to send files through Telegram Bot API. - You need to pass a file, which should be an instance of :class:`io.IOBase` or + You need to pass a file, which should be an instance of :class:`io.IOBase` or :class:`pathlib.Path`, or :obj:`str`. If you pass an :obj:`str` as a file, it will be opened and closed by the class. @@ -8073,7 +8072,7 @@ def __init__(self, file: Union[str, IOBase, Path], file_name: Optional[str] = No self._file, self._file_name = self._resolve_file(file) if file_name: self._file_name = file_name - + @staticmethod def _resolve_file(file): @@ -8094,7 +8093,7 @@ def file(self) -> Union[IOBase, str]: File object. """ return self._file - + @property def file_name(self) -> str: """ @@ -8106,7 +8105,7 @@ def file_name(self) -> str: class ForumTopicCreated(JsonDeserializable): """ This object represents a service message about a new forum topic created in the chat. - + Telegram documentation: https://core.telegram.org/bots/api#forumtopiccreated :param name: Name of the topic @@ -8136,7 +8135,7 @@ def __init__(self, name: str, icon_color: int, icon_custom_emoji_id: Optional[st class ForumTopicClosed(JsonDeserializable): """ This object represents a service message about a forum topic closed in the chat. Currently holds no information. - + Telegram documentation: https://core.telegram.org/bots/api#forumtopicclosed """ # for future use @@ -8208,7 +8207,7 @@ class GeneralForumTopicUnhidden(JsonDeserializable): Telegram documentation: https://core.telegram.org/bots/api#generalforumtopicunhidden """ - + @classmethod def de_json(cls, json_string): return cls() @@ -8277,7 +8276,7 @@ def de_json(cls, json_string): if json_string is None: return None obj = cls.check_json(json_string) return cls(**obj) - + def __init__(self, from_request: Optional[bool]=None, web_app_name: Optional[str]=None, from_attachment_menu: Optional[bool]=None, **kwargs) -> None: @@ -8383,7 +8382,7 @@ class InputSticker(Dictionaryable, JsonSerializable): :param sticker: The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. - Animated and video stickers can't be uploaded via HTTP URL. + Animated and video stickers can't be uploaded via HTTP URL. :type sticker: :obj:`str` or :obj:`telebot.types.InputFile` :param emoji_list: One or more(up to 20) emoji(s) corresponding to the sticker @@ -8391,7 +8390,7 @@ class InputSticker(Dictionaryable, JsonSerializable): :param mask_position: Optional. Position where the mask should be placed on faces. For “mask” stickers only. :type mask_position: :class:`telebot.types.MaskPosition` - + :param keywords: Optional. List of 0-20 search keywords for the sticker with total length of up to 64 characters. For “regular” and “custom_emoji” stickers only. :type keywords: :obj:`list` of :obj:`str` @@ -8438,18 +8437,18 @@ def to_dict(self) -> dict: json_dict['keywords'] = self.keywords return json_dict - + def to_json(self) -> str: return json.dumps(self.to_dict()) - + def convert_input_sticker(self) -> Tuple[str, Optional[dict]]: if service_utils.is_string(self.sticker): return self.to_json(), None return self.to_json(), {self._sticker_name: self.sticker} - - - + + + class SwitchInlineQueryChosenChat(JsonDeserializable, Dictionaryable, JsonSerializable): """ Represents an inline button that switches the current user to inline mode in a chosen chat, @@ -8548,7 +8547,7 @@ class InlineQueryResultsButton(JsonSerializable, Dictionaryable): :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 switch back to the inline mode using the method web_app_switch_inline_query inside the Web App. :type web_app: :class:`telebot.types.WebAppInfo` - + :param start_parameter: Optional. Deep-linking parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed. Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search @@ -8578,7 +8577,7 @@ def to_dict(self) -> dict: json_dict['start_parameter'] = self.start_parameter return json_dict - + def to_json(self) -> str: return json.dumps(self.to_dict()) @@ -8606,7 +8605,7 @@ def de_json(cls, json_string): obj = cls.check_json(json_string) obj['chat'] = Chat.de_json(obj['chat']) return cls(**obj) - + def __init__(self, chat: Chat, id: int, **kwargs) -> None: self.chat: Chat = chat self.id: int = id @@ -8631,7 +8630,7 @@ class ReactionType(JsonDeserializable, Dictionaryable, JsonSerializable): def de_json(cls, json_string): if json_string is None: return None obj = cls.check_json(json_string) - # remove type + # remove type if obj['type'] == 'emoji': del obj['type'] return ReactionTypeEmoji(**obj) @@ -8654,7 +8653,7 @@ def to_dict(self) -> dict: 'type': self.type } return json_dict - + def to_json(self) -> str: return json.dumps(self.to_dict()) @@ -8731,7 +8730,7 @@ def __init__(self, **kwargs) -> None: def to_dict(self) -> dict: return super().to_dict() - + class MessageReactionUpdated(JsonDeserializable): @@ -8851,7 +8850,7 @@ def de_json(cls, json_string): obj = cls.check_json(json_string) obj['type'] = ReactionType.de_json(obj['type']) return cls(**obj) - + def __init__(self, type: ReactionType, total_count: int, **kwargs) -> None: self.type: ReactionType = type self.total_count: int = total_count @@ -9265,7 +9264,7 @@ def __init__(self, chats: List[Chat], winners_selection_date: int, winner_count: self.country_codes: Optional[List[str]] = country_codes self.premium_subscription_month_count: Optional[int] = premium_subscription_month_count self.prize_star_count: Optional[int] = prize_star_count - + class GiveawayWinners(JsonDeserializable): """ @@ -9320,7 +9319,7 @@ def de_json(cls, json_string): obj['chat'] = Chat.de_json(obj['chat']) obj['winners'] = [User.de_json(user) for user in obj['winners']] return cls(**obj) - + def __init__(self, chat: Chat, giveaway_message_id: int, winners_selection_date: int, winner_count: int, winners: List[User], additional_chat_count: Optional[int] = None, premium_subscription_month_count: Optional[int] = None, unclaimed_prize_count: Optional[int] = None, @@ -9338,8 +9337,8 @@ def __init__(self, chat: Chat, giveaway_message_id: int, winners_selection_date: self.was_refunded: Optional[bool] = was_refunded self.prize_description: Optional[str] = prize_description self.prize_star_count: Optional[int] = prize_star_count - - + + class GiveawayCompleted(JsonDeserializable): """ This object represents a service message about the completion of a giveaway without public winners. @@ -9369,14 +9368,14 @@ def de_json(cls, json_string): if 'giveaway_message' in obj: obj['giveaway_message'] = Message.de_json(obj['giveaway_message']) return cls(**obj) - + def __init__(self, winner_count: int, unclaimed_prize_count: Optional[int] = None, giveaway_message: Optional[Message] = None, is_star_giveaway: Optional[bool] = None, **kwargs) -> None: self.winner_count: int = winner_count self.unclaimed_prize_count: Optional[int] = unclaimed_prize_count self.giveaway_message: Optional[Message] = giveaway_message self.is_star_giveaway: Optional[bool] = is_star_giveaway - + class GiveawayCreated(JsonDeserializable): """ @@ -9486,7 +9485,7 @@ def de_json(cls, json_string): obj = cls.check_json(json_string) if 'quote_entities' in obj: obj['quote_entities'] = [MessageEntity.de_json(entity) for entity in obj['quote_entities']] - return cls(**obj) + return cls(**obj) def __init__(self, message_id: int, chat_id: Optional[Union[int, str]] = None, allow_sending_without_reply: Optional[bool] = None, quote: Optional[str] = None, @@ -9520,11 +9519,11 @@ def to_dict(self) -> dict: if self.checklist_task_id is not None: json_dict['checklist_task_id'] = self.checklist_task_id return json_dict - + def to_json(self) -> str: return json.dumps(self.to_dict()) - - + + class UsersShared(JsonDeserializable): """ This object contains information about the users whose identifiers were shared with the bot @@ -9582,7 +9581,7 @@ class ChatBoostUpdated(JsonDeserializable): @classmethod def de_json(cls, json_string): if json_string is None: return None - obj = cls.check_json(json_string) + obj = cls.check_json(json_string) obj['chat'] = Chat.de_json(obj['chat']) obj['boost'] = ChatBoost.de_json(obj['boost']) return cls(**obj) @@ -9590,8 +9589,8 @@ def de_json(cls, json_string): def __init__(self, chat, boost, **kwargs): self.chat: Chat = chat self.boost: ChatBoost = boost - - + + class ChatBoostRemoved(JsonDeserializable): """ This object represents a boost removed from a chat. @@ -9619,7 +9618,7 @@ def de_json(cls, json_string): if json_string is None: return None obj = cls.check_json(json_string) obj['chat'] = Chat.de_json(obj['chat']) - obj['source'] = ChatBoostSource.de_json(obj['source']) + obj['source'] = ChatBoostSource.de_json(obj['source']) return cls(**obj) def __init__(self, chat, boost_id, remove_date, source, **kwargs): @@ -9627,8 +9626,8 @@ def __init__(self, chat, boost_id, remove_date, source, **kwargs): self.boost_id: str = boost_id self.remove_date: int = remove_date self.source: ChatBoostSource = source - - + + class ChatBoostSource(ABC, JsonDeserializable): """ This object describes the source of a chat boost. It can be one of @@ -9801,7 +9800,7 @@ def __init__(self, boost_id, add_date, expiration_date, source, **kwargs): self.add_date: int = add_date self.expiration_date: int = expiration_date self.source: ChatBoostSource = source - + class UserChatBoosts(JsonDeserializable): """ @@ -9825,7 +9824,7 @@ def de_json(cls, json_string): def __init__(self, boosts, **kwargs): self.boosts: List[ChatBoost] = boosts - + class InaccessibleMessage(JsonDeserializable): """ @@ -9902,7 +9901,7 @@ def de_json(cls, json_string): if json_string is None: return None obj = cls.check_json(json_string) return cls(**obj) - + def __init__(self, boost_count, **kwargs): self.boost_count: int = boost_count @@ -9946,7 +9945,7 @@ def de_json(cls, json_string): obj['user'] = User.de_json(obj['user']) obj['rights'] = BusinessBotRights.de_json(obj.get('rights')) return cls(**obj) - + def __init__(self, id, user, user_chat_id, date, can_reply, is_enabled, rights=None, **kwargs): self.id: str = id @@ -9991,13 +9990,13 @@ def de_json(cls, json_string): obj = cls.check_json(json_string) obj['chat'] = Chat.de_json(obj['chat']) return cls(**obj) - + def __init__(self, business_connection_id, chat, message_ids, **kwargs): self.business_connection_id: str = business_connection_id self.chat: Chat = chat self.message_ids: List[int] = message_ids - + class BusinessIntro(JsonDeserializable): """ @@ -10025,7 +10024,7 @@ def de_json(cls, json_string): if 'sticker' in obj: obj['sticker'] = Sticker.de_json(obj['sticker']) return cls(**obj) - + def __init__(self, title=None, message=None, sticker=None, **kwargs): self.title: Optional[str] = title self.message: Optional[str] = message @@ -10055,7 +10054,7 @@ def de_json(cls, json_string): if 'location' in obj: obj['location'] = Location.de_json(obj['location']) return cls(**obj) - + def __init__(self, address, location=None, **kwargs): self.address: str = address self.location: Optional[Location] = location @@ -10082,7 +10081,7 @@ def de_json(cls, json_string): if json_string is None: return None obj = cls.check_json(json_string) return cls(**obj) - + def __init__(self, opening_minute, closing_minute, **kwargs): self.opening_minute: int = opening_minute self.closing_minute: int = closing_minute @@ -10112,7 +10111,7 @@ def de_json(cls, json_string): obj = cls.check_json(json_string) obj['opening_hours'] = [BusinessOpeningHoursInterval.de_json(interval) for interval in obj['opening_hours']] return cls(**obj) - + def __init__(self, time_zone_name, opening_hours, **kwargs): self.time_zone_name: str = time_zone_name self.opening_hours: List[BusinessOpeningHoursInterval] = opening_hours @@ -10150,7 +10149,7 @@ def de_json(cls, json_string): if 'photo' in obj: obj['photo'] = [PhotoSize.de_json(photo) for photo in obj['photo']] return cls(**obj) - + def __init__(self, user_id, first_name=None, last_name=None, username=None, photo=None, **kwargs): self.user_id: int = user_id self.first_name: Optional[str] = first_name @@ -10183,7 +10182,7 @@ def de_json(cls, json_string): if json_string is None: return None obj = cls.check_json(json_string) return cls(**obj) - + def __init__(self, day, month, year=None, **kwargs): self.day: int = day self.month: int = month @@ -10761,8 +10760,8 @@ class TransactionPartnerUser(TransactionPartner): :rtype: :class:`TransactionPartnerUser` """ - def __init__(self, type, user, affiliate=None, invoice_payload=None, paid_media: Optional[List[PaidMedia]] = None, - subscription_period=None, gift: Optional[Gift] = None, premium_subscription_duration: Optional[int] = None, + def __init__(self, type, user, affiliate=None, invoice_payload=None, paid_media: Optional[List[PaidMedia]] = None, + subscription_period=None, gift: Optional[Gift] = None, premium_subscription_duration: Optional[int] = None, transaction_type: Optional[str] = None, **kwargs): self.type: str = type self.user: User = user @@ -10794,7 +10793,7 @@ class TransactionPartnerTelegramAds(TransactionPartner): Describes a transaction with Telegram Ads. Telegram documentation: https://core.telegram.org/bots/api#transactionpartnertelegramads - + :param type: Type of the transaction partner, always “telegram_ads” :type type: :obj:`str` @@ -10874,7 +10873,7 @@ def de_json(cls, json_string): if 'receiver' in obj: obj['receiver'] = TransactionPartner.de_json(obj['receiver']) return cls(**obj) - + def __init__(self, id, amount, date, source=None, receiver=None, nanostar_amount=None, **kwargs): self.id: str = id self.amount: int = amount @@ -10904,7 +10903,7 @@ def de_json(cls, json_string): obj = cls.check_json(json_string) obj['transactions'] = [StarTransaction.de_json(transaction) for transaction in obj['transactions']] return cls(**obj) - + def __init__(self, transactions, **kwargs): self.transactions: List[StarTransaction] = transactions @@ -11055,7 +11054,7 @@ def de_json(cls, json_string): obj = cls.check_json(json_string) obj['paid_media'] = [PaidMedia.de_json(media) for media in obj['paid_media']] return cls(**obj) - + def __init__(self, star_count, paid_media, **kwargs): self.star_count: int = star_count self.paid_media: List[PaidMedia] = paid_media @@ -11091,7 +11090,7 @@ def __init__(self, type: str, media: Union[str, InputFile], **kwargs): def to_json(self): return json.dumps(self.to_dict()) - + def to_dict(self): data = { 'type': self.type, @@ -11235,8 +11234,8 @@ def de_json(cls, json_string): if json_string is None: return None obj = cls.check_json(json_string) return cls(**obj) - - + + class PaidMediaPurchased(JsonDeserializable): """ This object contains information about a paid media purchase. @@ -11263,7 +11262,7 @@ def de_json(cls, json_string): obj = cls.check_json(json_string) obj['from_user'] = User.de_json(obj['from_user']) return cls(**obj) - + class CopyTextButton(JsonSerializable, JsonDeserializable): """ @@ -11282,13 +11281,13 @@ def __init__(self, text: str, **kwargs): def to_json(self): return json.dumps(self.to_dict()) - + def to_dict(self): data = { 'text': self.text } return data - + @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -11322,7 +11321,7 @@ def de_json(cls, json_string): if json_string is None: return None obj = cls.check_json(json_string) return cls(**obj) - + # noinspection PyShadowingBuiltins class Gift(JsonDeserializable): @@ -11398,8 +11397,8 @@ def de_json(cls, json_string): obj = cls.check_json(json_string) obj['gifts'] = [Gift.de_json(gift) for gift in obj['gifts']] return cls(**obj) - - + + # noinspection PyShadowingBuiltins class TransactionPartnerAffiliateProgram(TransactionPartner): """ @@ -11433,7 +11432,7 @@ def de_json(cls, json_string): obj['sponsor_user'] = User.de_json(obj['sponsor_user']) return cls(**obj) - + class AffiliateInfo(JsonDeserializable): """ @@ -11476,7 +11475,7 @@ def de_json(cls, json_string): if 'affiliate_chat' in obj: obj['affiliate_chat'] = Chat.de_json(obj['affiliate_chat']) return cls(**obj) - + # noinspection PyShadowingBuiltins class TransactionPartnerChat(TransactionPartner): @@ -11511,7 +11510,7 @@ def de_json(cls, json_string): if 'gift' in obj: obj['gift'] = Gift.de_json(obj['gift']) return cls(**obj) - + class BusinessBotRights(JsonDeserializable): """ @@ -11562,10 +11561,10 @@ class BusinessBotRights(JsonDeserializable): :type can_manage_stories: :obj:`bool` :return: Instance of the class - :rtype: :class:`BusinessBotRights` + :rtype: :class:`BusinessBotRights` """ def __init__(self, can_reply=None, can_read_messages=None, can_delete_outgoing_messages=None, can_delete_all_messages=None, - can_edit_name=None, can_edit_bio=None, can_edit_profile_photo=None, can_edit_username=None, + can_edit_name=None, can_edit_bio=None, can_edit_profile_photo=None, can_edit_username=None, can_change_gift_settings=None, can_view_gifts_and_stars=None, can_convert_gifts_to_stars=None, can_transfer_and_upgrade_gifts=None, can_transfer_stars=None, can_manage_stories=None, **kwargs): self.can_reply: Optional[bool] = can_reply @@ -11582,7 +11581,7 @@ def __init__(self, can_reply=None, can_read_messages=None, can_delete_outgoing_m self.can_transfer_and_upgrade_gifts: Optional[bool] = can_transfer_and_upgrade_gifts self.can_transfer_stars: Optional[bool] = can_transfer_stars self.can_manage_stories: Optional[bool] = can_manage_stories - + @classmethod def de_json(cls, json_string): if json_string is None: return None @@ -11604,7 +11603,7 @@ class AcceptedGiftTypes(JsonDeserializable, JsonSerializable): :param unique_gifts: True, if unique gifts or gifts that can be upgraded to unique for free are accepted :type unique_gifts: :obj:`bool` - + :param premium_subscription: True, if a Telegram Premium subscription is accepted :type premium_subscription: :obj:`bool` @@ -11617,10 +11616,10 @@ def __init__(self, unlimited_gifts: bool, limited_gifts: bool, self.limited_gifts: bool = limited_gifts self.unique_gifts: bool = unique_gifts self.premium_subscription: bool = premium_subscription - + def to_json(self): return json.dumps(self.to_dict()) - + def to_dict(self): data = { 'unlimited_gifts': self.unlimited_gifts, @@ -11710,7 +11709,7 @@ class OwnedGiftRegular(OwnedGift): :param send_date: Date the gift was sent in Unix time :type send_date: :obj:`int` - + :param text: Optional. Text of the message that was added to the gift :type text: :obj:`str` @@ -11824,7 +11823,7 @@ def de_json(cls, json_string): if 'sender_user' in obj: obj['sender_user'] = User.de_json(obj['sender_user']) return cls(**obj) - + class OwnedGifts(JsonDeserializable): """ @@ -11907,8 +11906,8 @@ def de_json(cls, json_string): if 'publisher_chat' in obj: obj['publisher_chat'] = Chat.de_json(obj['publisher_chat']) return cls(**obj) - - + + class UniqueGiftModel(JsonDeserializable): """ This object describes the model of a unique gift. @@ -12068,20 +12067,20 @@ def __init__(self, photo: InputFile, **kwargs): self.photo: InputFile = photo self._photo_name = service_utils.generate_random_token() self._photo_dic = "attach://{}".format(self._photo_name) - + def to_json(self): return json.dumps(self.to_dict()) - + def to_dict(self): data = { 'type': self.type, 'photo': self._photo_dic } return data - + def convert_input_story(self): return self.to_json(), {self._photo_name: self.photo} - + class InputStoryContentVideo(InputStoryContent): """ @@ -12116,7 +12115,7 @@ def __init__(self, video: InputFile, duration: Optional[float] = None, cover_fra def to_json(self): return json.dumps(self.to_dict()) - + def to_dict(self): data = { 'type': self.type, @@ -12132,7 +12131,7 @@ def to_dict(self): def convert_input_story(self): return self.to_json(), {self._video_name: self.video} - + class StoryAreaPosition(JsonSerializable): """ @@ -12183,7 +12182,7 @@ def to_dict(self): 'corner_radius_percentage': self.corner_radius_percentage } return data - + class LocationAddress(JsonSerializable): """ @@ -12228,7 +12227,7 @@ def to_dict(self): data['street'] = self.street return data - + # noinspection PyShadowingBuiltins class StoryAreaType(JsonSerializable, ABC): """ @@ -12287,7 +12286,7 @@ def to_dict(self): if self.address is not None: data['address'] = self.address.to_dict() return data - + class StoryAreaTypeSuggestedReaction(StoryAreaType): """ @@ -12430,7 +12429,7 @@ def to_dict(self): } return data - + # noinspection PyShadowingBuiltins class StoryArea(JsonSerializable): @@ -12461,7 +12460,7 @@ def to_dict(self): 'type': self.type.to_dict() } return data - + class GiftInfo(JsonDeserializable): """ @@ -12563,7 +12562,7 @@ def de_json(cls, json_string): obj = cls.check_json(json_string) obj['gift'] = UniqueGift.de_json(obj['gift']) return cls(**obj) - + class PaidMessagePriceChanged(JsonDeserializable): """ @@ -12585,7 +12584,7 @@ def de_json(cls, json_string): if json_string is None: return None obj = cls.check_json(json_string) return cls(**obj) - + class InputProfilePhoto(JsonSerializable, ABC): """ @@ -12603,7 +12602,7 @@ class InputProfilePhoto(JsonSerializable, ABC): class InputProfilePhotoStatic(InputProfilePhoto): """ This object describes a static profile photo to set. - + Telegram documentation: https://core.telegram.org/bots/api#inputprofilephotostatic :param type: Type of the profile photo, must be static @@ -12624,7 +12623,7 @@ def __init__(self, photo: InputFile, **kwargs): def to_json(self): return json.dumps(self.to_dict()) - + def to_dict(self): data = { 'type': self.type, @@ -12722,7 +12721,7 @@ def de_json(cls, json_string): obj['completed_by_user'] = User.de_json(obj['completed_by_user']) return cls(**obj) - + class Checklist(JsonDeserializable): """ Describes a checklist. @@ -12748,7 +12747,7 @@ class Checklist(JsonDeserializable): :rtype: :class:`Checklist` """ def __init__(self, title: str, tasks: List[ChecklistTask], - title_entities: Optional[List[MessageEntity]] = None, + title_entities: Optional[List[MessageEntity]] = None, others_can_add_tasks: Optional[bool] = None, others_can_mark_tasks_as_done: Optional[bool] = None, **kwargs): self.title: str = title @@ -12795,10 +12794,10 @@ def __init__(self, id: int, text: str, parse_mode: Optional[str] = None, self.text: str = text self.parse_mode: Optional[str] = parse_mode self.text_entities: Optional[List[MessageEntity]] = text_entities - + def to_json(self): return json.dumps(self.to_dict()) - + def to_dict(self): data = { 'id': self.id, @@ -12838,7 +12837,7 @@ class InputChecklist(JsonSerializable): :return: Instance of the class :rtype: :class:`InputChecklist` """ - def __init__(self, title: str, tasks: List[InputChecklistTask], + def __init__(self, title: str, tasks: List[InputChecklistTask], parse_mode: Optional[str] = None, title_entities: Optional[List[MessageEntity]] = None, others_can_add_tasks: Optional[bool] = None, @@ -12852,7 +12851,7 @@ def __init__(self, title: str, tasks: List[InputChecklistTask], def to_json(self): return json.dumps(self.to_dict()) - + def to_dict(self): data = { 'title': self.title, @@ -12900,8 +12899,8 @@ def de_json(cls, json_string): if 'checklist_message' in obj: obj['checklist_message'] = Message.de_json(obj['checklist_message']) return cls(**obj) - - + + class ChecklistTasksAdded(JsonDeserializable): """ Describes a service message about tasks added to a checklist.