mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 10:53:44 +03:00
Fix get_extension missing even more photo cases
This commit is contained in:
parent
86cdb7c1f8
commit
35ba9848d9
|
@ -106,9 +106,13 @@ def get_extension(media):
|
|||
"""Gets the corresponding extension for any Telegram media."""
|
||||
|
||||
# Photos are always compressed as .jpg by Telegram
|
||||
if isinstance(media, (types.UserProfilePhoto,
|
||||
types.ChatPhoto, types.MessageMediaPhoto)):
|
||||
try:
|
||||
get_input_photo(media)
|
||||
return '.jpg'
|
||||
except TypeError:
|
||||
# These cases are not handled by input photo because it can't
|
||||
if isinstance(media, (types.UserProfilePhoto, types.ChatPhoto)):
|
||||
return '.jpg'
|
||||
|
||||
# Documents will come with a mime type
|
||||
if isinstance(media, types.MessageMediaDocument):
|
||||
|
@ -290,7 +294,10 @@ def get_input_photo(photo):
|
|||
except AttributeError:
|
||||
_raise_cast_fail(photo, 'InputPhoto')
|
||||
|
||||
if isinstance(photo, types.photos.Photo):
|
||||
if isinstance(photo, types.Message):
|
||||
photo = photo.media
|
||||
|
||||
if isinstance(photo, (types.photos.Photo, types.MessageMediaPhoto)):
|
||||
photo = photo.photo
|
||||
|
||||
if isinstance(photo, types.Photo):
|
||||
|
@ -302,6 +309,7 @@ def get_input_photo(photo):
|
|||
|
||||
if isinstance(photo, types.messages.ChatFull):
|
||||
photo = photo.full_chat
|
||||
|
||||
if isinstance(photo, types.ChannelFull):
|
||||
return get_input_photo(photo.chat_photo)
|
||||
elif isinstance(photo, types.UserFull):
|
||||
|
|
Loading…
Reference in New Issue
Block a user