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:
parent
b77771497d
commit
d5ca99dfff
@ -35,6 +35,7 @@ class SendAudio(BaseClient):
|
|||||||
duration: int = 0,
|
duration: int = 0,
|
||||||
performer: str = None,
|
performer: str = None,
|
||||||
title: str = None,
|
title: str = None,
|
||||||
|
thumb: str = None,
|
||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
reply_markup=None,
|
reply_markup=None,
|
||||||
@ -74,6 +75,11 @@ class SendAudio(BaseClient):
|
|||||||
title (``str``, *optional*):
|
title (``str``, *optional*):
|
||||||
Track name.
|
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*):
|
disable_notification (``bool``, *optional*):
|
||||||
Sends the message silently.
|
Sends the message silently.
|
||||||
Users will receive a notification with no sound.
|
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
|
style = self.html if parse_mode.lower() == "html" else self.markdown
|
||||||
|
|
||||||
if os.path.exists(audio):
|
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)
|
file = self.save_file(audio, progress=progress, progress_args=progress_args)
|
||||||
media = types.InputMediaUploadedDocument(
|
media = types.InputMediaUploadedDocument(
|
||||||
mime_type=mimetypes.types_map.get("." + audio.split(".")[-1], "audio/mpeg"),
|
mime_type=mimetypes.types_map.get("." + audio.split(".")[-1], "audio/mpeg"),
|
||||||
file=file,
|
file=file,
|
||||||
|
thumb=thumb,
|
||||||
attributes=[
|
attributes=[
|
||||||
types.DocumentAttributeAudio(
|
types.DocumentAttributeAudio(
|
||||||
duration=duration,
|
duration=duration,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user