forked from kate/uniborg
Add check for large files and comments
This commit is contained in:
parent
b0b2b65ca4
commit
ed18b3ccba
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue