2
0
mirror of https://github.com/Nick80835/microbot synced 2025-08-22 10:09:40 +00:00

add a function to loader for checking if a sticker is a sticker

This commit is contained in:
Nick80835 2020-12-04 20:25:31 -05:00
parent 8dbf05ba8c
commit a0cd71a29e
2 changed files with 14 additions and 5 deletions

View File

@ -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]

View File

@ -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!")