From 2d2fde4f935260d0a5838b6184df3000b1e59c00 Mon Sep 17 00:00:00 2001 From: Sergei Zobov Date: Fri, 5 Apr 2024 11:52:20 +0200 Subject: [PATCH] anker/bot/sticker_storage.py: a workaround for get_sticker_set The issues is described here: https://github.com/eternnoir/pyTelegramBotAPI/issues/2212 The error I got was: `TypeError: StickerSet.__init__() missing 2 required positional arguments: 'is_animated' and 'is_video'` Since the bot is not using `is_animated` nor `is_video` I can define these fields directly in the reply. --- anker/bot/sticker_storage.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/anker/bot/sticker_storage.py b/anker/bot/sticker_storage.py index 03a0c5a..eabf9ab 100644 --- a/anker/bot/sticker_storage.py +++ b/anker/bot/sticker_storage.py @@ -50,7 +50,15 @@ def get_sticker_set( bot: telebot.TeleBot, sticker_set_name: str ) -> telebot.types.StickerSet | None: try: - return bot.get_sticker_set(sticker_set_name) + # A workaround an issue described here: https://github.com/eternnoir/pyTelegramBotAPI/issues/2212 + is_workaround = True + if is_workaround: + result = telebot.apihelper.get_sticker_set(bot.token, sticker_set_name) + result["is_animated"] = False + result["is_video"] = False + return telebot.types.StickerSet.de_json(result) + else: + return bot.get_sticker_set(sticker_set_name) except telebot.apihelper.ApiTelegramException: return None