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

Bot API 5.7

This commit is contained in:
_run 2022-02-01 17:43:49 +04:00
parent 4e7652be7a
commit 71be20636a
3 changed files with 34 additions and 11 deletions

View File

@ -1536,8 +1536,14 @@ def create_new_sticker_set(
contains_masks=None, mask_position=None, webm_sticker=None): contains_masks=None, mask_position=None, webm_sticker=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' stype = None
sticker = png_sticker or tgs_sticker if png_sticker:
stype = 'png_sticker'
elif webm_sticker:
stype = 'webm_sticker'
else:
stype = 'tgs_sticker'
sticker = png_sticker or tgs_sticker or webm_sticker
files = None files = None
if not util.is_string(sticker): if not util.is_string(sticker):
files = {stype: sticker} files = {stype: sticker}
@ -1555,8 +1561,14 @@ def create_new_sticker_set(
def add_sticker_to_set(token, user_id, name, emojis, png_sticker, tgs_sticker, mask_position, webm_sticker): def add_sticker_to_set(token, user_id, name, emojis, png_sticker, tgs_sticker, mask_position, webm_sticker):
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' stype = None
sticker = png_sticker or tgs_sticker if png_sticker:
stype = 'png_sticker'
elif webm_sticker:
stype = 'webm_sticker'
else:
stype = 'tgs_sticker'
sticker = png_sticker or tgs_sticker or webm_sticker
files = None files = None
if not util.is_string(sticker): if not util.is_string(sticker):
files = {stype: sticker} files = {stype: sticker}
@ -1564,8 +1576,6 @@ def add_sticker_to_set(token, user_id, name, emojis, png_sticker, tgs_sticker, m
payload[stype] = sticker payload[stype] = sticker
if mask_position: if mask_position:
payload['mask_position'] = mask_position.to_json() payload['mask_position'] = mask_position.to_json()
if webm_sticker:
payload['webm_sticker'] = webm_sticker
return _make_request(token, method_url, params=payload, files=files, method='post') return _make_request(token, method_url, params=payload, files=files, method='post')

View File

@ -1500,8 +1500,14 @@ async def create_new_sticker_set(
contains_masks=None, mask_position=None, webm_sticker=None): contains_masks=None, mask_position=None, webm_sticker=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' stype = None
sticker = png_sticker or tgs_sticker if png_sticker:
stype = 'png_sticker'
elif webm_sticker:
stype = 'webm_sticker'
else:
stype = 'tgs_sticker'
sticker = png_sticker or tgs_sticker or webm_sticker
files = None files = None
if not util.is_string(sticker): if not util.is_string(sticker):
files = {stype: sticker} files = {stype: sticker}
@ -1519,9 +1525,16 @@ async def create_new_sticker_set(
async def add_sticker_to_set(token, user_id, name, emojis, png_sticker, tgs_sticker, mask_position, webm_sticker): async def add_sticker_to_set(token, user_id, name, emojis, png_sticker, tgs_sticker, mask_position, webm_sticker):
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' stype = None
sticker = png_sticker or tgs_sticker if png_sticker:
stype = 'png_sticker'
elif webm_sticker:
stype = 'webm_sticker'
else:
stype = 'tgs_sticker'
files = None files = None
sticker = png_sticker or tgs_sticker or webm_sticker
if not util.is_string(sticker): if not util.is_string(sticker):
files = {stype: sticker} files = {stype: sticker}
else: else:

View File

@ -2508,7 +2508,7 @@ class Sticker(JsonDeserializable):
return cls(**obj) return cls(**obj)
def __init__(self, file_id, file_unique_id, width, height, is_animated, def __init__(self, file_id, file_unique_id, width, height, is_animated,
is_video=None, thumb=None, emoji=None, set_name=None, mask_position=None, file_size=None, **kwargs): is_video, thumb=None, emoji=None, set_name=None, mask_position=None, file_size=None, **kwargs):
self.file_id: str = file_id self.file_id: str = file_id
self.file_unique_id: str = file_unique_id self.file_unique_id: str = file_unique_id
self.width: int = width self.width: int = width