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

Added optional connection (aka sending) timeouts to methods that may upload big chunks of data: send_audio, send_voice, send_document, send_sticker and send_video.

This commit is contained in:
Diego Muñoz Callejo
2016-05-22 18:35:20 +02:00
parent 747f14216b
commit 3413669a23
2 changed files with 25 additions and 15 deletions

View File

@@ -334,7 +334,7 @@ class TeleBot:
disable_notification))
def send_audio(self, chat_id, audio, duration=None, performer=None, title=None, reply_to_message_id=None,
reply_markup=None, disable_notification=None):
reply_markup=None, disable_notification=None, timeout=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
@@ -348,10 +348,10 @@ class TeleBot:
"""
return types.Message.de_json(
apihelper.send_audio(self.token, chat_id, audio, duration, performer, title, reply_to_message_id,
reply_markup, disable_notification))
reply_markup, disable_notification, timeout))
def send_voice(self, chat_id, voice, duration=None, reply_to_message_id=None, reply_markup=None,
disable_notification=None):
disable_notification=None, timeout=None):
"""
Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message.
:param chat_id:Unique identifier for the message recipient.
@@ -363,9 +363,9 @@ class TeleBot:
"""
return types.Message.de_json(
apihelper.send_voice(self.token, chat_id, voice, duration, reply_to_message_id, reply_markup,
disable_notification))
disable_notification, timeout))
def send_document(self, chat_id, data, reply_to_message_id=None, reply_markup=None, disable_notification=None):
def send_document(self, chat_id, data, reply_to_message_id=None, reply_markup=None, disable_notification=None, timeout=None):
"""
Use this method to send general files.
:param chat_id:
@@ -376,9 +376,9 @@ class TeleBot:
"""
return types.Message.de_json(
apihelper.send_data(self.token, chat_id, data, 'document', reply_to_message_id, reply_markup,
disable_notification))
disable_notification, timeout))
def send_sticker(self, chat_id, data, reply_to_message_id=None, reply_markup=None, disable_notification=None):
def send_sticker(self, chat_id, data, reply_to_message_id=None, reply_markup=None, disable_notification=None, timeout=None):
"""
Use this method to send .webp stickers.
:param chat_id:
@@ -389,10 +389,10 @@ class TeleBot:
"""
return types.Message.de_json(
apihelper.send_data(self.token, chat_id, data, 'sticker', reply_to_message_id, reply_markup,
disable_notification))
disable_notification, timeout))
def send_video(self, chat_id, data, duration=None, caption=None, reply_to_message_id=None, reply_markup=None,
disable_notification=None):
disable_notification=None, timeout=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
@@ -405,7 +405,7 @@ class TeleBot:
"""
return types.Message.de_json(
apihelper.send_video(self.token, chat_id, data, duration, caption, reply_to_message_id, reply_markup,
disable_notification))
disable_notification, timeout))
def send_location(self, chat_id, latitude, longitude, reply_to_message_id=None, reply_markup=None,
disable_notification=None):