Reject animated stickers

This commit is contained in:
blank X 2020-12-25 08:37:05 +07:00
parent 71fb7c1051
commit 0b2b204232
2 changed files with 8 additions and 0 deletions

View File

@ -6,6 +6,7 @@ from decimal import Decimal
from urllib.parse import urlparse, urlunparse, parse_qs, quote as urlencode from urllib.parse import urlparse, urlunparse, parse_qs, quote as urlencode
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from pyrogram import Client, filters 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 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): async def download_file(url, filename, referer=None):
@ -34,6 +35,9 @@ async def saucenao(client, message):
if not media: if not media:
await message.reply_text('Photo or GIF or Video or Sticker required') await message.reply_text('Photo or GIF or Video or Sticker required')
return return
if isinstance(media, Sticker) and sticker.is_animated:
await message.reply_text('No animated stickers')
return
with tempfile.TemporaryDirectory() as tempdir: with tempfile.TemporaryDirectory() as tempdir:
reply = await message.reply_text('Downloading...') 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)) filename = await client.download_media(media, file_name=os.path.join(tempdir, '0'), progress=progress_callback, progress_args=(reply, 'Downloading...', False))

View File

@ -7,6 +7,7 @@ import tempfile
from decimal import Decimal from decimal import Decimal
from urllib.parse import quote as urlencode from urllib.parse import quote as urlencode
from pyrogram import Client, filters from pyrogram import Client, filters
from pyrogram.types import Sticker
from .. import config, help_dict, log_errors, session, progress_callback, public_log_errors 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'])) @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: if not media:
await message.reply_text('Photo or GIF or Video or Sticker required') await message.reply_text('Photo or GIF or Video or Sticker required')
return return
if isinstance(media, Sticker) and sticker.is_animated:
await message.reply_text('No animated stickers')
return
with tempfile.TemporaryDirectory() as tempdir: with tempfile.TemporaryDirectory() as tempdir:
reply = await message.reply_text('Downloading...') 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)) path = await client.download_media(media, file_name=os.path.join(tempdir, '0'), progress=progress_callback, progress_args=(reply, 'Downloading...', False))