diff --git a/telebot/__init__.py b/telebot/__init__.py index 70afb35..d33f12d 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -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) diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 6e51bd9..aee5132 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -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') diff --git a/telebot/types.py b/telebot/types.py index fa5e4ef..be0274c 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -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("&", "&").replace("<", "<").replace(">", ">") if not type or not _subs.get(type): return text subs = _subs.get(type) - text = text.replace("&", "&").replace("<", "<").replace(">", ">") return subs.format(text=text, url=url) offset = 0