diff --git a/telebot/__init__.py b/telebot/__init__.py index f423245..dfc7102 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -87,15 +87,16 @@ class TeleBot: def remove_webhook(self): return self.set_webhook() # No params resets webhook - def get_updates(self, offset=None, limit=None, timeout=20): + def get_updates(self, offset=None, limit=None, timeout=20, allowed_updates=None): """ Use this method to receive incoming updates using long polling (wiki). An Array of Update objects is returned. + :param allowed_updates: Array of string. List the types of updates you want your bot to receive. :param offset: Integer. Identifier of the first update to be returned. :param limit: Integer. Limits the number of updates to be retrieved. :param timeout: Integer. Timeout in seconds for long polling. :return: array of Updates """ - json_updates = apihelper.get_updates(self.token, offset, limit, timeout) + json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates) ret = [] for ju in json_updates: ret.append(types.Update.de_json(ju)) diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 499cadc..da88b47 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -136,7 +136,7 @@ def get_webhook_info(token): return _make_request(token, method_url, params=payload) -def get_updates(token, offset=None, limit=None, timeout=None): +def get_updates(token, offset=None, limit=None, timeout=None, allowed_updates=None): method_url = r'getUpdates' payload = {} if offset: @@ -145,6 +145,8 @@ def get_updates(token, offset=None, limit=None, timeout=None): payload['limit'] = limit if timeout: payload['timeout'] = timeout + if allowed_updates: + payload['allowed_updates'] = allowed_updates return _make_request(token, method_url, params=payload)