Fixes regarding contains_masks

This commit is contained in:
_run 2022-08-13 13:22:25 +05:00
parent 737c3a439d
commit dd4073fd74
5 changed files with 24 additions and 11 deletions

View File

@ -4279,9 +4279,14 @@ class TeleBot:
:return: On success, True is returned.
:rtype: :obj:`bool`
"""
if contains_masks is not None:
logger.warning('The parameter "contains_masks" is deprecated, use "sticker_type" instead')
if sticker_type is None:
sticker_type = 'mask'
return apihelper.create_new_sticker_set(
self.token, user_id, name, title, emojis, png_sticker, tgs_sticker,
contains_masks, mask_position, webm_sticker, sticker_type)
mask_position, webm_sticker, sticker_type)
def add_sticker_to_set(
self, user_id: int, name: str, emojis: str,

View File

@ -1574,7 +1574,7 @@ def upload_sticker_file(token, user_id, png_sticker):
def create_new_sticker_set(
token, user_id, name, title, emojis, png_sticker, tgs_sticker,
contains_masks=None, mask_position=None, webm_sticker=None, sticker_type=None):
mask_position=None, webm_sticker=None, sticker_type=None):
method_url = 'createNewStickerSet'
payload = {'user_id': user_id, 'name': name, 'title': title, 'emojis': emojis}
if png_sticker:
@ -1589,8 +1589,6 @@ def create_new_sticker_set(
files = {stype: sticker}
else:
payload[stype] = sticker
if contains_masks is not None:
payload['contains_masks'] = contains_masks
if mask_position:
payload['mask_position'] = mask_position.to_json()
if webm_sticker:

View File

@ -5117,9 +5117,14 @@ class AsyncTeleBot:
:return: On success, True is returned.
:rtype: :obj:`bool`
"""
if contains_masks is not None:
logger.warning('The parameter "contains_masks" is deprecated, use "sticker_type" instead')
if sticker_type is None:
sticker_type = 'mask'
return await asyncio_helper.create_new_sticker_set(
self.token, user_id, name, title, emojis, png_sticker, tgs_sticker,
contains_masks, mask_position, webm_sticker, sticker_type)
mask_position, webm_sticker, sticker_type)
async def add_sticker_to_set(

View File

@ -1545,7 +1545,7 @@ async def upload_sticker_file(token, user_id, png_sticker):
async def create_new_sticker_set(
token, user_id, name, title, emojis, png_sticker, tgs_sticker,
contains_masks=None, mask_position=None, webm_sticker=None, sticker_type=None):
mask_position=None, webm_sticker=None, sticker_type=None):
method_url = 'createNewStickerSet'
payload = {'user_id': user_id, 'name': name, 'title': title, 'emojis': emojis}
if png_sticker:
@ -1560,8 +1560,6 @@ async def create_new_sticker_set(
files = {stype: sticker}
else:
payload[stype] = sticker
if contains_masks is not None:
payload['contains_masks'] = contains_masks
if mask_position:
payload['mask_position'] = mask_position.to_json()
if webm_sticker:

View File

@ -1275,7 +1275,7 @@ class MessageEntity(Dictionaryable, JsonSerializable, JsonDeserializable):
:type language: :obj:`str`
:param custom_emoji_id: Optional. For custom_emoji only, unique identifier of the custom emoji.
Use getCustomEmojiStickers to get full information about the sticker.
Use get_custom_emoji_stickers to get full information about the sticker.
:type custom_emoji_id: :obj:`str`
:return: Instance of the class
@ -5486,16 +5486,23 @@ class StickerSet(JsonDeserializable):
obj['thumb'] = None
return cls(**obj)
def __init__(self, name, title, sticker_type, is_animated, is_video, contains_masks, stickers, thumb=None, **kwargs):
def __init__(self, name, title, sticker_type, is_animated, is_video, stickers, thumb=None, **kwargs):
self.name: str = name
self.title: str = title
self.sticker_type: str = sticker_type
self.is_animated: bool = is_animated
self.is_video: bool = is_video
self.contains_masks: bool = contains_masks
self.stickers: List[Sticker] = stickers
self.thumb: PhotoSize = thumb
@property
def contains_masks(self):
"""
Deprecated since Bot API 6.2, use sticker_type instead.
"""
logger.warning("contains_masks is deprecated, use sticker_type instead")
return self.sticker_type == 'mask'
class Sticker(JsonDeserializable):
"""