1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Merge pull request #892 from Otxoto/Otxoto-patch-2

Added thumbnail support for send_audio and send_video
This commit is contained in:
Badiboy 2020-06-24 19:10:15 +03:00 committed by GitHub
commit d43292e42b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 6 deletions

View File

@ -695,7 +695,7 @@ class TeleBot:
def send_audio(self, chat_id, audio, caption=None, duration=None, performer=None, title=None,
reply_to_message_id=None, reply_markup=None, parse_mode=None, disable_notification=None,
timeout=None):
timeout=None, thumb=None):
"""
Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format.
:param chat_id:Unique identifier for the message recipient
@ -709,11 +709,12 @@ class TeleBot:
:param parse_mode
:param disable_notification:
:param timeout:
:param thumb:
:return: Message
"""
return types.Message.de_json(
apihelper.send_audio(self.token, chat_id, audio, caption, duration, performer, title, reply_to_message_id,
reply_markup, parse_mode, disable_notification, timeout))
reply_markup, parse_mode, disable_notification, timeout, thumb))
def send_voice(self, chat_id, voice, caption=None, duration=None, reply_to_message_id=None, reply_markup=None,
parse_mode=None, disable_notification=None, timeout=None):
@ -771,7 +772,7 @@ class TeleBot:
disable_notification, timeout))
def send_video(self, chat_id, data, duration=None, caption=None, reply_to_message_id=None, reply_markup=None,
parse_mode=None, supports_streaming=None, disable_notification=None, timeout=None):
parse_mode=None, supports_streaming=None, disable_notification=None, timeout=None, thumb=None):
"""
Use this method to send video files, Telegram clients support mp4 videos.
:param chat_id: Integer : Unique identifier for the message recipient User or GroupChat id
@ -784,11 +785,12 @@ class TeleBot:
:param reply_markup:
:param disable_notification:
:param timeout:
:param thumb:
:return:
"""
return types.Message.de_json(
apihelper.send_video(self.token, chat_id, data, duration, caption, reply_to_message_id, reply_markup,
parse_mode, supports_streaming, disable_notification, timeout))
parse_mode, supports_streaming, disable_notification, timeout, thumb))
def send_animation(self, chat_id, animation, duration=None, caption=None, reply_to_message_id=None, reply_markup=None,
parse_mode=None, disable_notification=None, timeout=None):

View File

@ -435,7 +435,7 @@ def send_chat_action(token, chat_id, action, timeout=None):
def send_video(token, chat_id, data, duration=None, caption=None, reply_to_message_id=None, reply_markup=None,
parse_mode=None, supports_streaming=None, disable_notification=None, timeout=None):
parse_mode=None, supports_streaming=None, disable_notification=None, timeout=None, thumb=None):
method_url = r'sendVideo'
payload = {'chat_id': chat_id}
files = None
@ -459,6 +459,11 @@ def send_video(token, chat_id, data, duration=None, caption=None, reply_to_messa
payload['disable_notification'] = disable_notification
if timeout:
payload['connect-timeout'] = timeout
if thumb:
if not util.is_string(thumb):
files['thumb'] = thumb
else:
payload['thumb'] = thumb
return _make_request(token, method_url, params=payload, files=files, method='post')
@ -541,7 +546,7 @@ def send_video_note(token, chat_id, data, duration=None, length=None, reply_to_m
def send_audio(token, chat_id, audio, caption=None, duration=None, performer=None, title=None, reply_to_message_id=None,
reply_markup=None, parse_mode=None, disable_notification=None, timeout=None):
reply_markup=None, parse_mode=None, disable_notification=None, timeout=None, thumb=None):
method_url = r'sendAudio'
payload = {'chat_id': chat_id}
files = None
@ -567,6 +572,11 @@ def send_audio(token, chat_id, audio, caption=None, duration=None, performer=Non
payload['disable_notification'] = disable_notification
if timeout:
payload['connect-timeout'] = timeout
if thumb:
if not util.is_string(thumb):
files['thumb'] = thumb
else:
payload['thumb'] = thumb
return _make_request(token, method_url, params=payload, files=files, method='post')