From da729069c2745f6b7d696f1bc3e5e7305a7b04c2 Mon Sep 17 00:00:00 2001 From: eternnoir Date: Sat, 5 Sep 2015 18:10:11 +0800 Subject: [PATCH] Add get_updates method. --- telebot/__init__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/telebot/__init__.py b/telebot/__init__.py index 5af3100..067914f 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -59,6 +59,20 @@ class TeleBot: if self.__create_threads: self.worker_pool = util.ThreadPool(num_threads) + def get_Updates(self, offset=None,limit=None, timeout=20): + """ + Use this method to receive incoming updates using long polling (wiki). An Array of Update objects is returned. + :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) + ret = [] + for ju in json_updates: + ret.append(types.Update.de_json(ju)) + return ret + def get_update(self): """ Retrieves any updates from the Telegram API.