Add check for large files and comments

This commit is contained in:
udf 2018-11-25 02:45:10 +02:00
parent b0b2b65ca4
commit ed18b3ccba
Signed by untrusted user: kate
GPG Key ID: E40724BAD73AF77B
1 changed files with 6 additions and 2 deletions

View File

@ -14,8 +14,12 @@ async def on_file_to_photo(event, target):
image = target.media.document image = target.media.document
except AttributeError: except AttributeError:
return return
if image.mime_type == 'image/webp' or not image.mime_type.startswith('image/'): if not image.mime_type.startswith('image/'):
return 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 = await borg.download_media(target, file=BytesIO())
file.seek(0) file.seek(0)