mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Fix self-destruct media if file_id and ttl_seconds are passed (#971)
This commit is contained in:
parent
045fe0bf21
commit
32b3452e76
@ -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(
|
||||||
|
@ -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)
|
||||||
|
@ -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}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user