mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Update tgs_sticker support
* Updated `create_new_sticker_set` and `add_sticker_to_set` functions * Removed `create_new_animated_sticker_set` and `add_sticker_to_animated_sticker_set` functions
This commit is contained in:
parent
c00595e212
commit
bffbe764e5
@ -2104,32 +2104,9 @@ class TeleBot:
|
|||||||
|
|
||||||
def create_new_sticker_set(
|
def create_new_sticker_set(
|
||||||
self, user_id: int, name: str, title: str,
|
self, user_id: int, name: str, title: str,
|
||||||
|
emojis: str,
|
||||||
png_sticker: Union[Any, str],
|
png_sticker: Union[Any, str],
|
||||||
emojis: str,
|
|
||||||
contains_masks: Optional[bool]=None,
|
|
||||||
mask_position: Optional[types.MaskPosition]=None) -> bool:
|
|
||||||
"""
|
|
||||||
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.
|
|
||||||
:param user_id:
|
|
||||||
:param name:
|
|
||||||
:param title:
|
|
||||||
:param png_sticker:
|
|
||||||
:param emojis:
|
|
||||||
:param contains_masks:
|
|
||||||
:param mask_position:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
return apihelper.create_new_sticker_set(
|
|
||||||
self.token, user_id, name, title, png_sticker, emojis,
|
|
||||||
contains_masks, mask_position, animated=False)
|
|
||||||
|
|
||||||
|
|
||||||
def create_new_animated_sticker_set(
|
|
||||||
self, user_id: int, name: str, title: str,
|
|
||||||
tgs_sticker: Union[Any, str],
|
tgs_sticker: Union[Any, str],
|
||||||
emojis: str,
|
|
||||||
contains_masks: Optional[bool]=None,
|
contains_masks: Optional[bool]=None,
|
||||||
mask_position: Optional[types.MaskPosition]=None) -> bool:
|
mask_position: Optional[types.MaskPosition]=None) -> bool:
|
||||||
"""
|
"""
|
||||||
@ -2139,47 +2116,37 @@ class TeleBot:
|
|||||||
:param user_id:
|
:param user_id:
|
||||||
:param name:
|
:param name:
|
||||||
:param title:
|
:param title:
|
||||||
:param tgs_sticker:
|
|
||||||
:param emojis:
|
:param emojis:
|
||||||
|
:param png_sticker:
|
||||||
|
:param tgs_sticker:
|
||||||
:param contains_masks:
|
:param contains_masks:
|
||||||
:param mask_position:
|
:param mask_position:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
return apihelper.create_new_sticker_set(
|
return apihelper.create_new_sticker_set(
|
||||||
self.token, user_id, name, title, tgs_sticker, emojis,
|
self.token, user_id, name, title, emojis, png_sticker, tgs_sticker,
|
||||||
contains_masks, mask_position, animated=True)
|
contains_masks, mask_position)
|
||||||
|
|
||||||
|
|
||||||
def add_sticker_to_set(
|
def add_sticker_to_set(
|
||||||
self, user_id: int, name: str, png_sticker: Union[Any, str],
|
self, user_id: int, name: str, emojis: str,
|
||||||
emojis: str, mask_position: Optional[types.MaskPosition]=None) -> bool:
|
png_sticker: Optional[Union[Any, str]]=None,
|
||||||
|
tgs_sticker: Optional[Union[Any, str]]=None,
|
||||||
|
mask_position: Optional[types.MaskPosition]=None) -> bool:
|
||||||
"""
|
"""
|
||||||
Use this method to add a new sticker to a set created by the bot. Returns True on success.
|
Use this method to add a new sticker to a set created by the bot.
|
||||||
|
It's required to pass `png_sticker` or `tgs_sticker`.
|
||||||
|
Returns True on success.
|
||||||
:param user_id:
|
:param user_id:
|
||||||
:param name:
|
:param name:
|
||||||
:param png_sticker:
|
|
||||||
:param emojis:
|
:param emojis:
|
||||||
|
:param png_sticker: Required if `tgs_sticker` is None
|
||||||
|
:param tgs_sticker: Required if `png_sticker` is None
|
||||||
:param mask_position:
|
:param mask_position:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
return apihelper.add_sticker_to_set(
|
return apihelper.add_sticker_to_set(
|
||||||
self.token, user_id, name, png_sticker, emojis, mask_position, animated=False)
|
self.token, user_id, name, emojis, png_sticker, tgs_sticker, mask_position)
|
||||||
|
|
||||||
|
|
||||||
def add_sticker_to_animated_set(
|
|
||||||
self, user_id: int, name: str, tgs_sticker: Union[Any, str],
|
|
||||||
emojis: str, mask_position: Optional[types.MaskPosition]=None) -> bool:
|
|
||||||
"""
|
|
||||||
Use this method to add a new sticker to a set created by the bot. Returns True on success.
|
|
||||||
:param user_id:
|
|
||||||
:param name:
|
|
||||||
:param tgs_sticker:
|
|
||||||
:param emojis:
|
|
||||||
:param mask_position:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
return apihelper.add_sticker_to_set(
|
|
||||||
self.token, user_id, name, tgs_sticker, emojis, mask_position, animated=True)
|
|
||||||
|
|
||||||
|
|
||||||
def set_sticker_position_in_set(self, sticker: str, position: int) -> bool:
|
def set_sticker_position_in_set(self, sticker: str, position: int) -> bool:
|
||||||
|
@ -810,7 +810,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,
|
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, thumb=None, caption_entities=None,
|
||||||
allow_sending_without_reply=None):
|
allow_sending_without_reply=None, disable_content_type_detection=None):
|
||||||
method_url = get_method_by_type(data_type)
|
method_url = get_method_by_type(data_type)
|
||||||
payload = {'chat_id': chat_id}
|
payload = {'chat_id': chat_id}
|
||||||
files = None
|
files = None
|
||||||
@ -842,6 +842,8 @@ def send_data(token, chat_id, data, data_type, reply_to_message_id=None, reply_m
|
|||||||
payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities))
|
payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities))
|
||||||
if allow_sending_without_reply is not None:
|
if allow_sending_without_reply is not None:
|
||||||
payload['allow_sending_without_reply'] = allow_sending_without_reply
|
payload['allow_sending_without_reply'] = allow_sending_without_reply
|
||||||
|
if method_url == 'sendDocument' and disable_content_type_detection is not None:
|
||||||
|
payload['disable_content_type_detection'] = disable_content_type_detection
|
||||||
return _make_request(token, method_url, params=payload, files=files, method='post')
|
return _make_request(token, method_url, params=payload, files=files, method='post')
|
||||||
|
|
||||||
|
|
||||||
@ -1388,12 +1390,13 @@ def upload_sticker_file(token, user_id, png_sticker):
|
|||||||
|
|
||||||
|
|
||||||
def create_new_sticker_set(
|
def create_new_sticker_set(
|
||||||
token, user_id, name, title, sticker, emojis,
|
token, user_id, name, title, emojis, png_sticker, tgs_sticker,
|
||||||
contains_masks=None, mask_position=None, animated=False):
|
contains_masks=None, mask_position=None):
|
||||||
method_url = 'createNewStickerSet'
|
method_url = 'createNewStickerSet'
|
||||||
payload = {'user_id': user_id, 'name': name, 'title': title, 'emojis': emojis}
|
payload = {'user_id': user_id, 'name': name, 'title': title, 'emojis': emojis}
|
||||||
|
stype = 'png_sticker' if png_sticker else 'tgs_sticker'
|
||||||
|
sticker = png_sticker or tgs_sticker
|
||||||
files = None
|
files = None
|
||||||
stype = 'tgs_sticker' if animated else 'png_sticker'
|
|
||||||
if not util.is_string(sticker):
|
if not util.is_string(sticker):
|
||||||
files = {stype: sticker}
|
files = {stype: sticker}
|
||||||
else:
|
else:
|
||||||
@ -1405,11 +1408,12 @@ def create_new_sticker_set(
|
|||||||
return _make_request(token, method_url, params=payload, files=files, method='post')
|
return _make_request(token, method_url, params=payload, files=files, method='post')
|
||||||
|
|
||||||
|
|
||||||
def add_sticker_to_set(token, user_id, name, sticker, emojis, mask_position, animated=False):
|
def add_sticker_to_set(token, user_id, name, emojis, png_sticker, tgs_sticker, mask_position):
|
||||||
method_url = 'addStickerToSet'
|
method_url = 'addStickerToSet'
|
||||||
payload = {'user_id': user_id, 'name': name, 'emojis': emojis}
|
payload = {'user_id': user_id, 'name': name, 'emojis': emojis}
|
||||||
|
stype = 'png_sticker' if png_sticker else 'tgs_sticker'
|
||||||
|
sticker = png_sticker or tgs_sticker
|
||||||
files = None
|
files = None
|
||||||
stype = 'tgs_sticker' if animated else 'png_sticker'
|
|
||||||
if not util.is_string(sticker):
|
if not util.is_string(sticker):
|
||||||
files = {stype: sticker}
|
files = {stype: sticker}
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user