From e2e4f13946bedc9cdba48475210f7475ef0181d0 Mon Sep 17 00:00:00 2001 From: wulan17 Date: Tue, 13 May 2025 20:25:26 +0700 Subject: [PATCH] pyrofork: Add view_once parameter to send_video and Message.reply_video Signed-off-by: wulan17 --- pyrogram/methods/messages/send_video.py | 13 +++++++++---- pyrogram/types/messages_and_media/message.py | 5 +++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pyrogram/methods/messages/send_video.py b/pyrogram/methods/messages/send_video.py index af2a539d..5689dc5a 100644 --- a/pyrogram/methods/messages/send_video.py +++ b/pyrogram/methods/messages/send_video.py @@ -58,6 +58,7 @@ class SendVideo: protect_content: bool = None, allow_paid_broadcast: bool = None, message_effect_id: int = None, + view_once: bool = None, invert_media: bool = None, reply_markup: Union[ "types.InlineKeyboardMarkup", @@ -180,6 +181,10 @@ class SendVideo: message_effect_id (``int`` ``64-bit``, *optional*): Unique identifier of the message effect to be added to the message; for private chats only. + view_once (``bool``, *optional*): + Self-Destruct Timer. + If True, the photo will self-destruct after it was viewed. + invert_media (``bool``, *optional*): Inverts the position of the video and caption. @@ -298,7 +303,7 @@ class SendVideo: media = raw.types.InputMediaUploadedDocument( mime_type=self.guess_mime_type(video) or "video/mp4", file=file, - ttl_seconds=ttl_seconds, + ttl_seconds=(1 << 31) - 1 if view_once else ttl_seconds, spoiler=has_spoiler, thumb=thumb, attributes=[ @@ -316,13 +321,13 @@ class SendVideo: elif re.match("^https?://", video): media = raw.types.InputMediaDocumentExternal( url=video, - ttl_seconds=ttl_seconds, + ttl_seconds=(1 << 31) - 1 if view_once else ttl_seconds, spoiler=has_spoiler, video_cover=vidcover_file, video_timestamp=start_timestamp ) else: - media = utils.get_input_media_from_file_id(video, FileType.VIDEO, ttl_seconds=ttl_seconds) + media = utils.get_input_media_from_file_id(video, FileType.VIDEO, ttl_seconds=(1 << 31) - 1 if view_once else ttl_seconds) media.spoiler = has_spoiler else: thumb = await self.save_file(thumb) @@ -330,7 +335,7 @@ class SendVideo: media = raw.types.InputMediaUploadedDocument( mime_type=self.guess_mime_type(file_name or video.name) or "video/mp4", file=file, - ttl_seconds=ttl_seconds, + ttl_seconds=(1 << 31) - 1 if view_once else ttl_seconds, spoiler=has_spoiler, thumb=thumb, attributes=[ diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index d5cb3f94..69761464 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -3611,6 +3611,7 @@ class Message(Object, Update): quote_entities: List["types.MessageEntity"] = None, allow_paid_broadcast: bool = None, message_effect_id: int = None, + view_once: bool = None, cover: Union[str, BinaryIO] = None, start_timestamp: int = None, schedule_date: datetime = None, @@ -3734,6 +3735,9 @@ class Message(Object, Update): message_effect_id (``int`` ``64-bit``, *optional*): Unique identifier of the message effect to be added to the message; for private chats only. + view_once (``bool``, *optional*): + Pass True to send the video as a view-once message. + invert_media (``bool``, *optional*): Pass True to invert the video and caption position. @@ -3813,6 +3817,7 @@ class Message(Object, Update): quote_entities=quote_entities, allow_paid_broadcast=allow_paid_broadcast, message_effect_id=message_effect_id, + view_once=view_once, cover=cover, start_timestamp=start_timestamp, schedule_date=schedule_date,