From 42ea51cb77f47ee2d8bdfbde891270c686b256f5 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Tue, 18 Sep 2018 11:37:11 +0200 Subject: [PATCH] Make send_document and send_video_note accept a thumbnail #119 --- pyrogram/client/methods/messages/send_document.py | 9 +++++++++ pyrogram/client/methods/messages/send_video_note.py | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/pyrogram/client/methods/messages/send_document.py b/pyrogram/client/methods/messages/send_document.py index 01c3eca5..28d93f07 100644 --- a/pyrogram/client/methods/messages/send_document.py +++ b/pyrogram/client/methods/messages/send_document.py @@ -30,6 +30,7 @@ class SendDocument(BaseClient): def send_document(self, chat_id: int or str, document: str, + thumb: str = None, caption: str = "", parse_mode: str = "", disable_notification: bool = None, @@ -51,6 +52,12 @@ class SendDocument(BaseClient): pass an HTTP URL as a string for Telegram to get a file from the Internet, or pass a file path as string to upload a new file that exists on your local machine. + thumb (``str``): + Thumbnail of the file sent. + The thumbnail should be in JPEG format and less than 200 KB in size. + A thumbnail's width and height should not exceed 90 pixels. + Thumbnails can't be reused and can be only uploaded as a new file. + caption (``str``, *optional*): Document caption, 0-200 characters. @@ -103,10 +110,12 @@ class SendDocument(BaseClient): style = self.html if parse_mode.lower() == "html" else self.markdown if os.path.exists(document): + thumb = None if thumb is None else self.save_file(thumb) file = self.save_file(document, progress=progress, progress_args=progress_args) media = types.InputMediaUploadedDocument( mime_type=mimetypes.types_map.get("." + document.split(".")[-1], "text/plain"), file=file, + thumb=thumb, attributes=[ types.DocumentAttributeFilename(os.path.basename(document)) ] diff --git a/pyrogram/client/methods/messages/send_video_note.py b/pyrogram/client/methods/messages/send_video_note.py index 6adc6497..6da1962a 100644 --- a/pyrogram/client/methods/messages/send_video_note.py +++ b/pyrogram/client/methods/messages/send_video_note.py @@ -32,6 +32,7 @@ class SendVideoNote(BaseClient): video_note: str, duration: int = 0, length: int = 1, + thumb: str = None, disable_notification: bool = None, reply_to_message_id: int = None, reply_markup=None, @@ -57,6 +58,12 @@ class SendVideoNote(BaseClient): length (``int``, *optional*): Video width and height. + thumb (``str``, *optional*): + Thumbnail of the video sent. + The thumbnail should be in JPEG format and less than 200 KB in size. + A thumbnail's width and height should not exceed 90 pixels. + Thumbnails can't be reused and can be only uploaded as a new file. + disable_notification (``bool``, *optional*): Sends the message silently. Users will receive a notification with no sound. @@ -100,10 +107,12 @@ class SendVideoNote(BaseClient): file = None if os.path.exists(video_note): + thumb = None if thumb is None else self.save_file(thumb) file = self.save_file(video_note, progress=progress, progress_args=progress_args) media = types.InputMediaUploadedDocument( mime_type=mimetypes.types_map[".mp4"], file=file, + thumb=thumb, attributes=[ types.DocumentAttributeVideo( round_message=True,