From 32b3452e76f81147a959ac00cff547c39184cb39 Mon Sep 17 00:00:00 2001 From: Stark Programmer <88478059+StarkBotsIndustries@users.noreply.github.com> Date: Wed, 27 Apr 2022 12:47:14 +0530 Subject: [PATCH] Fix self-destruct media if file_id and ttl_seconds are passed (#971) --- pyrogram/methods/messages/send_photo.py | 2 +- pyrogram/methods/messages/send_video.py | 2 +- pyrogram/utils.py | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pyrogram/methods/messages/send_photo.py b/pyrogram/methods/messages/send_photo.py index 85d6fe4b..836ce1b1 100644 --- a/pyrogram/methods/messages/send_photo.py +++ b/pyrogram/methods/messages/send_photo.py @@ -155,7 +155,7 @@ class SendPhoto: ttl_seconds=ttl_seconds ) else: - media = utils.get_input_media_from_file_id(photo, FileType.PHOTO) + media = utils.get_input_media_from_file_id(photo, FileType.PHOTO, ttl_seconds=ttl_seconds) else: file = await self.save_file(photo, progress=progress, progress_args=progress_args) media = raw.types.InputMediaUploadedPhoto( diff --git a/pyrogram/methods/messages/send_video.py b/pyrogram/methods/messages/send_video.py index 299f1b47..669b42ec 100644 --- a/pyrogram/methods/messages/send_video.py +++ b/pyrogram/methods/messages/send_video.py @@ -200,7 +200,7 @@ class SendVideo: ttl_seconds=ttl_seconds ) else: - media = utils.get_input_media_from_file_id(video, FileType.VIDEO) + media = utils.get_input_media_from_file_id(video, FileType.VIDEO, ttl_seconds=ttl_seconds) else: thumb = await self.save_file(thumb) file = await self.save_file(video, progress=progress, progress_args=progress_args) diff --git a/pyrogram/utils.py b/pyrogram/utils.py index b9f3fdd8..d5862d1a 100644 --- a/pyrogram/utils.py +++ b/pyrogram/utils.py @@ -42,7 +42,8 @@ async def ainput(prompt: str = "", *, hide: bool = False): def get_input_media_from_file_id( file_id: str, - expected_file_type: FileType = None + expected_file_type: FileType = None, + ttl_seconds: int = None ) -> Union["raw.types.InputMediaPhoto", "raw.types.InputMediaDocument"]: try: decoded = FileId.decode(file_id) @@ -64,7 +65,8 @@ def get_input_media_from_file_id( id=decoded.media_id, access_hash=decoded.access_hash, file_reference=decoded.file_reference - ) + ), + ttl_seconds=ttl_seconds ) if file_type in DOCUMENT_TYPES: @@ -73,7 +75,8 @@ def get_input_media_from_file_id( id=decoded.media_id, access_hash=decoded.access_hash, file_reference=decoded.file_reference - ) + ), + ttl_seconds=ttl_seconds ) raise ValueError(f"Unknown file id: {file_id}")