1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Deprecation warnings equalisation

This commit is contained in:
Badiboy 2023-03-25 15:17:29 +03:00
parent b0740a920a
commit c9ef0d71f0
3 changed files with 34 additions and 40 deletions

View File

@ -1028,7 +1028,7 @@ class TeleBot:
:return: :return:
""" """
if none_stop is not None: 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 non_stop = none_stop
if skip_pending: if skip_pending:
@ -1918,7 +1918,7 @@ class TeleBot:
if thumb is not None and thumbnail is None: if thumb is not None and thumbnail is None:
thumbnail = thumb thumbnail = thumb
logger.warning('"thumb" param is deprecated, use "thumbnail" param instead') logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.')
return types.Message.de_json( return types.Message.de_json(
apihelper.send_audio( apihelper.send_audio(
@ -2086,11 +2086,12 @@ class TeleBot:
if data and not(document): if data and not(document):
# function typo miss compatibility # function typo miss compatibility
logger.warning('The parameter "data" is deprecated. Use "document" instead.')
document = data document = data
if thumb is not None and thumbnail is None: if thumb is not None and thumbnail is None:
thumbnail = thumb thumbnail = thumb
logger.warning('"thumb" param is deprecated, use "thumbnail" param instead') logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.')
return types.Message.de_json( return types.Message.de_json(
apihelper.send_data( apihelper.send_data(
@ -2166,6 +2167,7 @@ class TeleBot:
if data and not(sticker): if data and not(sticker):
# function typo miss compatibility # function typo miss compatibility
logger.warning('The parameter "data" is deprecated. Use "sticker" instead.')
sticker = data sticker = data
return types.Message.de_json( return types.Message.de_json(
@ -2272,11 +2274,12 @@ class TeleBot:
if data and not(video): if data and not(video):
# function typo miss compatibility # function typo miss compatibility
logger.warning('The parameter "data" is deprecated. Use "video" instead.')
video = data video = data
if thumb is not None and thumbnail is None: if thumb is not None and thumbnail is None:
thumbnail = thumb thumbnail = thumb
logger.warning('"thumb" param is deprecated, use "thumbnail" param instead') logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.')
return types.Message.de_json( return types.Message.de_json(
apihelper.send_video( apihelper.send_video(
@ -3033,9 +3036,7 @@ class TeleBot:
can_invite_users=can_invite_users, can_invite_users=can_invite_users,
can_pin_messages=can_pin_messages can_pin_messages=can_pin_messages
) )
logger.warning( logger.warning('The parameters "can_..." are deprecated, use "permissions" instead.')
"Individual parameters are deprecated and will be removed, use 'permissions' instead."
)
return apihelper.restrict_chat_member( return apihelper.restrict_chat_member(
self.token, chat_id, user_id, permissions, until_date, use_independent_chat_permissions) self.token, chat_id, user_id, permissions, until_date, use_independent_chat_permissions)
@ -3118,7 +3119,7 @@ class TeleBot:
:rtype: :obj:`bool` :rtype: :obj:`bool`
""" """
if can_manage_voice_chats is not None: 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: if can_manage_video_chats is None:
can_manage_video_chats = can_manage_voice_chats can_manage_video_chats = can_manage_voice_chats
@ -4745,7 +4746,7 @@ class TeleBot:
:rtype: :class:`telebot.types.File` :rtype: :class:`telebot.types.File`
""" """
if png_sticker: 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 = png_sticker
sticker_format = "static" sticker_format = "static"
@ -4903,10 +4904,7 @@ class TeleBot:
if sticker is None: if sticker is None:
old_sticker = png_sticker or tgs_sticker or webm_sticker old_sticker = png_sticker or tgs_sticker or webm_sticker
if old_sticker is not None: if old_sticker is not None:
logger.warning( logger.warning('The parameters "..._sticker", "emojis" and "mask_position" are deprecated, use "sticker" instead')
'The parameters "png_sticker", "tgs_sticker", "webm_sticker", "emojis" and "mask_position" are deprecated, '
'use "sticker" instead'
)
if not old_sticker: if not old_sticker:
raise ValueError('You must pass at least one sticker.') raise ValueError('You must pass at least one sticker.')
sticker = types.InputSticker(old_sticker, emojis, mask_position) sticker = types.InputSticker(old_sticker, emojis, mask_position)

View File

@ -294,7 +294,7 @@ class AsyncTeleBot:
:return: :return:
""" """
if none_stop is not None: 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 non_stop = none_stop
if skip_pending: if skip_pending:
@ -2944,11 +2944,12 @@ class AsyncTeleBot:
if data and not(document): if data and not(document):
# function typo miss compatibility # function typo miss compatibility
logger.warning('The parameter "data" is deprecated. Use "document" instead.')
document = data document = data
if thumb is not None and thumbnail is None: if thumb is not None and thumbnail is None:
thumbnail = thumb thumbnail = thumb
logger.warning('"thumb" param is deprecated, use "thumbnail" param instead') logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.')
return types.Message.de_json( return types.Message.de_json(
await asyncio_helper.send_data( await asyncio_helper.send_data(
@ -3021,7 +3022,7 @@ class AsyncTeleBot:
if data and not(sticker): if data and not(sticker):
# function typo miss compatibility # 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 sticker = data
return types.Message.de_json( return types.Message.de_json(
@ -3128,11 +3129,11 @@ class AsyncTeleBot:
if data and not(video): if data and not(video):
# function typo miss compatibility # 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 video = data
if thumb and not(thumbnail): 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 thumbnail = thumb
return types.Message.de_json( return types.Message.de_json(
@ -3234,7 +3235,7 @@ class AsyncTeleBot:
if thumb is not None and thumbnail is None: if thumb is not None and thumbnail is None:
thumbnail = thumb thumbnail = thumb
logger.warning('"thumb" param is deprecated, use "thumbnail" param instead') logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.')
return types.Message.de_json( return types.Message.de_json(
await asyncio_helper.send_animation( await asyncio_helper.send_animation(
@ -3314,7 +3315,7 @@ class AsyncTeleBot:
if thumb is not None and thumbnail is None: if thumb is not None and thumbnail is None:
thumbnail = thumb thumbnail = thumb
logger.warning('"thumb" param is deprecated, use "thumbnail" param instead') logger.warning('The parameter "thumb" is deprecated. Use "thumbnail" instead.')
return types.Message.de_json( return types.Message.de_json(
await asyncio_helper.send_video_note( await asyncio_helper.send_video_note(
@ -3887,9 +3888,7 @@ class AsyncTeleBot:
can_invite_users=can_invite_users, can_invite_users=can_invite_users,
can_pin_messages=can_pin_messages can_pin_messages=can_pin_messages
) )
logger.warning( logger.warning('The parameters "can_..." are deprecated, use "permissions" instead.')
"Individual parameters are deprecated and will be removed, use 'permissions' instead."
)
return await asyncio_helper.restrict_chat_member( return await asyncio_helper.restrict_chat_member(
self.token, chat_id, user_id, permissions, until_date, use_independent_chat_permissions) self.token, chat_id, user_id, permissions, until_date, use_independent_chat_permissions)
@ -3973,7 +3972,7 @@ class AsyncTeleBot:
""" """
if can_manage_voice_chats is not None: 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: if can_manage_video_chats is None:
can_manage_video_chats = can_manage_voice_chats can_manage_video_chats = can_manage_voice_chats
@ -5539,7 +5538,7 @@ class AsyncTeleBot:
:rtype: :class:`telebot.types.File` :rtype: :class:`telebot.types.File`
""" """
if png_sticker: 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 = png_sticker
sticker_format = "static" sticker_format = "static"
@ -5761,10 +5760,7 @@ class AsyncTeleBot:
if sticker is None: if sticker is None:
old_sticker = png_sticker or tgs_sticker or webm_sticker old_sticker = png_sticker or tgs_sticker or webm_sticker
if old_sticker is not None: if old_sticker is not None:
logger.warning( logger.warning('The parameters "..._sticker", "emojis" and "mask_position" are deprecated, use "sticker" instead')
'Parameters "png_sticker", "tgs_sticker", "webm_sticker", "emojis" and "mask_position" are deprecated, '
'use "sticker" instead'
)
if not old_sticker: if not old_sticker:
raise ValueError('You must pass at least one sticker.') raise ValueError('You must pass at least one sticker.')
sticker = types.InputSticker(old_sticker, emojis, mask_position) sticker = types.InputSticker(old_sticker, emojis, mask_position)

View File

@ -1582,7 +1582,7 @@ class Audio(JsonDeserializable):
@property @property
def thumb(self): def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead') logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail return self.thumbnail
@ -1677,7 +1677,7 @@ class Document(JsonDeserializable):
@property @property
def thumb(self): def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead') logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail return self.thumbnail
@ -1741,7 +1741,7 @@ class Video(JsonDeserializable):
@property @property
def thumb(self): def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead') logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail return self.thumbnail
@ -1791,7 +1791,7 @@ class VideoNote(JsonDeserializable):
@property @property
def thumb(self): def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead') logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail return self.thumbnail
@ -5493,7 +5493,7 @@ class Animation(JsonDeserializable):
@property @property
def thumb(self): def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead') logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail return self.thumbnail
@ -5918,7 +5918,7 @@ class StickerSet(JsonDeserializable):
@property @property
def thumb(self): def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead') logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail return self.thumbnail
@property @property
@ -6024,7 +6024,7 @@ class Sticker(JsonDeserializable):
@property @property
def thumb(self): def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead') logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail return self.thumbnail
@ -6225,7 +6225,7 @@ class InputMediaVideo(InputMedia):
@property @property
def thumb(self): def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead') logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail return self.thumbnail
def to_dict(self): def to_dict(self):
@ -6301,7 +6301,7 @@ class InputMediaAnimation(InputMedia):
@property @property
def thumb(self): def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead') logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail return self.thumbnail
def to_dict(self): def to_dict(self):
@ -6371,7 +6371,7 @@ class InputMediaAudio(InputMedia):
@property @property
def thumb(self): def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead') logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail return self.thumbnail
def to_dict(self): def to_dict(self):
@ -6432,7 +6432,7 @@ class InputMediaDocument(InputMedia):
@property @property
def thumb(self): def thumb(self):
logger.warning('The property "thumb" is deprecated, use "thumbnail" instead') logger.warning('The parameter "thumb" is deprecated, use "thumbnail" instead')
return self.thumbnail return self.thumbnail
def to_dict(self): def to_dict(self):