fixing formatting of caption in the method send_document

This commit is contained in:
heyyyoyy 2018-02-16 18:29:29 +03:00
parent 903b1dfd50
commit 518c49f23a
3 changed files with 13 additions and 6 deletions

View File

@ -503,8 +503,8 @@ class TeleBot:
parse_mode, disable_notification)) parse_mode, disable_notification))
def send_audio(self, chat_id, audio, caption=None, duration=None, performer=None, title=None, def send_audio(self, chat_id, audio, caption=None, duration=None, performer=None, title=None,
reply_to_message_id=None, reply_to_message_id=None, reply_markup=None, parse_mode=None, disable_notification=None,
reply_markup=None, parse_mode=None, disable_notification=None, timeout=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. 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 :param chat_id:Unique identifier for the message recipient
@ -545,7 +545,8 @@ class TeleBot:
:param data: :param data:
:param reply_to_message_id: :param reply_to_message_id:
:param reply_markup: :param reply_markup:
:param parse_mode :param parse_mode:
:param disable_notification:
:return: API reply. :return: API reply.
""" """
return types.Message.de_json( return types.Message.de_json(

View File

@ -460,8 +460,8 @@ def send_audio(token, chat_id, audio, caption=None, duration=None, performer=Non
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, def send_data(token, chat_id, data, data_type, reply_to_message_id=None, reply_markup=None, parse_mode=None,
timeout=None, parse_mode=None, caption=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

View File

@ -467,4 +467,10 @@ class TestTeleBot:
assert len(result) == 2 assert len(result) == 2
assert result[0].media_group_id is not None assert result[0].media_group_id is not None
assert result[0].caption_entities[0].type == 'bold' assert result[0].caption_entities[0].type == 'bold'
assert result[1].caption_entities[0].type == 'italic' assert result[1].caption_entities[0].type == 'italic'
def test_send_document_formating_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='_italic_', parse_mode='Markdown')
assert ret_msg.caption_entities[0].type == 'italic'