mirror of
https://github.com/Nick80835/microbot
synced 2025-08-22 18:19:16 +00:00
add a function to loader for checking if a sticker is a sticker
This commit is contained in:
parent
8dbf05ba8c
commit
a0cd71a29e
@ -4,8 +4,8 @@ from importlib import import_module, reload
|
|||||||
from os.path import basename, dirname, isfile
|
from os.path import basename, dirname, isfile
|
||||||
|
|
||||||
from aiohttp import ClientSession
|
from aiohttp import ClientSession
|
||||||
|
from telethon.tl.types import (DocumentAttributeFilename,
|
||||||
from telethon.tl.types import DocumentAttributeFilename
|
DocumentAttributeSticker)
|
||||||
|
|
||||||
from .cache import Cache
|
from .cache import Cache
|
||||||
from .command import (CallbackQueryCommand, Command, InlineArticleCommand,
|
from .command import (CallbackQueryCommand, Command, InlineArticleCommand,
|
||||||
@ -171,6 +171,15 @@ class Loader():
|
|||||||
else:
|
else:
|
||||||
return
|
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):
|
def prefix(self):
|
||||||
return (self.settings.get_list('cmd_prefix') or ['.'])[0]
|
return (self.settings.get_list('cmd_prefix') or ['.'])[0]
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ async def userprofilegetter(event):
|
|||||||
async def stickertopng(event):
|
async def stickertopng(event):
|
||||||
reply = await event.get_reply_message()
|
reply = await event.get_reply_message()
|
||||||
|
|
||||||
if reply and reply.sticker:
|
if reply and await ldr.is_sticker(reply):
|
||||||
sticker_webp_data = reply.sticker
|
sticker_webp_data = reply.sticker
|
||||||
else:
|
else:
|
||||||
await event.reply("Reply to a sticker to get it as a PNG file!")
|
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):
|
async def flipsticker(event):
|
||||||
reply = await event.get_reply_message()
|
reply = await event.get_reply_message()
|
||||||
|
|
||||||
if reply and reply.sticker:
|
if reply and await ldr.is_sticker(reply):
|
||||||
sticker_webp_data = reply.sticker
|
sticker_webp_data = reply.sticker
|
||||||
else:
|
else:
|
||||||
await event.reply("Reply to a sticker to flip that bitch!")
|
await event.reply("Reply to a sticker to flip that bitch!")
|
||||||
@ -186,7 +186,7 @@ async def compressor(event):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
compression_quality = 15
|
compression_quality = 15
|
||||||
|
|
||||||
if reply and reply.sticker:
|
if reply and await ldr.is_sticker(reply):
|
||||||
sticker_webp_data = reply.sticker
|
sticker_webp_data = reply.sticker
|
||||||
else:
|
else:
|
||||||
await event.reply("Reply to a sticker to compress that bitch!")
|
await event.reply("Reply to a sticker to compress that bitch!")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user