Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit 32b3452

Browse files
Fix self-destruct media if file_id and ttl_seconds are passed (#971)
1 parent 045fe0b commit 32b3452

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

pyrogram/methods/messages/send_photo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ async def send_photo(
155155
ttl_seconds=ttl_seconds
156156
)
157157
else:
158-
media = utils.get_input_media_from_file_id(photo, FileType.PHOTO)
158+
media = utils.get_input_media_from_file_id(photo, FileType.PHOTO, ttl_seconds=ttl_seconds)
159159
else:
160160
file = await self.save_file(photo, progress=progress, progress_args=progress_args)
161161
media = raw.types.InputMediaUploadedPhoto(

pyrogram/methods/messages/send_video.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ async def progress(current, total):
200200
ttl_seconds=ttl_seconds
201201
)
202202
else:
203-
media = utils.get_input_media_from_file_id(video, FileType.VIDEO)
203+
media = utils.get_input_media_from_file_id(video, FileType.VIDEO, ttl_seconds=ttl_seconds)
204204
else:
205205
thumb = await self.save_file(thumb)
206206
file = await self.save_file(video, progress=progress, progress_args=progress_args)

pyrogram/utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ async def ainput(prompt: str = "", *, hide: bool = False):
4242

4343
def get_input_media_from_file_id(
4444
file_id: str,
45-
expected_file_type: FileType = None
45+
expected_file_type: FileType = None,
46+
ttl_seconds: int = None
4647
) -> Union["raw.types.InputMediaPhoto", "raw.types.InputMediaDocument"]:
4748
try:
4849
decoded = FileId.decode(file_id)
@@ -64,7 +65,8 @@ def get_input_media_from_file_id(
6465
id=decoded.media_id,
6566
access_hash=decoded.access_hash,
6667
file_reference=decoded.file_reference
67-
)
68+
),
69+
ttl_seconds=ttl_seconds
6870
)
6971

7072
if file_type in DOCUMENT_TYPES:
@@ -73,7 +75,8 @@ def get_input_media_from_file_id(
7375
id=decoded.media_id,
7476
access_hash=decoded.access_hash,
7577
file_reference=decoded.file_reference
76-
)
78+
),
79+
ttl_seconds=ttl_seconds
7780
)
7881

7982
raise ValueError(f"Unknown file id: {file_id}")

0 commit comments

Comments
 (0)