mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Merge branch 'master' of https://github.com/SwissCorePy/pyTelegramBotAPI
This commit is contained in:
commit
3a4cf47def
@ -1123,7 +1123,8 @@ class TeleBot:
|
|||||||
timeout: Optional[int]=None,
|
timeout: Optional[int]=None,
|
||||||
thumb: Optional[Union[Any, str]]=None,
|
thumb: Optional[Union[Any, str]]=None,
|
||||||
caption_entities: Optional[List[types.MessageEntity]]=None,
|
caption_entities: Optional[List[types.MessageEntity]]=None,
|
||||||
allow_sending_without_reply: Optional[bool]=None) -> types.Message:
|
allow_sending_without_reply: Optional[bool]=None,
|
||||||
|
visible_file_name: Optional[str]=None) -> types.Message:
|
||||||
"""
|
"""
|
||||||
Use this method to send general files.
|
Use this method to send general files.
|
||||||
:param chat_id:
|
:param chat_id:
|
||||||
@ -1137,6 +1138,7 @@ class TeleBot:
|
|||||||
:param thumb: InputFile or String : Thumbnail of the file sent
|
:param thumb: InputFile or String : Thumbnail of the file sent
|
||||||
:param caption_entities:
|
:param caption_entities:
|
||||||
:param allow_sending_without_reply:
|
:param allow_sending_without_reply:
|
||||||
|
:param visible_file_name: allows to define file name that will be visible in the Telegram instead of original file name
|
||||||
:return: API reply.
|
:return: API reply.
|
||||||
"""
|
"""
|
||||||
parse_mode = self.parse_mode if (parse_mode is None) else parse_mode
|
parse_mode = self.parse_mode if (parse_mode is None) else parse_mode
|
||||||
@ -1145,7 +1147,7 @@ class TeleBot:
|
|||||||
apihelper.send_data(
|
apihelper.send_data(
|
||||||
self.token, chat_id, data, 'document', reply_to_message_id, reply_markup,
|
self.token, chat_id, data, 'document', reply_to_message_id, reply_markup,
|
||||||
parse_mode, disable_notification, timeout, caption, thumb, caption_entities,
|
parse_mode, disable_notification, timeout, caption, thumb, caption_entities,
|
||||||
allow_sending_without_reply))
|
allow_sending_without_reply, visible_file_name))
|
||||||
|
|
||||||
def send_sticker(
|
def send_sticker(
|
||||||
self, chat_id: Union[int, str], data: Union[Any, str],
|
self, chat_id: Union[int, str], data: Union[Any, str],
|
||||||
|
@ -806,12 +806,15 @@ def send_audio(token, chat_id, audio, caption=None, duration=None, performer=Non
|
|||||||
|
|
||||||
def send_data(token, chat_id, data, data_type, reply_to_message_id=None, reply_markup=None, parse_mode=None,
|
def send_data(token, chat_id, data, data_type, reply_to_message_id=None, reply_markup=None, parse_mode=None,
|
||||||
disable_notification=None, timeout=None, caption=None, thumb=None, caption_entities=None,
|
disable_notification=None, timeout=None, caption=None, thumb=None, caption_entities=None,
|
||||||
allow_sending_without_reply=None, disable_content_type_detection=None):
|
allow_sending_without_reply=None, disable_content_type_detection=None, visible_file_name=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
|
||||||
if not util.is_string(data):
|
if not util.is_string(data):
|
||||||
files = {data_type: data}
|
file_data = data
|
||||||
|
if visible_file_name:
|
||||||
|
file_data = (visible_file_name, data)
|
||||||
|
files = {data_type: file_data}
|
||||||
else:
|
else:
|
||||||
payload[data_type] = data
|
payload[data_type] = data
|
||||||
if reply_to_message_id:
|
if reply_to_message_id:
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
# Versions should comply with PEP440.
|
# Versions should comply with PEP440.
|
||||||
# This line is parsed in setup.py:
|
# This line is parsed in setup.py:
|
||||||
__version__ = '3.8.0'
|
__version__ = '3.8.1'
|
||||||
|
@ -134,6 +134,16 @@ 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_with_filename(self):
|
||||||
|
file_data = open('../examples/detailed_example/kitten.jpg', 'rb')
|
||||||
|
tb = telebot.TeleBot(TOKEN)
|
||||||
|
|
||||||
|
ret_msg = tb.send_document(CHAT_ID, file_data)
|
||||||
|
assert ret_msg.message_id
|
||||||
|
|
||||||
|
ret_msg = tb.send_document(CHAT_ID, file_data, visible_file_name="test.jpg")
|
||||||
|
assert ret_msg.message_id
|
||||||
|
|
||||||
def test_send_file_dis_noti(self):
|
def test_send_file_dis_noti(self):
|
||||||
file_data = open('../examples/detailed_example/kitten.jpg', 'rb')
|
file_data = open('../examples/detailed_example/kitten.jpg', 'rb')
|
||||||
tb = telebot.TeleBot(TOKEN)
|
tb = telebot.TeleBot(TOKEN)
|
||||||
|
Loading…
Reference in New Issue
Block a user