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

Add allowed_updates to get_updates.

This commit is contained in:
eternnoir 2016-12-06 11:44:30 +08:00
parent b5e27d0fea
commit eadff07f79
2 changed files with 6 additions and 3 deletions

View File

@ -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))

View File

@ -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)