From 0b2b20423289c163fa05aa66367b3aed65eef3cc Mon Sep 17 00:00:00 2001 From: blank X Date: Fri, 25 Dec 2020 08:37:05 +0700 Subject: [PATCH] Reject animated stickers --- sukuinote/plugins/saucenao.py | 4 ++++ sukuinote/plugins/whatanime.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/sukuinote/plugins/saucenao.py b/sukuinote/plugins/saucenao.py index 4e0ffa2..78c9775 100644 --- a/sukuinote/plugins/saucenao.py +++ b/sukuinote/plugins/saucenao.py @@ -6,6 +6,7 @@ from decimal import Decimal from urllib.parse import urlparse, urlunparse, parse_qs, quote as urlencode from bs4 import BeautifulSoup from pyrogram import Client, filters +from pyrogram.types import Sticker from .. import config, help_dict, log_errors, public_log_errors, session, get_file_mimetype, progress_callback, get_file_ext async def download_file(url, filename, referer=None): @@ -34,6 +35,9 @@ async def saucenao(client, message): if not media: await message.reply_text('Photo or GIF or Video or Sticker required') return + if isinstance(media, Sticker) and sticker.is_animated: + await message.reply_text('No animated stickers') + return with tempfile.TemporaryDirectory() as tempdir: reply = await message.reply_text('Downloading...') filename = await client.download_media(media, file_name=os.path.join(tempdir, '0'), progress=progress_callback, progress_args=(reply, 'Downloading...', False)) diff --git a/sukuinote/plugins/whatanime.py b/sukuinote/plugins/whatanime.py index 2a2f9ed..68c37fa 100644 --- a/sukuinote/plugins/whatanime.py +++ b/sukuinote/plugins/whatanime.py @@ -7,6 +7,7 @@ import tempfile from decimal import Decimal from urllib.parse import quote as urlencode from pyrogram import Client, filters +from pyrogram.types import Sticker from .. import config, help_dict, log_errors, session, progress_callback, public_log_errors @Client.on_message(~filters.sticker & ~filters.via_bot & ~filters.edited & filters.me & filters.command(['trace', 'tracemoe', 'whatanime', 'wa', 'wait'], prefixes=config['config']['prefixes'])) @@ -21,6 +22,9 @@ async def whatanime(client, message): if not media: await message.reply_text('Photo or GIF or Video or Sticker required') return + if isinstance(media, Sticker) and sticker.is_animated: + await message.reply_text('No animated stickers') + return with tempfile.TemporaryDirectory() as tempdir: reply = await message.reply_text('Downloading...') path = await client.download_media(media, file_name=os.path.join(tempdir, '0'), progress=progress_callback, progress_args=(reply, 'Downloading...', False))