2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 12:57:52 +00:00

Make send_document and send_video_note accept a thumbnail

#119
This commit is contained in:
Dan 2018-09-18 11:37:11 +02:00
parent 61e6e58be7
commit 42ea51cb77
2 changed files with 18 additions and 0 deletions

View File

@ -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))
]

View File

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