From b5e27d0fea9c006f186af01b76985eef60b02fc6 Mon Sep 17 00:00:00 2001 From: eternnoir Date: Tue, 6 Dec 2016 11:42:15 +0800 Subject: [PATCH] Add max_connections and allowed_updates to set_webhook. --- telebot/__init__.py | 4 ++-- telebot/apihelper.py | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/telebot/__init__.py b/telebot/__init__.py index 44e77c3..f423245 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -77,8 +77,8 @@ class TeleBot: if self.threaded: self.worker_pool = util.ThreadPool() - def set_webhook(self, url=None, certificate=None): - return apihelper.set_webhook(self.token, url, certificate) + def set_webhook(self, url=None, certificate=None, max_connections=None, allowed_updates=None): + return apihelper.set_webhook(self.token, url, certificate, max_connections, allowed_updates) def get_webhook_info(self): result = apihelper.get_webhook_info(self.token) diff --git a/telebot/apihelper.py b/telebot/apihelper.py index c56b081..499cadc 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -115,7 +115,7 @@ def send_message(token, chat_id, text, disable_web_page_preview=None, reply_to_m return _make_request(token, method_url, params=payload, method='post') -def set_webhook(token, url=None, certificate=None): +def set_webhook(token, url=None, certificate=None, max_connections=None, allowed_updates=None): method_url = r'setWebhook' payload = { 'url': url if url else "", @@ -123,7 +123,10 @@ def set_webhook(token, url=None, certificate=None): files = None if certificate: files = {'certificate': certificate} - + if max_connections: + payload['max_connections'] = max_connections + if allowed_updates: + payload['allowed_updates'] = allowed_updates return _make_request(token, method_url, params=payload, files=files) @@ -443,7 +446,8 @@ def send_game(token, chat_id, game_short_name, disable_notification=None, reply_ # https://core.telegram.org/bots/api#setgamescore -def set_game_score(token, user_id, score, force=None, disable_edit_message=None, chat_id=None, message_id=None, inline_message_id=None): +def set_game_score(token, user_id, score, force=None, disable_edit_message=None, chat_id=None, message_id=None, + inline_message_id=None): """ Use this method to set the score of the specified user in a game. On success, if the message was sent by the bot, returns the edited Message, otherwise returns True. Returns an error, if the new score is not greater than the user's current score in the chat. :param token: Bot's token (you don't need to fill this)