mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-23 06:50:29 +01:00
Add caption fields to voice and audio
Or at least the methods/classes for sending.
This commit is contained in:
parent
c3e07b1056
commit
f7ede4baea
6 changed files with 43 additions and 7 deletions
|
@ -323,7 +323,14 @@ class Bot(TelegramObject):
|
||||||
|
|
||||||
@log
|
@log
|
||||||
@message
|
@message
|
||||||
def sendAudio(self, chat_id, audio, duration=None, performer=None, title=None, **kwargs):
|
def sendAudio(self,
|
||||||
|
chat_id,
|
||||||
|
audio,
|
||||||
|
duration=None,
|
||||||
|
performer=None,
|
||||||
|
title=None,
|
||||||
|
caption=None,
|
||||||
|
**kwargs):
|
||||||
"""Use this method to send audio files, if you want Telegram clients to
|
"""Use this method to send audio files, if you want Telegram clients to
|
||||||
display them in the music player. Your audio must be in an .mp3 format.
|
display them in the music player. Your audio must be in an .mp3 format.
|
||||||
On success, the sent Message is returned. Bots can currently send audio
|
On success, the sent Message is returned. Bots can currently send audio
|
||||||
|
@ -348,6 +355,8 @@ class Bot(TelegramObject):
|
||||||
Performer of sent audio. [Optional]
|
Performer of sent audio. [Optional]
|
||||||
title:
|
title:
|
||||||
Title of sent audio. [Optional]
|
Title of sent audio. [Optional]
|
||||||
|
caption:
|
||||||
|
Audio caption [Optional]
|
||||||
|
|
||||||
Keyword Args:
|
Keyword Args:
|
||||||
disable_notification (Optional[bool]): Sends the message silently.
|
disable_notification (Optional[bool]): Sends the message silently.
|
||||||
|
@ -381,6 +390,8 @@ class Bot(TelegramObject):
|
||||||
data['performer'] = performer
|
data['performer'] = performer
|
||||||
if title:
|
if title:
|
||||||
data['title'] = title
|
data['title'] = title
|
||||||
|
if caption:
|
||||||
|
data['caption'] = caption
|
||||||
|
|
||||||
return url, data
|
return url, data
|
||||||
|
|
||||||
|
@ -531,7 +542,7 @@ class Bot(TelegramObject):
|
||||||
|
|
||||||
@log
|
@log
|
||||||
@message
|
@message
|
||||||
def sendVoice(self, chat_id, voice, duration=None, **kwargs):
|
def sendVoice(self, chat_id, voice, duration=None, caption=None, **kwargs):
|
||||||
"""Use this method to send audio files, if you want Telegram clients to
|
"""Use this method to send audio files, if you want Telegram clients to
|
||||||
display the file as a playable voice message. For this to work, your
|
display the file as a playable voice message. For this to work, your
|
||||||
audio must be in an .ogg file encoded with OPUS (other formats may be
|
audio must be in an .ogg file encoded with OPUS (other formats may be
|
||||||
|
@ -548,6 +559,8 @@ class Bot(TelegramObject):
|
||||||
a new audio file using multipart/form-data.
|
a new audio file using multipart/form-data.
|
||||||
duration:
|
duration:
|
||||||
Duration of sent audio in seconds. [Optional]
|
Duration of sent audio in seconds. [Optional]
|
||||||
|
caption:
|
||||||
|
Voice caption [Optional]
|
||||||
|
|
||||||
Keyword Args:
|
Keyword Args:
|
||||||
disable_notification (Optional[bool]): Sends the message silently.
|
disable_notification (Optional[bool]): Sends the message silently.
|
||||||
|
@ -577,6 +590,8 @@ class Bot(TelegramObject):
|
||||||
|
|
||||||
if duration:
|
if duration:
|
||||||
data['duration'] = duration
|
data['duration'] = duration
|
||||||
|
if caption:
|
||||||
|
data['caption'] = caption
|
||||||
|
|
||||||
return url, data
|
return url, data
|
||||||
|
|
||||||
|
@ -1443,7 +1458,8 @@ class Bot(TelegramObject):
|
||||||
return (self.__class__, (self.token, self.base_url.replace(self.token, ''),
|
return (self.__class__, (self.token, self.base_url.replace(self.token, ''),
|
||||||
self.base_file_url.replace(self.token, '')))
|
self.base_file_url.replace(self.token, '')))
|
||||||
|
|
||||||
# snake_case (PEP8) aliases
|
# snake_case (PEP8) aliases
|
||||||
|
|
||||||
get_me = getMe
|
get_me = getMe
|
||||||
send_message = sendMessage
|
send_message = sendMessage
|
||||||
forward_message = forwardMessage
|
forward_message = forwardMessage
|
||||||
|
|
|
@ -32,6 +32,7 @@ class Chat(TelegramObject):
|
||||||
username (str): Username, for private chats and channels if available
|
username (str): Username, for private chats and channels if available
|
||||||
first_name (str): First name of the other party in a private chat
|
first_name (str): First name of the other party in a private chat
|
||||||
last_name (str): Last name of the other party in a private chat
|
last_name (str): Last name of the other party in a private chat
|
||||||
|
all_members_are_admins (bool): True if a group has ‘All Members Are Admins’ enabled.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
id (int):
|
id (int):
|
||||||
|
@ -57,6 +58,7 @@ class Chat(TelegramObject):
|
||||||
self.username = kwargs.get('username', '')
|
self.username = kwargs.get('username', '')
|
||||||
self.first_name = kwargs.get('first_name', '')
|
self.first_name = kwargs.get('first_name', '')
|
||||||
self.last_name = kwargs.get('last_name', '')
|
self.last_name = kwargs.get('last_name', '')
|
||||||
|
self.all_members_are_admins = kwargs.get('all_members_are_admins', '')
|
||||||
|
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ class InlineQueryResultAudio(InlineQueryResult):
|
||||||
title (str):
|
title (str):
|
||||||
performer (Optional[str]):
|
performer (Optional[str]):
|
||||||
audio_duration (Optional[str]):
|
audio_duration (Optional[str]):
|
||||||
|
caption (Optional[str]):
|
||||||
reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]):
|
reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]):
|
||||||
input_message_content (Optional[
|
input_message_content (Optional[
|
||||||
:class:`telegram.input_message_content`]):
|
:class:`telegram.input_message_content`]):
|
||||||
|
@ -53,6 +54,7 @@ class InlineQueryResultAudio(InlineQueryResult):
|
||||||
Keyword Args:
|
Keyword Args:
|
||||||
performer (Optional[str]):
|
performer (Optional[str]):
|
||||||
audio_duration (Optional[str]):
|
audio_duration (Optional[str]):
|
||||||
|
caption (Optional[str]):
|
||||||
reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]):
|
reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]):
|
||||||
input_message_content (Optional[
|
input_message_content (Optional[
|
||||||
:class:`telegram.input_message_content`]):
|
:class:`telegram.input_message_content`]):
|
||||||
|
@ -64,6 +66,7 @@ class InlineQueryResultAudio(InlineQueryResult):
|
||||||
title,
|
title,
|
||||||
performer=None,
|
performer=None,
|
||||||
audio_duration=None,
|
audio_duration=None,
|
||||||
|
caption=None,
|
||||||
reply_markup=None,
|
reply_markup=None,
|
||||||
input_message_content=None,
|
input_message_content=None,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
|
@ -78,6 +81,8 @@ class InlineQueryResultAudio(InlineQueryResult):
|
||||||
self.performer = performer
|
self.performer = performer
|
||||||
if audio_duration:
|
if audio_duration:
|
||||||
self.audio_duration = audio_duration
|
self.audio_duration = audio_duration
|
||||||
|
if caption:
|
||||||
|
self.caption = caption
|
||||||
if reply_markup:
|
if reply_markup:
|
||||||
self.reply_markup = reply_markup
|
self.reply_markup = reply_markup
|
||||||
if input_message_content:
|
if input_message_content:
|
||||||
|
|
|
@ -31,6 +31,7 @@ class InlineQueryResultCachedAudio(InlineQueryResult):
|
||||||
Attributes:
|
Attributes:
|
||||||
id (str):
|
id (str):
|
||||||
audio_file_id (str):
|
audio_file_id (str):
|
||||||
|
caption (Optional[str]):
|
||||||
reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]):
|
reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]):
|
||||||
input_message_content (Optional[
|
input_message_content (Optional[
|
||||||
:class:`telegram.input_message_content`]):
|
:class:`telegram.input_message_content`]):
|
||||||
|
@ -48,17 +49,26 @@ class InlineQueryResultCachedAudio(InlineQueryResult):
|
||||||
**kwargs: Arbitrary keyword arguments.
|
**kwargs: Arbitrary keyword arguments.
|
||||||
|
|
||||||
Keyword Args:
|
Keyword Args:
|
||||||
|
caption (Optional[str]):
|
||||||
reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]):
|
reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]):
|
||||||
input_message_content (Optional[
|
input_message_content (Optional[
|
||||||
:class:`telegram.input_message_content`]):
|
:class:`telegram.input_message_content`]):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, id, audio_file_id, reply_markup=None, input_message_content=None, **kwargs):
|
def __init__(self,
|
||||||
|
id,
|
||||||
|
audio_file_id,
|
||||||
|
caption=None,
|
||||||
|
reply_markup=None,
|
||||||
|
input_message_content=None,
|
||||||
|
**kwargs):
|
||||||
# Required
|
# Required
|
||||||
super(InlineQueryResultCachedAudio, self).__init__('audio', id)
|
super(InlineQueryResultCachedAudio, self).__init__('audio', id)
|
||||||
self.audio_file_id = audio_file_id
|
self.audio_file_id = audio_file_id
|
||||||
|
|
||||||
# Optionals
|
# Optionals
|
||||||
|
if caption:
|
||||||
|
self.caption = caption
|
||||||
if reply_markup:
|
if reply_markup:
|
||||||
self.reply_markup = reply_markup
|
self.reply_markup = reply_markup
|
||||||
if input_message_content:
|
if input_message_content:
|
||||||
|
|
|
@ -28,7 +28,7 @@ class InlineQueryResultCachedVoice(InlineQueryResult):
|
||||||
id,
|
id,
|
||||||
voice_file_id,
|
voice_file_id,
|
||||||
title,
|
title,
|
||||||
description=None,
|
caption=None,
|
||||||
reply_markup=None,
|
reply_markup=None,
|
||||||
input_message_content=None,
|
input_message_content=None,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
|
@ -38,8 +38,8 @@ class InlineQueryResultCachedVoice(InlineQueryResult):
|
||||||
self.title = title
|
self.title = title
|
||||||
|
|
||||||
# Optionals
|
# Optionals
|
||||||
if description:
|
if caption:
|
||||||
self.description = description
|
self.caption = caption
|
||||||
if reply_markup:
|
if reply_markup:
|
||||||
self.reply_markup = reply_markup
|
self.reply_markup = reply_markup
|
||||||
if input_message_content:
|
if input_message_content:
|
||||||
|
|
|
@ -29,6 +29,7 @@ class InlineQueryResultVoice(InlineQueryResult):
|
||||||
voice_url,
|
voice_url,
|
||||||
title,
|
title,
|
||||||
voice_duration=None,
|
voice_duration=None,
|
||||||
|
caption=None,
|
||||||
reply_markup=None,
|
reply_markup=None,
|
||||||
input_message_content=None,
|
input_message_content=None,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
|
@ -41,6 +42,8 @@ class InlineQueryResultVoice(InlineQueryResult):
|
||||||
# Optional
|
# Optional
|
||||||
if voice_duration:
|
if voice_duration:
|
||||||
self.voice_duration = voice_duration
|
self.voice_duration = voice_duration
|
||||||
|
if caption:
|
||||||
|
self.caption = caption
|
||||||
if reply_markup:
|
if reply_markup:
|
||||||
self.reply_markup = reply_markup
|
self.reply_markup = reply_markup
|
||||||
if input_message_content:
|
if input_message_content:
|
||||||
|
|
Loading…
Reference in a new issue