From a54cd2e4fcf2ded7e09d8a7cdb234bfde1e5f346 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Thu, 2 Apr 2020 13:55:47 +0200 Subject: [PATCH] Add ttl_seconds to Photo objects --- pyrogram/client/types/messages_and_media/message.py | 2 +- pyrogram/client/types/messages_and_media/photo.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index f566849b..451e8c25 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -523,7 +523,7 @@ class Message(Object, Update): if media: if isinstance(media, types.MessageMediaPhoto): - photo = Photo._parse(client, media.photo) + photo = Photo._parse(client, media) elif isinstance(media, types.MessageMediaGeo): location = Location._parse(client, media.geo) elif isinstance(media, types.MessageMediaContact): diff --git a/pyrogram/client/types/messages_and_media/photo.py b/pyrogram/client/types/messages_and_media/photo.py index 7a0230d6..1edfb4e2 100644 --- a/pyrogram/client/types/messages_and_media/photo.py +++ b/pyrogram/client/types/messages_and_media/photo.py @@ -42,6 +42,9 @@ class Photo(Object): height (``int``): Photo height. + ttl_seconds (``int``): + Time-to-live seconds, for secret photos. + file_size (``int``): File size. @@ -60,6 +63,7 @@ class Photo(Object): file_ref: str, width: int, height: int, + ttl_seconds: int, file_size: int, date: int, thumbs: List[Thumbnail] @@ -70,12 +74,15 @@ class Photo(Object): self.file_ref = file_ref self.width = width self.height = height + self.ttl_seconds = ttl_seconds self.file_size = file_size self.date = date self.thumbs = thumbs @staticmethod - def _parse(client, photo: types.Photo) -> "Photo": + def _parse(client, media_photo: types.MessageMediaPhoto) -> "Photo": + photo = media_photo.photo + if isinstance(photo, types.Photo): big = photo.sizes[-1] @@ -91,6 +98,7 @@ class Photo(Object): file_ref=encode_file_ref(photo.file_reference), width=big.w, height=big.h, + ttl_seconds=media_photo.ttl_seconds, file_size=big.size, date=photo.date, thumbs=Thumbnail._parse(client, photo),