From 27d442fabfa8b1c94b59ea788797af1dbbd0d3e5 Mon Sep 17 00:00:00 2001 From: Badiboy Date: Tue, 24 Jul 2018 00:33:13 +0300 Subject: [PATCH] timeout for send_message Add optional "timeout" parameter to send_message (the same as exists in all other send_*). Equal rights for all send functions! :) --- telebot/__init__.py | 4 ++-- telebot/apihelper.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/telebot/__init__.py b/telebot/__init__.py index fb7770b..5106f87 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -459,7 +459,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. @@ -477,7 +477,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): """ diff --git a/telebot/apihelper.py b/telebot/apihelper.py index ceda96c..e919b5a 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -114,7 +114,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: @@ -137,6 +137,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')