Fix ttl_seconds not being parsed correctly

This commit is contained in:
Dan 2020-04-04 23:47:09 +02:00
parent fa157b59f1
commit 850b79315f
2 changed files with 3 additions and 5 deletions

View File

@ -523,7 +523,7 @@ class Message(Object, Update):
if media: if media:
if isinstance(media, types.MessageMediaPhoto): if isinstance(media, types.MessageMediaPhoto):
photo = Photo._parse(client, media) photo = Photo._parse(client, media.photo, media.ttl_seconds)
elif isinstance(media, types.MessageMediaGeo): elif isinstance(media, types.MessageMediaGeo):
location = Location._parse(client, media.geo) location = Location._parse(client, media.geo)
elif isinstance(media, types.MessageMediaContact): elif isinstance(media, types.MessageMediaContact):

View File

@ -80,9 +80,7 @@ class Photo(Object):
self.thumbs = thumbs self.thumbs = thumbs
@staticmethod @staticmethod
def _parse(client, media_photo: types.MessageMediaPhoto) -> "Photo": def _parse(client, photo: types.Photo, ttl_seconds: int = None) -> "Photo":
photo = media_photo.photo
if isinstance(photo, types.Photo): if isinstance(photo, types.Photo):
big = photo.sizes[-1] big = photo.sizes[-1]
@ -98,7 +96,7 @@ class Photo(Object):
file_ref=encode_file_ref(photo.file_reference), file_ref=encode_file_ref(photo.file_reference),
width=big.w, width=big.w,
height=big.h, height=big.h,
ttl_seconds=media_photo.ttl_seconds, ttl_seconds=ttl_seconds,
file_size=big.size, file_size=big.size,
date=photo.date, date=photo.date,
thumbs=Thumbnail._parse(client, photo), thumbs=Thumbnail._parse(client, photo),