From 5e26ae189463e306063f1bb45d90d51372fdda83 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 14 Apr 2018 20:49:16 +0200 Subject: [PATCH] Enhance send_video_note by accepting file_ids --- pyrogram/client/client.py | 69 +++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 18 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 34820205..4547429d 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -1884,7 +1884,9 @@ class Client: video_note (``str``): Video note to send. - Pass a file path as string to send a video note that exists on your local machine. + Pass a file_id as string to send a video note that exists on the Telegram servers, or + pass a file path as string to upload a new video note that exists on your local machine. + Sending video notes by a URL is currently unsupported. duration (``int``, optional): Duration of sent video in seconds. @@ -1911,40 +1913,71 @@ class Client: The size of the file. Returns: - On success, the sent Message is returned. + On success, the sent :obj:`Message ` is returned. Raises: :class:`Error ` """ - file = self.save_file(video_note, progress=progress) + file = None + + if os.path.exists(video_note): + file = self.save_file(video_note, progress=progress) + media = types.InputMediaUploadedDocument( + mime_type=mimetypes.types_map[".mp4"], + file=file, + attributes=[ + types.DocumentAttributeVideo( + round_message=True, + duration=duration, + w=length, + h=length + ) + ] + ) + else: + try: + decoded = utils.decode(video_note) + fmt = " 24 else "