diff --git a/ubot/loader.py b/ubot/loader.py index f90752f..52ffd11 100644 --- a/ubot/loader.py +++ b/ubot/loader.py @@ -4,8 +4,8 @@ from importlib import import_module, reload from os.path import basename, dirname, isfile from aiohttp import ClientSession - -from telethon.tl.types import DocumentAttributeFilename +from telethon.tl.types import (DocumentAttributeFilename, + DocumentAttributeSticker) from .cache import Cache from .command import (CallbackQueryCommand, Command, InlineArticleCommand, @@ -171,6 +171,15 @@ class Loader(): else: return + async def is_sticker(self, event) -> bool: + if event and event.sticker: + attrs = [i.alt for i in event.sticker.attributes if isinstance(i, DocumentAttributeSticker)] + + if attrs and attrs[0]: + return True + + return False + def prefix(self): return (self.settings.get_list('cmd_prefix') or ['.'])[0] diff --git a/ubot/modules/evaluation.py b/ubot/modules/evaluation.py index d3b44fb..76dcd73 100644 --- a/ubot/modules/evaluation.py +++ b/ubot/modules/evaluation.py @@ -96,7 +96,7 @@ async def userprofilegetter(event): async def stickertopng(event): reply = await event.get_reply_message() - if reply and reply.sticker: + if reply and await ldr.is_sticker(reply): sticker_webp_data = reply.sticker else: await event.reply("Reply to a sticker to get it as a PNG file!") @@ -117,7 +117,7 @@ async def stickertopng(event): async def flipsticker(event): reply = await event.get_reply_message() - if reply and reply.sticker: + if reply and await ldr.is_sticker(reply): sticker_webp_data = reply.sticker else: await event.reply("Reply to a sticker to flip that bitch!") @@ -186,7 +186,7 @@ async def compressor(event): except ValueError: compression_quality = 15 - if reply and reply.sticker: + if reply and await ldr.is_sticker(reply): sticker_webp_data = reply.sticker else: await event.reply("Reply to a sticker to compress that bitch!")