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

Merge pull request #539 from Badiboy/master

"timeout" parameter for send_message
Fix kick_chat_member return type
HTML symbols not replaced
This commit is contained in:
Badiboy 2020-01-03 00:50:24 +03:00 committed by GitHub
commit 86644c05f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -579,7 +579,7 @@ class TeleBot:
return types.ChatMember.de_json(result)
def send_message(self, chat_id, text, disable_web_page_preview=None, reply_to_message_id=None, reply_markup=None,
parse_mode=None, disable_notification=None):
parse_mode=None, disable_notification=None, timeout=None):
"""
Use this method to send text messages.
@ -597,7 +597,7 @@ class TeleBot:
"""
return types.Message.de_json(
apihelper.send_message(self.token, chat_id, text, disable_web_page_preview, reply_to_message_id,
reply_markup, parse_mode, disable_notification))
reply_markup, parse_mode, disable_notification, timeout))
def forward_message(self, chat_id, from_chat_id, message_id, disable_notification=None):
"""
@ -843,7 +843,7 @@ class TeleBot:
:param user_id: Int : Unique identifier of the target user
:param until_date: Date when the user will be unbanned, unix time. If user is banned for more than 366 days or
less than 30 seconds from the current time they are considered to be banned forever
:return: types.Message
:return: boolean
"""
return apihelper.kick_chat_member(self.token, chat_id, user_id, until_date)

View File

@ -121,7 +121,7 @@ def download_file(token, file_path):
def send_message(token, chat_id, text, disable_web_page_preview=None, reply_to_message_id=None, reply_markup=None,
parse_mode=None, disable_notification=None):
parse_mode=None, disable_notification=None, timeout=None):
"""
Use this method to send text messages. On success, the sent Message is returned.
:param token:
@ -146,6 +146,8 @@ def send_message(token, chat_id, text, disable_web_page_preview=None, reply_to_m
payload['parse_mode'] = parse_mode
if disable_notification:
payload['disable_notification'] = disable_notification
if timeout:
payload['connect-timeout'] = timeout
return _make_request(token, method_url, params=payload, method='post')

View File

@ -484,10 +484,10 @@ class Message(JsonDeserializable):
url = "tg://user?id={0}".format(user.id)
elif type == "mention":
url = "https://t.me/{0}".format(text[1:])
text = text.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
if not type or not _subs.get(type):
return text
subs = _subs.get(type)
text = text.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
return subs.format(text=text, url=url)
offset = 0