Skip to content

Commit

Permalink
anker/bot/sticker_storage.py: a workaround for get_sticker_set
Browse files Browse the repository at this point in the history
The issues is described here:
eternnoir/pyTelegramBotAPI#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.
  • Loading branch information
szobov committed Apr 5, 2024
1 parent fb0e736 commit 2d2fde4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion anker/bot/sticker_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

2 comments on commit 2d2fde4

@Kuchizu
Copy link

@Kuchizu Kuchizu commented on 2d2fde4 Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! Thanks for the solution ✨

@szobov
Copy link
Owner Author

@szobov szobov commented on 2d2fde4 Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! Thanks for the solution ✨

You're welcome!

Please sign in to comment.