pyrofork: Add view_once parameter to send_video and Message.reply_video

Signed-off-by: wulan17 <wulan17@komodos.id>
This commit is contained in:
wulan17 2025-05-13 20:25:26 +07:00
parent beb5b5138b
commit e2e4f13946
No known key found for this signature in database
GPG key ID: 737814D4B5FF0420
2 changed files with 14 additions and 4 deletions

View file

@ -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=[

View file

@ -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,