mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Fix #179.
This commit is contained in:
parent
a0f25089e0
commit
ce24aa25f2
@ -365,7 +365,7 @@ class TeleBot:
|
|||||||
apihelper.send_voice(self.token, chat_id, voice, duration, reply_to_message_id, reply_markup,
|
apihelper.send_voice(self.token, chat_id, voice, duration, reply_to_message_id, reply_markup,
|
||||||
disable_notification, timeout))
|
disable_notification, timeout))
|
||||||
|
|
||||||
def send_document(self, chat_id, data, reply_to_message_id=None, reply_markup=None, disable_notification=None, timeout=None):
|
def send_document(self, chat_id, data, reply_to_message_id=None, caption=None, reply_markup=None, disable_notification=None, timeout=None):
|
||||||
"""
|
"""
|
||||||
Use this method to send general files.
|
Use this method to send general files.
|
||||||
:param chat_id:
|
:param chat_id:
|
||||||
@ -376,7 +376,7 @@ class TeleBot:
|
|||||||
"""
|
"""
|
||||||
return types.Message.de_json(
|
return types.Message.de_json(
|
||||||
apihelper.send_data(self.token, chat_id, data, 'document', reply_to_message_id, reply_markup,
|
apihelper.send_data(self.token, chat_id, data, 'document', reply_to_message_id, reply_markup,
|
||||||
disable_notification, timeout))
|
disable_notification, timeout, caption=caption))
|
||||||
|
|
||||||
def send_sticker(self, chat_id, data, reply_to_message_id=None, reply_markup=None, disable_notification=None, timeout=None):
|
def send_sticker(self, chat_id, data, reply_to_message_id=None, reply_markup=None, disable_notification=None, timeout=None):
|
||||||
"""
|
"""
|
||||||
|
@ -298,7 +298,8 @@ def send_audio(token, chat_id, audio, duration=None, performer=None, title=None,
|
|||||||
return _make_request(token, method_url, params=payload, files=files, method='post')
|
return _make_request(token, method_url, params=payload, files=files, method='post')
|
||||||
|
|
||||||
|
|
||||||
def send_data(token, chat_id, data, data_type, reply_to_message_id=None, reply_markup=None, disable_notification=None, timeout=None):
|
def send_data(token, chat_id, data, data_type, reply_to_message_id=None, reply_markup=None, disable_notification=None,
|
||||||
|
timeout=None, caption=None):
|
||||||
method_url = get_method_by_type(data_type)
|
method_url = get_method_by_type(data_type)
|
||||||
payload = {'chat_id': chat_id}
|
payload = {'chat_id': chat_id}
|
||||||
files = None
|
files = None
|
||||||
@ -314,6 +315,8 @@ def send_data(token, chat_id, data, data_type, reply_to_message_id=None, reply_m
|
|||||||
payload['disable_notification'] = disable_notification
|
payload['disable_notification'] = disable_notification
|
||||||
if timeout:
|
if timeout:
|
||||||
payload['connect-timeout'] = timeout
|
payload['connect-timeout'] = timeout
|
||||||
|
if caption:
|
||||||
|
payload['caption'] = caption
|
||||||
return _make_request(token, method_url, params=payload, files=files, method='post')
|
return _make_request(token, method_url, params=payload, files=files, method='post')
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,6 +129,15 @@ class TestTeleBot:
|
|||||||
ret_msg = tb.send_document(CHAT_ID, ret_msg.document.file_id)
|
ret_msg = tb.send_document(CHAT_ID, ret_msg.document.file_id)
|
||||||
assert ret_msg.message_id
|
assert ret_msg.message_id
|
||||||
|
|
||||||
|
def test_send_file_caption(self):
|
||||||
|
file_data = open('../examples/detailed_example/kitten.jpg', 'rb')
|
||||||
|
tb = telebot.TeleBot(TOKEN)
|
||||||
|
ret_msg = tb.send_document(CHAT_ID, file_data, caption="Test")
|
||||||
|
assert ret_msg.message_id
|
||||||
|
|
||||||
|
ret_msg = tb.send_document(CHAT_ID, ret_msg.document.file_id)
|
||||||
|
assert ret_msg.message_id
|
||||||
|
|
||||||
def test_send_video(self):
|
def test_send_video(self):
|
||||||
file_data = open('./test_data/test_video.mp4', 'rb')
|
file_data = open('./test_data/test_video.mp4', 'rb')
|
||||||
tb = telebot.TeleBot(TOKEN)
|
tb = telebot.TeleBot(TOKEN)
|
||||||
|
Loading…
Reference in New Issue
Block a user