From ed18b3ccba4ea391676d1da6defb75a061a3a10b Mon Sep 17 00:00:00 2001 From: udf Date: Sun, 25 Nov 2018 02:45:10 +0200 Subject: [PATCH] Add check for large files and comments --- stdplugins/kbass_file_to_photo.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stdplugins/kbass_file_to_photo.py b/stdplugins/kbass_file_to_photo.py index e999e92..f267cab 100644 --- a/stdplugins/kbass_file_to_photo.py +++ b/stdplugins/kbass_file_to_photo.py @@ -14,8 +14,12 @@ async def on_file_to_photo(event, target): image = target.media.document except AttributeError: return - if image.mime_type == 'image/webp' or not image.mime_type.startswith('image/'): - return + if not image.mime_type.startswith('image/'): + return # This isn't an image + if image.mime_type == 'image/webp': + return # Telegram doesn't let you directly send stickers as photos + if image.size > 10 * 1024 * 1024: + return # We'd get PhotoSaveFileInvalidError otherwise file = await borg.download_media(target, file=BytesIO()) file.seek(0)