2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +00:00

Allow to set audio thumbnail when using send_audio

With the Bot API 4.0 update (https://core.telegram.org/bots/api#july-26-2018), sendAudio allows bots to pass a thumbnail - making it possible for pyrogram to include a 'thumb' parameter in its convenience method 'send_audio'
This commit is contained in:
zeroone2numeral2 2018-08-30 11:50:09 +02:00
parent b77771497d
commit d5ca99dfff

View File

@ -35,6 +35,7 @@ class SendAudio(BaseClient):
duration: int = 0,
performer: str = None,
title: str = None,
thumb: str = None,
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup=None,
@ -74,6 +75,11 @@ class SendAudio(BaseClient):
title (``str``, *optional*):
Track name.
thumb (``str``, *optional*):
Audio thumbnail.
Pass a file path as string to send an image that exists on your local machine.
Thumbnail should have 90 or less pixels of width and 90 or less pixels of height.
disable_notification (``bool``, *optional*):
Sends the message silently.
Users will receive a notification with no sound.
@ -118,10 +124,12 @@ class SendAudio(BaseClient):
style = self.html if parse_mode.lower() == "html" else self.markdown
if os.path.exists(audio):
thumb = None if thumb is None else self.save_file(thumb)
file = self.save_file(audio, progress=progress, progress_args=progress_args)
media = types.InputMediaUploadedDocument(
mime_type=mimetypes.types_map.get("." + audio.split(".")[-1], "audio/mpeg"),
file=file,
thumb=thumb,
attributes=[
types.DocumentAttributeAudio(
duration=duration,