Merge pull request #556 from drizzt/video-ttl_seconds
Add ttl_seconds support for send_video and reply_video
This commit is contained in:
commit
1835b62a40
@ -37,6 +37,7 @@ class SendVideo(Scaffold):
|
|||||||
caption: str = "",
|
caption: str = "",
|
||||||
parse_mode: Union[str, None] = object,
|
parse_mode: Union[str, None] = object,
|
||||||
caption_entities: List["types.MessageEntity"] = None,
|
caption_entities: List["types.MessageEntity"] = None,
|
||||||
|
ttl_seconds: int = None,
|
||||||
duration: int = 0,
|
duration: int = 0,
|
||||||
width: int = 0,
|
width: int = 0,
|
||||||
height: int = 0,
|
height: int = 0,
|
||||||
@ -83,6 +84,11 @@ class SendVideo(Scaffold):
|
|||||||
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
|
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
|
||||||
List of special entities that appear in the caption, which can be specified instead of __parse_mode__.
|
List of special entities that appear in the caption, which can be specified instead of __parse_mode__.
|
||||||
|
|
||||||
|
ttl_seconds (``int``, *optional*):
|
||||||
|
Self-Destruct Timer.
|
||||||
|
If you set a timer, the video will self-destruct in *ttl_seconds*
|
||||||
|
seconds after it was viewed.
|
||||||
|
|
||||||
duration (``int``, *optional*):
|
duration (``int``, *optional*):
|
||||||
Duration of sent video in seconds.
|
Duration of sent video in seconds.
|
||||||
|
|
||||||
@ -155,6 +161,9 @@ class SendVideo(Scaffold):
|
|||||||
# Add caption to the video
|
# Add caption to the video
|
||||||
app.send_video("me", "video.mp4", caption="recording")
|
app.send_video("me", "video.mp4", caption="recording")
|
||||||
|
|
||||||
|
# Send self-destructing video
|
||||||
|
app.send_photo("me", "video.mp4", ttl_seconds=10)
|
||||||
|
|
||||||
# Keep track of the progress while uploading
|
# Keep track of the progress while uploading
|
||||||
def progress(current, total):
|
def progress(current, total):
|
||||||
print(f"{current * 100 / total:.1f}%")
|
print(f"{current * 100 / total:.1f}%")
|
||||||
@ -171,6 +180,7 @@ class SendVideo(Scaffold):
|
|||||||
media = raw.types.InputMediaUploadedDocument(
|
media = raw.types.InputMediaUploadedDocument(
|
||||||
mime_type=self.guess_mime_type(video) or "video/mp4",
|
mime_type=self.guess_mime_type(video) or "video/mp4",
|
||||||
file=file,
|
file=file,
|
||||||
|
ttl_seconds=ttl_seconds,
|
||||||
thumb=thumb,
|
thumb=thumb,
|
||||||
attributes=[
|
attributes=[
|
||||||
raw.types.DocumentAttributeVideo(
|
raw.types.DocumentAttributeVideo(
|
||||||
@ -184,7 +194,8 @@ class SendVideo(Scaffold):
|
|||||||
)
|
)
|
||||||
elif re.match("^https?://", video):
|
elif re.match("^https?://", video):
|
||||||
media = raw.types.InputMediaDocumentExternal(
|
media = raw.types.InputMediaDocumentExternal(
|
||||||
url=video
|
url=video,
|
||||||
|
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)
|
||||||
@ -194,6 +205,7 @@ class SendVideo(Scaffold):
|
|||||||
media = raw.types.InputMediaUploadedDocument(
|
media = raw.types.InputMediaUploadedDocument(
|
||||||
mime_type=self.guess_mime_type(video.name) or "video/mp4",
|
mime_type=self.guess_mime_type(video.name) or "video/mp4",
|
||||||
file=file,
|
file=file,
|
||||||
|
ttl_seconds=ttl_seconds,
|
||||||
thumb=thumb,
|
thumb=thumb,
|
||||||
attributes=[
|
attributes=[
|
||||||
raw.types.DocumentAttributeVideo(
|
raw.types.DocumentAttributeVideo(
|
||||||
|
@ -2124,6 +2124,7 @@ class Message(Object, Update):
|
|||||||
caption: str = "",
|
caption: str = "",
|
||||||
parse_mode: Union[str, None] = object,
|
parse_mode: Union[str, None] = object,
|
||||||
caption_entities: List["types.MessageEntity"] = None,
|
caption_entities: List["types.MessageEntity"] = None,
|
||||||
|
ttl_seconds: int = None,
|
||||||
duration: int = 0,
|
duration: int = 0,
|
||||||
width: int = 0,
|
width: int = 0,
|
||||||
height: int = 0,
|
height: int = 0,
|
||||||
@ -2181,6 +2182,11 @@ class Message(Object, Update):
|
|||||||
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
|
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
|
||||||
List of special entities that appear in the caption, which can be specified instead of __parse_mode__.
|
List of special entities that appear in the caption, which can be specified instead of __parse_mode__.
|
||||||
|
|
||||||
|
ttl_seconds (``int``, *optional*):
|
||||||
|
Self-Destruct Timer.
|
||||||
|
If you set a timer, the video will self-destruct in *ttl_seconds*
|
||||||
|
seconds after it was viewed.
|
||||||
|
|
||||||
duration (``int``, *optional*):
|
duration (``int``, *optional*):
|
||||||
Duration of sent video in seconds.
|
Duration of sent video in seconds.
|
||||||
|
|
||||||
@ -2252,6 +2258,7 @@ class Message(Object, Update):
|
|||||||
caption=caption,
|
caption=caption,
|
||||||
parse_mode=parse_mode,
|
parse_mode=parse_mode,
|
||||||
caption_entities=caption_entities,
|
caption_entities=caption_entities,
|
||||||
|
ttl_seconds=ttl_seconds,
|
||||||
duration=duration,
|
duration=duration,
|
||||||
width=width,
|
width=width,
|
||||||
height=height,
|
height=height,
|
||||||
|
Loading…
Reference in New Issue
Block a user