From db087427fc27d4f97c76f35c3cbd9eff5157ccd4 Mon Sep 17 00:00:00 2001 From: coder2020official Date: Sat, 11 Mar 2023 22:27:37 +0400 Subject: [PATCH] Added the method deleteStickerSet for complete deletion of a given sticker set that was created by the bot. --- telebot/__init__.py | 13 +++++++++++++ telebot/apihelper.py | 5 +++++ telebot/async_telebot.py | 13 +++++++++++++ telebot/asyncio_helper.py | 5 +++++ 4 files changed, 36 insertions(+) diff --git a/telebot/__init__.py b/telebot/__init__.py index a2cfb31..1f5288e 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -4597,6 +4597,19 @@ class TeleBot: """ return apihelper.set_sticker_set_title(self.token, name, title) + + def delete_sticker_set(self, name:str): + """ + Use this method to delete a sticker set. Returns True on success. + + :param name: Sticker set name + :type name: :obj:`str` + + :return: Returns True on success. + :rtype: :obj:`bool` + """ + + return apihelper.delete_sticker_set(self.token, name) def upload_sticker_file(self, user_id: int, png_sticker: Union[Any, str]=None, sticker: Optional[types.InputFile]=None, sticker_format: Optional[str]=None) -> types.File: """ diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 9a264b9..987be4b 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -1641,6 +1641,11 @@ def set_sticker_set_title(token, name, title): payload = {'name': name, 'title': title} return _make_request(token, method_url, params=payload, method='post') +def delete_sticker_set(token, name): + method_url = 'deleteStickerSet' + payload = {'name': name} + return _make_request(token, method_url, params=payload, method='post') + def create_new_sticker_set( token, user_id, name, title, stickers, sticker_format=None, sticker_type=None, needs_repainting=None): method_url = 'createNewStickerSet' diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index 608d880..1576b7f 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -5492,6 +5492,19 @@ class AsyncTeleBot: return await asyncio_helper.set_sticker_set_title(self.token, name, title) + async def delete_sticker_set(self, name:str): + """ + Use this method to delete a sticker set. Returns True on success. + + :param name: Sticker set name + :type name: :obj:`str` + + :return: Returns True on success. + :rtype: :obj:`bool` + """ + + return await asyncio_helper.delete_sticker_set(self.token, name) + async def create_new_sticker_set( self, user_id: int, name: str, title: str, diff --git a/telebot/asyncio_helper.py b/telebot/asyncio_helper.py index 2018757..cc0cf5b 100644 --- a/telebot/asyncio_helper.py +++ b/telebot/asyncio_helper.py @@ -1615,6 +1615,11 @@ async def upload_sticker_file(token, user_id, sticker, sticker_format): return await _process_request(token, method_url, params=payload, files=files, method='post') +async def delete_sticker_set(token, name): + method_url = 'deleteStickerSet' + payload = {'name': name} + return await _process_request(token, method_url, params=payload, method='post') + async def set_custom_emoji_sticker_set_thumbnail(token, name, custom_emoji_id=None): method_url = 'setCustomEmojiStickerSetThumbnail' payload = {'name': name}