diff --git a/README.md b/README.md index 00fc372..a6ca036 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ [![PyPi Package Version](https://img.shields.io/pypi/v/pyTelegramBotAPI.svg)](https://pypi.python.org/pypi/pyTelegramBotAPI) [![Supported Python versions](https://img.shields.io/pypi/pyversions/pyTelegramBotAPI.svg)](https://pypi.python.org/pypi/pyTelegramBotAPI) [![Documentation Status](https://readthedocs.org/projects/pytba/badge/?version=latest)](https://pytba.readthedocs.io/en/latest/?badge=latest) -[![Build Status](https://travis-ci.org/eternnoir/pyTelegramBotAPI.svg?branch=master)](https://travis-ci.org/eternnoir/pyTelegramBotAPI) [![PyPi downloads](https://img.shields.io/pypi/dm/pyTelegramBotAPI.svg)](https://pypi.org/project/pyTelegramBotAPI/) [![PyPi status](https://img.shields.io/pypi/status/pytelegrambotapi.svg?style=flat-square)](https://pypi.python.org/pypi/pytelegrambotapi) diff --git a/telebot/__init__.py b/telebot/__init__.py index 0d36d7b..c385a29 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -451,7 +451,7 @@ class TeleBot: drop_pending_updates: Optional[bool] = None, timeout: Optional[int]=None, secret_token: Optional[str]=None, - secret_token_length: Optional[int]=20,): + secret_token_length: Optional[int]=20): """ This class sets webhooks and listens to a given url and port. @@ -1028,7 +1028,7 @@ class TeleBot: :return: """ if none_stop is not None: - logger.warning("polling: none_stop parameter is deprecated. Use non_stop instead.") + logger.warning('The parameter "none_stop" is deprecated. Use "non_stop" instead.') non_stop = none_stop if skip_pending: @@ -1892,7 +1892,7 @@ class TeleBot: 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 - :type thumbnail: :obj:`str` + :type thumbnail: :obj:`str` or :class:`telebot.types.InputFile` :param caption_entities: A JSON-serialized 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` @@ -1906,6 +1906,9 @@ class TeleBot: :param message_thread_id: Identifier of a message thread, in which the message will be sent :type message_thread_id: :obj:`int` + :param thumb: Deprecated. Use thumbnail instead + :type thumb: :obj:`str` or :class:`telebot.types.InputFile` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -1916,7 +1919,7 @@ class TeleBot: if thumb is not None and thumbnail is None: thumbnail = thumb - logger.warning('thumb is deprecated, use thumbnail instead') + logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.') return types.Message.de_json( apihelper.send_audio( @@ -2072,6 +2075,9 @@ class TeleBot: :param message_thread_id: The thread to which the message will be sent :type message_thread_id: :obj:`int` + :param thumb: Deprecated. Use thumbnail instead + :type thumb: :obj:`str` or :class:`telebot.types.InputFile` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -2082,17 +2088,18 @@ class TeleBot: if data and not(document): # function typo miss compatibility + logger.warning('The parameter "data" is deprecated. Use "document" instead.') document = data if thumb is not None and thumbnail is None: thumbnail = thumb - logger.warning('thumb is deprecated, use thumbnail instead') + logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.') return types.Message.de_json( apihelper.send_data( self.token, chat_id, document, 'document', reply_to_message_id = reply_to_message_id, reply_markup = reply_markup, parse_mode = parse_mode, - disable_notification = disable_notification, timeout = timeout, caption = caption, thumb = thumbnail, + disable_notification = disable_notification, timeout = timeout, caption = caption, thumbnail= thumbnail, caption_entities = caption_entities, allow_sending_without_reply = allow_sending_without_reply, disable_content_type_detection = disable_content_type_detection, visible_file_name = visible_file_name, protect_content = protect_content, message_thread_id = message_thread_id)) @@ -2162,6 +2169,7 @@ class TeleBot: if data and not(sticker): # function typo miss compatibility + logger.warning('The parameter "data" is deprecated. Use "sticker" instead.') sticker = data return types.Message.de_json( @@ -2256,6 +2264,9 @@ class TeleBot: :param has_spoiler: Pass True, if the video should be sent as a spoiler :type has_spoiler: :obj:`bool` + :param thumb: Deprecated. Use thumbnail instead + :type thumb: :obj:`str` or :class:`telebot.types.InputFile` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -2266,11 +2277,12 @@ class TeleBot: if data and not(video): # function typo miss compatibility + logger.warning('The parameter "data" is deprecated. Use "video" instead.') video = data if thumb is not None and thumbnail is None: thumbnail = thumb - logger.warning('thumb is deprecated, use thumbnail instead') + logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.') return types.Message.de_json( apihelper.send_video( @@ -2359,6 +2371,9 @@ class TeleBot: :param has_spoiler: Pass True, if the animation should be sent as a spoiler :type has_spoiler: :obj:`bool` + :param thumb: Deprecated. Use thumbnail instead + :type thumb: :obj:`str` or :class:`telebot.types.InputFile` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -2438,6 +2453,8 @@ class TeleBot: :param message_thread_id: Identifier of a message thread, in which the video note will be sent :type message_thread_id: :obj:`int` + :param thumb: Deprecated. Use thumbnail instead + :type thumb: :obj:`str` or :class:`telebot.types.InputFile` :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -3023,9 +3040,7 @@ class TeleBot: can_invite_users=can_invite_users, can_pin_messages=can_pin_messages ) - logger.warning( - "Individual parameters are deprecated and will be removed, use 'permissions' instead." - ) + logger.warning('The parameters "can_..." are deprecated, use "permissions" instead.') return apihelper.restrict_chat_member( self.token, chat_id, user_id, permissions, until_date, use_independent_chat_permissions) @@ -3108,7 +3123,7 @@ class TeleBot: :rtype: :obj:`bool` """ if can_manage_voice_chats is not None: - logger.warning("promote_chat_member: can_manage_voice_chats parameter is deprecated. Use can_manage_video_chats instead.") + logger.warning('The parameter "can_manage_voice_chats" is deprecated. Use "can_manage_video_chats" instead.') if can_manage_video_chats is None: can_manage_video_chats = can_manage_voice_chats @@ -4537,8 +4552,7 @@ class TeleBot: """ return apihelper.answer_callback_query(self.token, callback_query_id, text, show_alert, url, cache_time) - def set_sticker_set_thumbnail( - self, name: str, user_id: int, thumb: Union[Any, str]=None): + def set_sticker_set_thumbnail(self, name: str, user_id: int, thumbnail: Union[Any, str]=None): """ 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. @@ -4551,16 +4565,17 @@ class TeleBot: :param user_id: User identifier :type user_id: :obj:`int` - :param thumb: - :type thumb: :obj:`filelike object` + :param thumbnail: A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical requirements), or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-sticker-requirements for video sticker technical requirements. 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. More information on Sending Files ». Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. + :type thumbnail: :obj:`filelike object` :return: On success, True is returned. :rtype: :obj:`bool` """ - return apihelper.set_sticker_set_thumb(self.token, name, user_id, thumb) + + return apihelper.set_sticker_set_thumbnail(self.token, name, user_id, thumbnail) - def set_sticker_set_thumb( - self, name: str, user_id: int, thumb: Union[Any, str]=None): + @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. Animated thumbnails can be set for animated sticker sets only. Returns True on success. @@ -4580,8 +4595,7 @@ class TeleBot: :rtype: :obj:`bool` """ # deprecated - logger.warning('set_sticker_set_thumb is deprecated. Use set_sticker_set_thumbnail instead.') - return apihelper.set_sticker_set_thumb(self.token, name, user_id, thumb) + return self.set_sticker_set_thumbnail(name, user_id, thumb) def get_sticker_set(self, name: str) -> types.StickerSet: """ @@ -4736,7 +4750,7 @@ class TeleBot: :rtype: :class:`telebot.types.File` """ if png_sticker: - logger.warning("png_sticker is deprecated, use sticker instead", DeprecationWarning) + logger.warning('The parameter "png_sticker" is deprecated. Use "sticker" instead.') sticker = png_sticker sticker_format = "static" @@ -4894,10 +4908,7 @@ class TeleBot: if sticker is None: old_sticker = png_sticker or tgs_sticker or webm_sticker if old_sticker is not None: - logger.warning( - 'The parameters "png_sticker", "tgs_sticker", "webm_sticker", "emojis" and "mask_position" are deprecated, ' - 'use "sticker" instead' - ) + logger.warning('The parameters "..._sticker", "emojis" and "mask_position" are deprecated, use "sticker" instead') if not old_sticker: raise ValueError('You must pass at least one sticker.') sticker = types.InputSticker(old_sticker, emojis, mask_position) @@ -6740,7 +6751,6 @@ class TeleBot: if not process_handler: continue for i in inspect.signature(handler['function']).parameters: params.append(i) - result = None if len(params) == 1: result = handler['function'](message) elif "data" in params: diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 6d59b84..b5eb065 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -355,15 +355,15 @@ def get_chat_member_count(token, chat_id): return _make_request(token, method_url, params=payload) -def set_sticker_set_thumb(token, name, user_id, thumb): +def set_sticker_set_thumbnail(token, name, user_id, thumbnail): method_url = r'setStickerSetThumbnail' payload = {'name': name, 'user_id': user_id} files = {} - if thumb: - if not isinstance(thumb, str): - files['thumb'] = thumb + if thumbnail: + if not isinstance(thumbnail, str): + files['thumbnail'] = thumbnail else: - payload['thumb'] = thumb + payload['thumbnail'] = thumbnail return _make_request(token, method_url, params=payload, files=files or None) @@ -668,8 +668,8 @@ def send_chat_action(token, chat_id, action, timeout=None, message_thread_id=Non def send_video(token, chat_id, data, duration=None, caption=None, reply_to_message_id=None, reply_markup=None, - parse_mode=None, supports_streaming=None, disable_notification=None, timeout=None, - thumb=None, width=None, height=None, caption_entities=None, allow_sending_without_reply=None, protect_content=None, + parse_mode=None, supports_streaming=None, disable_notification=None, timeout=None, + thumbnail=None, width=None, height=None, caption_entities=None, allow_sending_without_reply=None, protect_content=None, message_thread_id=None, has_spoiler=None): method_url = r'sendVideo' payload = {'chat_id': chat_id} @@ -694,14 +694,14 @@ def send_video(token, chat_id, data, duration=None, caption=None, reply_to_messa payload['disable_notification'] = disable_notification if timeout: payload['timeout'] = timeout - if thumb: - if not util.is_string(thumb): + if thumbnail: + if not util.is_string(thumbnail): if files: - files['thumbnail'] = thumb + files['thumbnail'] = thumbnail else: - files = {'thumbnail': thumb} + files = {'thumbnail': thumbnail} else: - payload['thumbnail'] = thumb + payload['thumbnail'] = thumbnail if width: payload['width'] = width if height: @@ -721,7 +721,7 @@ def send_video(token, chat_id, data, duration=None, caption=None, reply_to_messa def send_animation( token, chat_id, data, duration=None, caption=None, reply_to_message_id=None, reply_markup=None, - parse_mode=None, disable_notification=None, timeout=None, thumb=None, caption_entities=None, + parse_mode=None, disable_notification=None, timeout=None, thumbnail=None, caption_entities=None, allow_sending_without_reply=None, protect_content=None, width=None, height=None, message_thread_id=None, has_spoiler=None): method_url = r'sendAnimation' @@ -745,14 +745,14 @@ def send_animation( payload['disable_notification'] = disable_notification if timeout: payload['timeout'] = timeout - if thumb: - if not util.is_string(thumb): + if thumbnail: + if not util.is_string(thumbnail): if files: - files['thumbnail'] = thumb + files['thumbnail'] = thumbnail else: - files = {'thumbnail': thumb} + files = {'thumbnail': thumbnail} else: - payload['thumbnail'] = thumb + payload['thumbnail'] = thumbnail if caption_entities: payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities)) if allow_sending_without_reply is not None: @@ -806,7 +806,7 @@ def send_voice(token, chat_id, voice, caption=None, duration=None, reply_to_mess def send_video_note(token, chat_id, data, duration=None, length=None, reply_to_message_id=None, reply_markup=None, - disable_notification=None, timeout=None, thumb=None, allow_sending_without_reply=None, protect_content=None, + disable_notification=None, timeout=None, thumbnail=None, allow_sending_without_reply=None, protect_content=None, message_thread_id=None): method_url = r'sendVideoNote' payload = {'chat_id': chat_id} @@ -829,14 +829,14 @@ def send_video_note(token, chat_id, data, duration=None, length=None, reply_to_m payload['disable_notification'] = disable_notification if timeout: payload['timeout'] = timeout - if thumb: - if not util.is_string(thumb): + if thumbnail: + if not util.is_string(thumbnail): if files: - files['thumbnail'] = thumb + files['thumbnail'] = thumbnail else: - files = {'thumbnail': thumb} + files = {'thumbnail': thumbnail} else: - payload['thumbnail'] = thumb + payload['thumbnail'] = thumbnail if allow_sending_without_reply is not None: payload['allow_sending_without_reply'] = allow_sending_without_reply if protect_content is not None: @@ -847,7 +847,7 @@ def send_video_note(token, chat_id, data, duration=None, length=None, reply_to_m def send_audio(token, chat_id, audio, caption=None, duration=None, performer=None, title=None, reply_to_message_id=None, - reply_markup=None, parse_mode=None, disable_notification=None, timeout=None, thumb=None, + reply_markup=None, parse_mode=None, disable_notification=None, timeout=None, thumbnail=None, caption_entities=None, allow_sending_without_reply=None, protect_content=None, message_thread_id=None): method_url = r'sendAudio' payload = {'chat_id': chat_id} @@ -874,14 +874,14 @@ def send_audio(token, chat_id, audio, caption=None, duration=None, performer=Non payload['disable_notification'] = disable_notification if timeout: payload['timeout'] = timeout - if thumb: - if not util.is_string(thumb): + if thumbnail: + if not util.is_string(thumbnail): if files: - files['thumbnail'] = thumb + files['thumbnail'] = thumbnail else: - files = {'thumbnail': thumb} + files = {'thumbnail': thumbnail} else: - payload['thumbnail'] = thumb + payload['thumbnail'] = thumbnail if caption_entities: payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities)) if allow_sending_without_reply is not None: @@ -894,7 +894,7 @@ def send_audio(token, chat_id, audio, caption=None, duration=None, performer=Non def send_data(token, chat_id, data, data_type, reply_to_message_id=None, reply_markup=None, parse_mode=None, - disable_notification=None, timeout=None, caption=None, thumb=None, caption_entities=None, + disable_notification=None, timeout=None, caption=None, thumbnail=None, caption_entities=None, allow_sending_without_reply=None, disable_content_type_detection=None, visible_file_name=None, protect_content = None, message_thread_id=None, emoji=None): method_url = get_method_by_type(data_type) @@ -919,14 +919,14 @@ def send_data(token, chat_id, data, data_type, reply_to_message_id=None, reply_m payload['timeout'] = timeout if caption: payload['caption'] = caption - if thumb: - if not util.is_string(thumb): + if thumbnail: + if not util.is_string(thumbnail): if files: - files['thumbnail'] = thumb + files['thumbnail'] = thumbnail else: - files = {'thumbnail': thumb} + files = {'thumbnail': thumbnail} else: - payload['thumbnail'] = thumb + payload['thumbnail'] = thumbnail if caption_entities: payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities)) if allow_sending_without_reply is not None: @@ -1479,7 +1479,8 @@ def send_invoice( :param max_tip_amount: The maximum accepted amount for tips in the smallest units of the currency :param suggested_tip_amounts: A JSON-serialized array of suggested amounts of tips in the smallest units of the currency. At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount. - :param protect_content: + :param protect_content: Protects the contents of the sent message from forwarding and saving + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :return: """ method_url = r'sendInvoice' diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index f13d1a0..ebf5e80 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -209,8 +209,8 @@ class AsyncTeleBot: :param allowed_updates: Array of string. List the types of updates you want your bot to receive. :type allowed_updates: :obj:`list`, optional - :param long_polling_timeout: Timeout in seconds for long polling. - :type long_polling_timeout: :obj:`int`, optional + :param request_timeout: Timeout in seconds for request. + :type request_timeout: :obj:`int`, optional :return: An Array of Update objects is returned. :rtype: :obj:`list` of :class:`telebot.types.Update` @@ -294,7 +294,7 @@ class AsyncTeleBot: :return: """ if none_stop is not None: - logger.warning("polling: none_stop parameter is deprecated. Use non_stop instead.") + logger.warning('The parameter "none_stop" is deprecated. Use "non_stop" instead.') non_stop = none_stop if skip_pending: @@ -511,7 +511,6 @@ class AsyncTeleBot: if not process_update: continue for i in signature(handler['function']).parameters: params.append(i) - result = None if len(params) == 1: result = await handler['function'](message) elif "data" in params: @@ -2059,8 +2058,7 @@ class AsyncTeleBot: """ This class sets webhooks and listens to a given url and port. - :param listen: IP address to listen to. Defaults to - 0.0.0.0 + :param listen: IP address to listen to. Defaults to 0.0.0.0 :param port: A port which will be used to listen to webhooks. :param url_path: Path to the webhook. Defaults to /token :param certificate: Path to the certificate file. @@ -2072,6 +2070,8 @@ class AsyncTeleBot: :param drop_pending_updates: Pass True to drop all pending updates :param timeout: Integer. Request connection timeout :param secret_token: Secret token to be used to verify the webhook request. + :param secret_token_length: Length of a secret token, defaults to 20 + :param debug: Debug mode, defaults to False :return: """ @@ -2079,12 +2079,9 @@ class AsyncTeleBot: if not secret_token: secret_token = ''.join(random.choices(string.ascii_uppercase + string.digits, k=secret_token_length)) - if not url_path: url_path = self.token + '/' if url_path[-1] != '/': url_path += '/' - - protocol = "https" if certificate else "http" if not webhook_url: @@ -2093,8 +2090,6 @@ class AsyncTeleBot: if certificate and certificate_key: ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) ssl_ctx.load_cert_chain(certificate, certificate_key) - else: - ssl_ctx = None # open certificate if it exists cert_file = open(certificate, 'rb') if certificate else None @@ -2755,7 +2750,7 @@ class AsyncTeleBot: 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 - :type thumbnail: :obj:`str` + :type thumbnail: :obj:`str` or :class:`telebot.types.InputFile` :param caption_entities: A JSON-serialized 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` @@ -2769,6 +2764,9 @@ class AsyncTeleBot: :param message_thread_id: Identifier of a message thread, in which the message will be sent :type message_thread_id: :obj:`int` + :param thumb: Deprecated. Use thumbnail instead + :type thumb: :obj:`str` or :class:`telebot.types.InputFile` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -2934,6 +2932,9 @@ class AsyncTeleBot: :param message_thread_id: Identifier of a message thread, in which the message will be sent :type message_thread_id: :obj:`int` + :param thumb: Deprecated. Use thumbnail instead + :type thumb: :obj:`str` or :class:`telebot.types.InputFile` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -2944,17 +2945,18 @@ class AsyncTeleBot: if data and not(document): # function typo miss compatibility + logger.warning('The parameter "data" is deprecated. Use "document" instead.') document = data if thumb is not None and thumbnail is None: thumbnail = thumb - logger.warning('thumb is deprecated, use thumbnail instead') + logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.') return types.Message.de_json( await asyncio_helper.send_data( self.token, chat_id, document, 'document', reply_to_message_id = reply_to_message_id, reply_markup = reply_markup, parse_mode = parse_mode, - disable_notification = disable_notification, timeout = timeout, caption = caption, thumb = thumbnail, + disable_notification = disable_notification, timeout = timeout, caption = caption, thumbnail= thumbnail, caption_entities = caption_entities, allow_sending_without_reply = allow_sending_without_reply, disable_content_type_detection = disable_content_type_detection, visible_file_name = visible_file_name, protect_content = protect_content, message_thread_id = message_thread_id)) @@ -3021,7 +3023,7 @@ class AsyncTeleBot: if data and not(sticker): # function typo miss compatibility - logger.warning("send_sticker: data parameter is deprecated. Use sticker instead.") + logger.warning('The parameter "data" is deprecated. Use "sticker" instead.') sticker = data return types.Message.de_json( @@ -3116,6 +3118,9 @@ class AsyncTeleBot: :param has_spoiler: Pass True, if the video should be sent as a spoiler :type has_spoiler: :obj:`bool` + :param thumb: Deprecated. Use thumbnail instead + :type thumb: :obj:`str` or :class:`telebot.types.InputFile` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -3126,11 +3131,11 @@ class AsyncTeleBot: if data and not(video): # function typo miss compatibility - logger.warning("send_sticker: data parameter is deprecated. Use video instead.") + logger.warning('The parameter "data" is deprecated. Use "video" instead.') video = data if thumb and not(thumbnail): - logger.warning("send_sticker: thumb parameter is deprecated. Use thumbnail instead.") + logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.') thumbnail = thumb return types.Message.de_json( @@ -3220,6 +3225,9 @@ class AsyncTeleBot: :param has_spoiler: Pass True, if the animation should be sent as a spoiler :type has_spoiler: :obj:`bool` + :param thumb: Deprecated. Use thumbnail instead + :type thumb: :obj:`str` or :class:`telebot.types.InputFile` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -3230,7 +3238,7 @@ class AsyncTeleBot: if thumb is not None and thumbnail is None: thumbnail = thumb - logger.warning('thumb is deprecated, use thumbnail instead') + logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.') return types.Message.de_json( await asyncio_helper.send_animation( @@ -3299,6 +3307,9 @@ class AsyncTeleBot: :param message_thread_id: Identifier of a message thread, in which the video note will be sent :type message_thread_id: :obj:`int` + :param thumb: Deprecated. Use thumbnail instead + :type thumb: :obj:`str` or :class:`telebot.types.InputFile` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -3308,7 +3319,7 @@ class AsyncTeleBot: if thumb is not None and thumbnail is None: thumbnail = thumb - logger.warning('thumb is deprecated, use thumbnail instead') + logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.') return types.Message.de_json( await asyncio_helper.send_video_note( @@ -3881,9 +3892,7 @@ class AsyncTeleBot: can_invite_users=can_invite_users, can_pin_messages=can_pin_messages ) - logger.warning( - "Individual parameters are deprecated and will be removed, use 'permissions' instead." - ) + logger.warning('The parameters "can_..." are deprecated, use "permissions" instead.') return await asyncio_helper.restrict_chat_member( self.token, chat_id, user_id, permissions, until_date, use_independent_chat_permissions) @@ -3967,7 +3976,7 @@ class AsyncTeleBot: """ if can_manage_voice_chats is not None: - logger.warning("promote_chat_member: can_manage_voice_chats parameter is deprecated. Use can_manage_video_chats instead.") + logger.warning('The parameter "can_manage_voice_chats" is deprecated. Use "can_manage_video_chats" instead.') if can_manage_video_chats is None: can_manage_video_chats = can_manage_voice_chats @@ -5401,8 +5410,7 @@ class AsyncTeleBot: """ return await asyncio_helper.answer_callback_query(self.token, callback_query_id, text, show_alert, url, cache_time) - async def set_sticker_set_thumbnail( - self, name: str, user_id: int, thumb: Union[Any, str]=None): + async def set_sticker_set_thumbnail(self, name: str, user_id: int, thumbnail: Union[Any, str]=None): """ 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. @@ -5415,16 +5423,16 @@ class AsyncTeleBot: :param user_id: User identifier :type user_id: :obj:`int` - :param thumb: - :type thumb: :obj:`filelike object` + :param thumbnail: A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical requirements), or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-sticker-requirements for video sticker technical requirements. 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. More information on Sending Files ». Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. + :type thumbnail: :obj:`filelike object` :return: On success, True is returned. :rtype: :obj:`bool` """ - return await asyncio_helper.set_sticker_set_thumb(self.token, name, user_id, thumb) + return await asyncio_helper.set_sticker_set_thumbnail(self.token, name, user_id, thumbnail) - async def set_sticker_set_thumb( - self, name: str, user_id: int, thumb: Union[Any, str]=None): + @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. Animated thumbnails can be set for animated sticker sets only. Returns True on success. @@ -5444,8 +5452,7 @@ class AsyncTeleBot: :rtype: :obj:`bool` """ # deprecated - logger.warning('set_sticker_set_thumb is deprecated, use set_sticker_set_thumbnail instead') - return await asyncio_helper.set_sticker_set_thumb(self.token, name, user_id, thumb) + return await self.set_sticker_set_thumbnail(name, user_id, thumb) async def get_sticker_set(self, name: str) -> types.StickerSet: """ @@ -5535,7 +5542,7 @@ class AsyncTeleBot: :rtype: :class:`telebot.types.File` """ if png_sticker: - logger.warning("png_sticker is deprecated, use sticker instead", DeprecationWarning) + logger.warning('The parameter "png_sticker" is deprecated. Use "sticker" instead.') sticker = png_sticker sticker_format = "static" @@ -5609,7 +5616,7 @@ class AsyncTeleBot: async def create_new_sticker_set( self, user_id: int, name: str, title: str, - emojis: Optional[str]=None, + emojis: Optional[List[str]]=None, png_sticker: Union[Any, str]=None, tgs_sticker: Union[Any, str]=None, webm_sticker: Union[Any, str]=None, @@ -5757,10 +5764,7 @@ class AsyncTeleBot: if sticker is None: old_sticker = png_sticker or tgs_sticker or webm_sticker if old_sticker is not None: - logger.warning( - 'Parameters "png_sticker", "tgs_sticker", "webm_sticker", "emojis" and "mask_position" are deprecated, ' - 'use "sticker" instead' - ) + logger.warning('The parameters "..._sticker", "emojis" and "mask_position" are deprecated, use "sticker" instead') if not old_sticker: raise ValueError('You must pass at least one sticker.') sticker = types.InputSticker(old_sticker, emojis, mask_position) diff --git a/telebot/asyncio_helper.py b/telebot/asyncio_helper.py index 0494f27..6f7ef0f 100644 --- a/telebot/asyncio_helper.py +++ b/telebot/asyncio_helper.py @@ -173,6 +173,7 @@ async def get_file_url(token, file_id): if FILE_URL is None: return "https://api.telegram.org/file/bot{0}/{1}".format(token, (await get_file(token, file_id))['file_path']) else: + # noinspection PyUnresolvedReferences return FILE_URL.format(token, (await get_file(token, file_id))['file_path']) @@ -180,6 +181,7 @@ async def download_file(token, file_path): if FILE_URL is None: url = "https://api.telegram.org/file/bot{0}/{1}".format(token, file_path) else: + # noinspection PyUnresolvedReferences url = FILE_URL.format(token, file_path) session = await session_manager.get_session() async with session.get(url, proxy=proxy) as response: @@ -341,15 +343,15 @@ async def get_chat_member_count(token, chat_id): return await _process_request(token, method_url, params=payload) -async def set_sticker_set_thumb(token, name, user_id, thumb): +async def set_sticker_set_thumbnail(token, name, user_id, thumbnail): method_url = r'setStickerSetThumbnail' payload = {'name': name, 'user_id': user_id} files = {} - if thumb: - if not isinstance(thumb, str): - files['thumb'] = thumb + if thumbnail: + if not isinstance(thumbnail, str): + files['thumbnail'] = thumbnail else: - payload['thumb'] = thumb + payload['thumbnail'] = thumbnail return await _process_request(token, method_url, params=payload, files=files or None) @@ -660,9 +662,9 @@ async def send_chat_action(token, chat_id, action, timeout=None, message_thread_ async def send_video(token, chat_id, data, duration=None, caption=None, reply_to_message_id=None, reply_markup=None, - parse_mode=None, supports_streaming=None, disable_notification=None, timeout=None, - thumb=None, width=None, height=None, caption_entities=None, allow_sending_without_reply=None, - protect_content=None, message_thread_id=None, has_spoiler=None): + parse_mode=None, supports_streaming=None, disable_notification=None, timeout=None, + thumbnail=None, width=None, height=None, caption_entities=None, allow_sending_without_reply=None, + protect_content=None, message_thread_id=None, has_spoiler=None): method_url = r'sendVideo' payload = {'chat_id': chat_id} files = None @@ -686,14 +688,14 @@ async def send_video(token, chat_id, data, duration=None, caption=None, reply_to payload['disable_notification'] = disable_notification if timeout: payload['timeout'] = timeout - if thumb: - if not util.is_string(thumb): + if thumbnail: + if not util.is_string(thumbnail): if files: - files['thumbnail'] = thumb + files['thumbnail'] = thumbnail else: - files = {'thumbnail': thumb} + files = {'thumbnail': thumbnail} else: - payload['thumbnail'] = thumb + payload['thumbnail'] = thumbnail if width: payload['width'] = width if height: @@ -713,7 +715,7 @@ async def send_video(token, chat_id, data, duration=None, caption=None, reply_to async def send_animation( token, chat_id, data, duration=None, caption=None, reply_to_message_id=None, reply_markup=None, - parse_mode=None, disable_notification=None, timeout=None, thumb=None, caption_entities=None, + parse_mode=None, disable_notification=None, timeout=None, thumbnail=None, caption_entities=None, allow_sending_without_reply=None, width=None, height=None, protect_content=None, message_thread_id=None, has_spoiler=None): method_url = r'sendAnimation' @@ -737,14 +739,14 @@ async def send_animation( payload['disable_notification'] = disable_notification if timeout: payload['timeout'] = timeout - if thumb: - if not util.is_string(thumb): + if thumbnail: + if not util.is_string(thumbnail): if files: - files['thumbnail'] = thumb + files['thumbnail'] = thumbnail else: - files = {'thumbnail': thumb} + files = {'thumbnail': thumbnail} else: - payload['thumbnail'] = thumb + payload['thumbnail'] = thumbnail if caption_entities: payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities)) if allow_sending_without_reply is not None: @@ -798,8 +800,8 @@ async def send_voice(token, chat_id, voice, caption=None, duration=None, reply_t async def send_video_note(token, chat_id, data, duration=None, length=None, reply_to_message_id=None, reply_markup=None, - disable_notification=None, timeout=None, thumb=None, allow_sending_without_reply=None, protect_content=None, - message_thread_id=None): + disable_notification=None, timeout=None, thumbnail=None, allow_sending_without_reply=None, protect_content=None, + message_thread_id=None): method_url = r'sendVideoNote' payload = {'chat_id': chat_id} files = None @@ -821,14 +823,14 @@ async def send_video_note(token, chat_id, data, duration=None, length=None, repl payload['disable_notification'] = disable_notification if timeout: payload['timeout'] = timeout - if thumb: - if not util.is_string(thumb): + if thumbnail: + if not util.is_string(thumbnail): if files: - files['thumbnail'] = thumb + files['thumbnail'] = thumbnail else: - files = {'thumbnail': thumb} + files = {'thumbnail': thumbnail} else: - payload['thumbnail'] = thumb + payload['thumbnail'] = thumbnail if allow_sending_without_reply is not None: payload['allow_sending_without_reply'] = allow_sending_without_reply if protect_content is not None: @@ -839,8 +841,8 @@ async def send_video_note(token, chat_id, data, duration=None, length=None, repl async def send_audio(token, chat_id, audio, caption=None, duration=None, performer=None, title=None, reply_to_message_id=None, - reply_markup=None, parse_mode=None, disable_notification=None, timeout=None, thumb=None, - caption_entities=None, allow_sending_without_reply=None, protect_content=None, message_thread_id=None): + reply_markup=None, parse_mode=None, disable_notification=None, timeout=None, thumbnail=None, + caption_entities=None, allow_sending_without_reply=None, protect_content=None, message_thread_id=None): method_url = r'sendAudio' payload = {'chat_id': chat_id} files = None @@ -866,14 +868,14 @@ async def send_audio(token, chat_id, audio, caption=None, duration=None, perform payload['disable_notification'] = disable_notification if timeout: payload['timeout'] = timeout - if thumb: - if not util.is_string(thumb): + if thumbnail: + if not util.is_string(thumbnail): if files: - files['thumbnail'] = thumb + files['thumbnail'] = thumbnail else: - files = {'thumbnail': thumb} + files = {'thumbnail': thumbnail} else: - payload['thumbnail'] = thumb + payload['thumbnail'] = thumbnail if caption_entities: payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities)) if allow_sending_without_reply is not None: @@ -886,9 +888,9 @@ async def send_audio(token, chat_id, audio, caption=None, duration=None, perform async def send_data(token, chat_id, data, data_type, reply_to_message_id=None, reply_markup=None, parse_mode=None, - disable_notification=None, timeout=None, caption=None, thumb=None, caption_entities=None, - allow_sending_without_reply=None, disable_content_type_detection=None, visible_file_name=None, protect_content=None, - message_thread_id=None, emoji=None): + disable_notification=None, timeout=None, caption=None, thumbnail=None, caption_entities=None, + allow_sending_without_reply=None, disable_content_type_detection=None, visible_file_name=None, protect_content=None, + message_thread_id=None, emoji=None): method_url = await get_method_by_type(data_type) payload = {'chat_id': chat_id} files = None @@ -911,14 +913,14 @@ async def send_data(token, chat_id, data, data_type, reply_to_message_id=None, r payload['timeout'] = timeout if caption: payload['caption'] = caption - if thumb: - if not util.is_string(thumb): + if thumbnail: + if not util.is_string(thumbnail): if files: - files['thumbnail'] = thumb + files['thumbnail'] = thumbnail else: - files = {'thumbnail': thumb} + files = {'thumbnail': thumbnail} else: - payload['thumbnail'] = thumb + payload['thumbnail'] = thumbnail if caption_entities: payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities)) if allow_sending_without_reply is not None: @@ -1433,8 +1435,8 @@ async def send_invoice( need_name=None, need_phone_number=None, need_email=None, need_shipping_address=None, send_phone_number_to_provider = None, send_email_to_provider = None, is_flexible=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, provider_data=None, - timeout=None, allow_sending_without_reply=None, max_tip_amount=None, suggested_tip_amounts=None, protect_content=None, - message_thread_id=None): + timeout=None, allow_sending_without_reply=None, max_tip_amount=None, suggested_tip_amounts=None, + protect_content=None, message_thread_id=None): """ Use this method to send invoices. On success, the sent Message is returned. :param token: Bot's token (you don't need to fill this) @@ -1466,7 +1468,8 @@ async def send_invoice( :param max_tip_amount: The maximum accepted amount for tips in the smallest units of the currency :param suggested_tip_amounts: A JSON-serialized array of suggested amounts of tips in the smallest units of the currency. At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount. - :param protect_content: + :param protect_content: Protects the contents of the sent message from forwarding and saving + :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :return: """ method_url = r'sendInvoice' diff --git a/telebot/types.py b/telebot/types.py index 96d526e..58fc07b 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -1578,8 +1578,12 @@ class Audio(JsonDeserializable): self.file_name: str = file_name self.mime_type: str = mime_type self.file_size: int = file_size - self.thumbnail: PhotoSize = thumbnail - self.thumb = thumbnail + self.thumbnail: PhotoSize = thumbnail + + @property + def thumb(self): + logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead') + return self.thumbnail class Voice(JsonDeserializable): @@ -1670,7 +1674,11 @@ class Document(JsonDeserializable): self.file_name: str = file_name self.mime_type: str = mime_type self.file_size: int = file_size - self.thumb = thumbnail + + @property + def thumb(self): + logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead') + return self.thumbnail class Video(JsonDeserializable): @@ -1730,7 +1738,11 @@ class Video(JsonDeserializable): self.file_name: str = file_name self.mime_type: str = mime_type self.file_size: int = file_size - self.thumb = thumbnail + + @property + def thumb(self): + logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead') + return self.thumbnail class VideoNote(JsonDeserializable): @@ -1776,7 +1788,11 @@ class VideoNote(JsonDeserializable): self.duration: int = duration self.thumbnail: PhotoSize = thumbnail self.file_size: int = file_size - self.thumb = thumbnail + + @property + def thumb(self): + logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead') + return self.thumbnail class Contact(JsonDeserializable): @@ -4016,10 +4032,20 @@ class InlineQueryResultArticle(InlineQueryResultBase): self.thumbnail_width = thumbnail_width self.thumbnail_height = thumbnail_height - # deprecateds - self.thumb_url = thumbnail_url - self.thumb_width = thumbnail_width - self.thumb_height = thumbnail_height + @property + def thumb_url(self): + logger.warning('The parameter "thumb_url" is deprecated, use "thumbnail_url" instead') + return self.thumbnail_url + + @property + def thumb_width(self): + logger.warning('The parameter "thumb_width" is deprecated, use "thumbnail_width" instead') + return self.thumbnail_width + + @property + def thumb_height(self): + logger.warning('The parameter "thumb_height" is deprecated, use "thumbnail_height" instead') + return self.thumbnail_height def to_dict(self): json_dict = super().to_dict() @@ -4031,9 +4057,9 @@ class InlineQueryResultArticle(InlineQueryResultBase): json_dict['description'] = self.description if self.thumbnail_url: json_dict['thumbnail_url'] = self.thumbnail_url - if self.thumb_width: + if self.thumbnail_width: json_dict['thumbnail_width'] = self.thumbnail_width - if self.thumb_height: + if self.thumbnail_height: json_dict['thumbnail_height'] = self.thumbnail_height return json_dict @@ -4099,8 +4125,10 @@ class InlineQueryResultPhoto(InlineQueryResultBase): self.photo_height = photo_height self.description = description - # deprecateds - self.thumb_url = thumbnail_url + @property + def thumb_url(self): + logger.warning('The parameter "thumb_url" is deprecated, use "thumbnail_url" instead') + return self.thumbnail_url def to_dict(self): json_dict = super().to_dict() @@ -4182,9 +4210,15 @@ class InlineQueryResultGif(InlineQueryResultBase): self.gif_duration = gif_duration self.thumbnail_mime_type = thumbnail_mime_type - # deprecateds - self.thumb_url = thumbnail_url - self.thumb_mime_type = thumbnail_mime_type + @property + def thumb_url(self): + logger.warning('The parameter "thumb_url" is deprecated, use "thumbnail_url" instead') + return self.thumbnail_url + + @property + def thumb_mime_type(self): + logger.warning('The parameter "thumb_mime_type" is deprecated, use "thumbnail_mime_type" instead') + return self.thumbnail_mime_type def to_dict(self): json_dict = super().to_dict() @@ -4268,9 +4302,15 @@ class InlineQueryResultMpeg4Gif(InlineQueryResultBase): self.mpeg4_duration = mpeg4_duration self.thumbnail_mime_type = thumbnail_mime_type - # deprecateds - self.thumb_url = thumbnail_url - self.thumb_mime_type = thumbnail_mime_type + @property + def thumb_url(self): + logger.warning('The parameter "thumb_url" is deprecated, use "thumbnail_url" instead') + return self.thumbnail_url + + @property + def thumb_mime_type(self): + logger.warning('The parameter "thumb_mime_type" is deprecated, use "thumbnail_mime_type" instead') + return self.thumbnail_mime_type def to_dict(self): json_dict = super().to_dict() @@ -4359,8 +4399,10 @@ class InlineQueryResultVideo(InlineQueryResultBase): self.video_duration = video_duration self.description = description - # deprecated - self.thumb_url = thumbnail_url + @property + def thumb_url(self): + logger.warning('The parameter "thumb_url" is deprecated, use "thumbnail_url" instead') + return self.thumbnail_url def to_dict(self): json_dict = super().to_dict() @@ -4563,11 +4605,20 @@ class InlineQueryResultDocument(InlineQueryResultBase): self.thumbnail_width = thumbnail_width self.thumbnail_height = thumbnail_height - # deprecated - self.thumb_url = thumbnail_url - self.thumb_width = thumbnail_width - self.thumb_height = thumbnail_height + @property + def thumb_url(self): + logger.warning('The parameter "thumb_url" is deprecated, use "thumbnail_url" instead') + return self.thumbnail_url + @property + def thumb_width(self): + logger.warning('The parameter "thumb_width" is deprecated, use "thumbnail_width" instead') + return self.thumbnail_width + + @property + def thumb_height(self): + logger.warning('The parameter "thumb_height" is deprecated, use "thumbnail_height" instead') + return self.thumbnail_height def to_dict(self): json_dict = super().to_dict() @@ -4652,10 +4703,20 @@ class InlineQueryResultLocation(InlineQueryResultBase): self.thumbnail_width = thumbnail_width self.thumbnail_height = thumbnail_height - # deprecated - self.thumb_url = thumbnail_url - self.thumb_width = thumbnail_width - self.thumb_height = thumbnail_height + @property + def thumb_url(self): + logger.warning('The parameter "thumb_url" is deprecated, use "thumbnail_url" instead') + return self.thumbnail_url + + @property + def thumb_width(self): + logger.warning('The parameter "thumb_width" is deprecated, use "thumbnail_width" instead') + return self.thumbnail_width + + @property + def thumb_height(self): + logger.warning('The parameter "thumb_height" is deprecated, use "thumbnail_height" instead') + return self.thumbnail_height def to_dict(self): json_dict = super().to_dict() @@ -4749,11 +4810,20 @@ class InlineQueryResultVenue(InlineQueryResultBase): self.thumbnail_width = thumbnail_width self.thumbnail_height = thumbnail_height - # deprecated - self.thumb_url = thumbnail_url - self.thumb_width = thumbnail_width - self.thumb_height = thumbnail_height - + @property + def thumb_url(self): + logger.warning('The parameter "thumb_url" is deprecated, use "thumbnail_url" instead') + return self.thumbnail_url + + @property + def thumb_width(self): + logger.warning('The parameter "thumb_width" is deprecated, use "thumbnail_width" instead') + return self.thumbnail_width + + @property + def thumb_height(self): + logger.warning('The parameter "thumb_height" is deprecated, use "thumbnail_height" instead') + return self.thumbnail_height def to_dict(self): json_dict = super().to_dict() @@ -4832,12 +4902,20 @@ class InlineQueryResultContact(InlineQueryResultBase): self.thumbnail_width = thumbnail_width self.thumbnail_height = thumbnail_height - # deprecated - self.thumb_url = thumbnail_url - self.thumb_width = thumbnail_width - self.thumb_height = thumbnail_height + @property + def thumb_url(self): + logger.warning('The parameter "thumb_url" is deprecated, use "thumbnail_url" instead') + return self.thumbnail_url - + @property + def thumb_width(self): + logger.warning('The parameter "thumb_width" is deprecated, use "thumbnail_width" instead') + return self.thumbnail_width + + @property + def thumb_height(self): + logger.warning('The parameter "thumb_height" is deprecated, use "thumbnail_height" instead') + return self.thumbnail_height def to_dict(self): json_dict = super().to_dict() @@ -5471,11 +5549,15 @@ class Animation(JsonDeserializable): self.height: int = height self.duration: int = duration self.thumbnail: PhotoSize = thumbnail - self.thumb: PhotoSize = thumbnail self.file_name: str = file_name self.mime_type: str = mime_type self.file_size: int = file_size + @property + def thumb(self): + logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead') + return self.thumbnail + class GameHighScore(JsonDeserializable): """ @@ -5895,7 +5977,11 @@ class StickerSet(JsonDeserializable): self.is_video: bool = is_video self.stickers: List[Sticker] = stickers self.thumbnail: PhotoSize = thumbnail - self.thumb = thumbnail + + @property + def thumb(self): + logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead') + return self.thumbnail @property def contains_masks(self): @@ -5997,8 +6083,11 @@ class Sticker(JsonDeserializable): self.premium_animation: File = premium_animation self.custom_emoji_id: int = custom_emoji_id self.needs_repainting: bool = needs_repainting - self.thumb = self.thumbnail - + + @property + def thumb(self): + logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead') + return self.thumbnail class MaskPosition(Dictionaryable, JsonDeserializable, JsonSerializable): @@ -6195,7 +6284,11 @@ class InputMediaVideo(InputMedia): self.duration = duration self.supports_streaming = supports_streaming self.has_spoiler: Optional[bool] = has_spoiler - self.thumb = thumbnail + + @property + def thumb(self): + logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead') + return self.thumbnail def to_dict(self): ret = super(InputMediaVideo, self).to_dict() @@ -6225,12 +6318,12 @@ class InputMediaAnimation(InputMedia): multipart/form-data under name. More information on Sending Files » :type media: :obj:`str` - :param thumb: Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported + :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 thumb: InputFile or :obj:`str` + :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` @@ -6267,7 +6360,11 @@ class InputMediaAnimation(InputMedia): self.height = height self.duration = duration self.has_spoiler: Optional[bool] = has_spoiler - self.thumb = thumbnail + + @property + def thumb(self): + logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead') + return self.thumbnail def to_dict(self): ret = super(InputMediaAnimation, self).to_dict() @@ -6333,7 +6430,11 @@ class InputMediaAudio(InputMedia): self.duration = duration self.performer = performer self.title = title - self.thumb = thumbnail + + @property + def thumb(self): + logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead') + return self.thumbnail def to_dict(self): ret = super(InputMediaAudio, self).to_dict() @@ -6390,7 +6491,11 @@ class InputMediaDocument(InputMedia): type="document", media=media, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities) self.thumbnail = thumbnail self.disable_content_type_detection = disable_content_type_detection - self.thumb = thumbnail + + @property + def thumb(self): + logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead') + return self.thumbnail def to_dict(self): ret = super(InputMediaDocument, self).to_dict()