mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-26 19:33:45 +03:00
client: add thumbnail support for send_file()
This commit is contained in:
parent
78871b697e
commit
2c437c51bb
|
@ -631,6 +631,7 @@ class TelegramClient(TelegramBareClient):
|
||||||
force_document=False, progress_callback=None,
|
force_document=False, progress_callback=None,
|
||||||
reply_to=None,
|
reply_to=None,
|
||||||
attributes=None,
|
attributes=None,
|
||||||
|
thumb=None,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
"""
|
"""
|
||||||
Sends a file to the specified entity.
|
Sends a file to the specified entity.
|
||||||
|
@ -658,6 +659,8 @@ class TelegramClient(TelegramBareClient):
|
||||||
:param attributes:
|
:param attributes:
|
||||||
Optional attributes that override the inferred ones, like
|
Optional attributes that override the inferred ones, like
|
||||||
DocumentAttributeFilename and so on.
|
DocumentAttributeFilename and so on.
|
||||||
|
:param thumb:
|
||||||
|
Optional thumbnail (for videos).
|
||||||
:param kwargs:
|
:param kwargs:
|
||||||
If "is_voice_note" in kwargs, despite its value, and the file is
|
If "is_voice_note" in kwargs, despite its value, and the file is
|
||||||
sent as a document, it will be sent as a voice note.
|
sent as a document, it will be sent as a voice note.
|
||||||
|
@ -716,11 +719,16 @@ class TelegramClient(TelegramBareClient):
|
||||||
if not mime_type:
|
if not mime_type:
|
||||||
mime_type = 'application/octet-stream'
|
mime_type = 'application/octet-stream'
|
||||||
|
|
||||||
|
input_kw = {}
|
||||||
|
if thumb:
|
||||||
|
input_kw['thumb'] = self.upload_file(thumb)
|
||||||
|
|
||||||
media = InputMediaUploadedDocument(
|
media = InputMediaUploadedDocument(
|
||||||
file=file_handle,
|
file=file_handle,
|
||||||
mime_type=mime_type,
|
mime_type=mime_type,
|
||||||
attributes=list(attr_dict.values()),
|
attributes=list(attr_dict.values()),
|
||||||
caption=caption
|
caption=caption,
|
||||||
|
**input_kw
|
||||||
)
|
)
|
||||||
|
|
||||||
# Once the media type is properly specified and the file uploaded,
|
# Once the media type is properly specified and the file uploaded,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user