From 8a858cac4eae8ded8927dbcbea30e24f730d5707 Mon Sep 17 00:00:00 2001 From: coder2020official Date: Sat, 11 Mar 2023 16:39:04 +0400 Subject: [PATCH] Added the parameter needs_repainting to the method createNewStickerSet to automatically change the color of emoji based on context (e.g., use text color in messages, accent color in statuses, etc.). --- telebot/__init__.py | 10 ++++++++-- telebot/apihelper.py | 4 +++- telebot/async_telebot.py | 10 ++++++++-- telebot/asyncio_helper.py | 4 +++- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/telebot/__init__.py b/telebot/__init__.py index 07ab9e1..f4df131 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -4592,7 +4592,8 @@ class TeleBot: webm_sticker: Union[Any, str]=None, contains_masks: Optional[bool]=None, sticker_type: Optional[str]=None, - mask_position: Optional[types.MaskPosition]=None) -> bool: + mask_position: Optional[types.MaskPosition]=None, + needs_repainting: Optional[bool]=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. @@ -4635,6 +4636,11 @@ class TeleBot: :param mask_position: A JSON-serialized object for position where the mask should be placed on faces :type mask_position: :class:`telebot.types.MaskPosition` + :param needs_repainting: Pass True if stickers in the sticker set must be repainted to the color of text when used in messages, + the accent color if used as emoji status, white on chat photos, or another appropriate color based on context; + for custom emoji sticker sets only + :type needs_repainting: :obj:`bool` + :return: On success, True is returned. :rtype: :obj:`bool` """ @@ -4645,7 +4651,7 @@ class TeleBot: return apihelper.create_new_sticker_set( self.token, user_id, name, title, emojis, png_sticker, tgs_sticker, - mask_position, webm_sticker, sticker_type) + mask_position, webm_sticker, sticker_type, needs_repainting) def add_sticker_to_set( self, user_id: int, name: str, emojis: str, diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 3b4f709..2bf5f9a 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -1630,7 +1630,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, - mask_position=None, webm_sticker=None, sticker_type=None): + mask_position=None, webm_sticker=None, sticker_type=None, needs_repainting=None): method_url = 'createNewStickerSet' payload = {'user_id': user_id, 'name': name, 'title': title, 'emojis': emojis} if png_sticker: @@ -1649,6 +1649,8 @@ def create_new_sticker_set( payload['mask_position'] = mask_position.to_json() if sticker_type: payload['sticker_type'] = sticker_type + if needs_repainting is not None: + payload['needs_repainting'] = needs_repainting return _make_request(token, method_url, params=payload, files=files, method='post') diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index e3b7373..f4669e8 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -5455,7 +5455,8 @@ class AsyncTeleBot: webm_sticker: Union[Any, str]=None, contains_masks: Optional[bool]=None, sticker_type: Optional[str]=None, - mask_position: Optional[types.MaskPosition]=None) -> bool: + mask_position: Optional[types.MaskPosition]=None, + needs_repainting: Optional[bool]=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. @@ -5498,6 +5499,11 @@ class AsyncTeleBot: :param mask_position: A JSON-serialized object for position where the mask should be placed on faces :type mask_position: :class:`telebot.types.MaskPosition` + :param needs_repainting: Pass True if stickers in the sticker set must be repainted to the color of text when used in messages, + the accent color if used as emoji status, white on chat photos, or another appropriate color based on context; + for custom emoji sticker sets only + :type needs_repainting: :obj:`bool` + :return: On success, True is returned. :rtype: :obj:`bool` """ @@ -5508,7 +5514,7 @@ class AsyncTeleBot: return await asyncio_helper.create_new_sticker_set( self.token, user_id, name, title, emojis, png_sticker, tgs_sticker, - mask_position, webm_sticker, sticker_type) + mask_position, webm_sticker, sticker_type, needs_repainting) async def add_sticker_to_set( diff --git a/telebot/asyncio_helper.py b/telebot/asyncio_helper.py index f2a9d4b..0f9919c 100644 --- a/telebot/asyncio_helper.py +++ b/telebot/asyncio_helper.py @@ -1617,7 +1617,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, - mask_position=None, webm_sticker=None, sticker_type=None): + mask_position=None, webm_sticker=None, sticker_type=None, needs_repainting=None): method_url = 'createNewStickerSet' payload = {'user_id': user_id, 'name': name, 'title': title, 'emojis': emojis} if png_sticker: @@ -1636,6 +1636,8 @@ async def create_new_sticker_set( payload['mask_position'] = mask_position.to_json() if sticker_type: payload['sticker_type'] = sticker_type + if needs_repainting is not None: + payload['needs_repainting'] = needs_repainting return await _process_request(token, method_url, params=payload, files=files, method='post')