From 715aabaf4920fac92b99bee9cc9d698d9c25e646 Mon Sep 17 00:00:00 2001 From: coder2020official Date: Sat, 11 Mar 2023 23:06:57 +0400 Subject: [PATCH] Added the method setStickerMaskPosition for changing the mask position of a mask sticker. --- telebot/__init__.py | 17 +++++++++++++++++ telebot/apihelper.py | 7 +++++++ telebot/async_telebot.py | 17 +++++++++++++++++ telebot/asyncio_helper.py | 9 ++++++++- 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/telebot/__init__.py b/telebot/__init__.py index 0458cc3..0d2910f 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -4581,6 +4581,23 @@ class TeleBot: """ return apihelper.set_sticker_keywords(self.token, sticker, keywords) + def set_sticker_mask_position(self, sticker: str, mask_position: types.MaskPosition=None) -> bool: + """ + Use this method to change the mask position of a mask sticker. + The sticker must belong to a sticker set that was created by the bot. + Returns True on success. + + :param sticker: File identifier of the sticker. + :type sticker: :obj:`str` + + :param mask_position: A JSON-serialized object for position where the mask should be placed on faces. + :type mask_position: :class:`telebot.types.MaskPosition` + + :return: Returns True on success. + :rtype: :obj:`bool` + """ + return apihelper.set_sticker_mask_position(self.token, sticker, mask_position) + def set_custom_emoji_sticker_set_thumbnail(self, name: str, custom_emoji_id: Optional[str]=None) -> bool: """ diff --git a/telebot/apihelper.py b/telebot/apihelper.py index c48df05..bdc2112 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -1628,6 +1628,13 @@ def set_sticker_keywords(token, sticker, keywords=None): payload['keywords'] = json.dumps(keywords) return _make_request(token, method_url, params=payload, method='post') +def set_sticker_mask_position(token, sticker, mask_position=None): + method_url = 'setStickerMaskPosition' + payload = {'sticker': sticker} + if mask_position: + payload['mask_position'] = mask_position.to_json() + return _make_request(token, method_url, params=payload, method='post') + def upload_sticker_file(token, user_id, sticker, sticker_format): method_url = 'uploadStickerFile' diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index 4e8ecdc..e169d2e 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -5429,6 +5429,23 @@ class AsyncTeleBot: :rtype: :obj:`bool` """ return await asyncio_helper.set_sticker_keywords(self.token, sticker, keywords) + + async def set_sticker_mask_position(self, sticker: str, mask_position: types.MaskPosition=None) -> bool: + """ + Use this method to change the mask position of a mask sticker. + The sticker must belong to a sticker set that was created by the bot. + Returns True on success. + + :param sticker: File identifier of the sticker. + :type sticker: :obj:`str` + + :param mask_position: A JSON-serialized object for position where the mask should be placed on faces. + :type mask_position: :class:`telebot.types.MaskPosition` + + :return: Returns True on success. + :rtype: :obj:`bool` + """ + return await asyncio_helper.set_sticker_mask_position(self.token, sticker, mask_position) async def get_custom_emoji_stickers(self, custom_emoji_ids: List[str]) -> List[types.Sticker]: """ diff --git a/telebot/asyncio_helper.py b/telebot/asyncio_helper.py index d6f3774..23be083 100644 --- a/telebot/asyncio_helper.py +++ b/telebot/asyncio_helper.py @@ -1613,7 +1613,14 @@ async def set_sticker_keywords(token, sticker, keywords=None): payload = {'sticker': sticker} if keywords: payload['keywords'] = json.dumps(keywords) - + + return await _process_request(token, method_url, params=payload, method='post') + +async def set_sticker_mask_position(token, sticker, mask_position=None): + method_url = 'setStickerMaskPosition' + payload = {'sticker': sticker} + if mask_position: + payload['mask_position'] = mask_position.to_json() return await _process_request(token, method_url, params=payload, method='post') async def upload_sticker_file(token, user_id, sticker, sticker_format):