2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +00:00

Fix self-destruct media if file_id and ttl_seconds are passed (#971)

This commit is contained in:
Stark Programmer 2022-04-27 12:47:14 +05:30 committed by GitHub
parent 045fe0bf21
commit 32b3452e76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View File

@ -155,7 +155,7 @@ class SendPhoto:
ttl_seconds=ttl_seconds ttl_seconds=ttl_seconds
) )
else: 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: else:
file = await self.save_file(photo, progress=progress, progress_args=progress_args) file = await self.save_file(photo, progress=progress, progress_args=progress_args)
media = raw.types.InputMediaUploadedPhoto( media = raw.types.InputMediaUploadedPhoto(

View File

@ -200,7 +200,7 @@ class SendVideo:
ttl_seconds=ttl_seconds ttl_seconds=ttl_seconds
) )
else: 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: else:
thumb = await self.save_file(thumb) thumb = await self.save_file(thumb)
file = await self.save_file(video, progress=progress, progress_args=progress_args) file = await self.save_file(video, progress=progress, progress_args=progress_args)

View File

@ -42,7 +42,8 @@ async def ainput(prompt: str = "", *, hide: bool = False):
def get_input_media_from_file_id( def get_input_media_from_file_id(
file_id: str, file_id: str,
expected_file_type: FileType = None expected_file_type: FileType = None,
ttl_seconds: int = None
) -> Union["raw.types.InputMediaPhoto", "raw.types.InputMediaDocument"]: ) -> Union["raw.types.InputMediaPhoto", "raw.types.InputMediaDocument"]:
try: try:
decoded = FileId.decode(file_id) decoded = FileId.decode(file_id)
@ -64,7 +65,8 @@ def get_input_media_from_file_id(
id=decoded.media_id, id=decoded.media_id,
access_hash=decoded.access_hash, access_hash=decoded.access_hash,
file_reference=decoded.file_reference file_reference=decoded.file_reference
) ),
ttl_seconds=ttl_seconds
) )
if file_type in DOCUMENT_TYPES: if file_type in DOCUMENT_TYPES:
@ -73,7 +75,8 @@ def get_input_media_from_file_id(
id=decoded.media_id, id=decoded.media_id,
access_hash=decoded.access_hash, access_hash=decoded.access_hash,
file_reference=decoded.file_reference file_reference=decoded.file_reference
) ),
ttl_seconds=ttl_seconds
) )
raise ValueError(f"Unknown file id: {file_id}") raise ValueError(f"Unknown file id: {file_id}")