From 3a148c6e8587b89e74e48796d758809ce039bcce Mon Sep 17 00:00:00 2001 From: eternnoir Date: Sat, 5 Sep 2015 21:54:54 +0800 Subject: [PATCH] Refactor get_update method. --- telebot/__init__.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/telebot/__init__.py b/telebot/__init__.py index dc3f366..71ae368 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -81,13 +81,12 @@ class TeleBot: Registered listeners and applicable message handlers will be notified when a new message arrives. :raises ApiException when a call has failed. """ - updates = apihelper.get_updates(self.token, offset=(self.last_update_id + 1), timeout=20) + updates = self.get_updates(offset=(self.last_update_id + 1), timeout=20) new_messages = [] for update in updates: - if update['update_id'] > self.last_update_id: - self.last_update_id = update['update_id'] - msg = types.Message.de_json(update['message']) - new_messages.append(msg) + if update.update_id > self.last_update_id: + self.last_update_id = update.update_id + new_messages.append(update.message) logger.debug('GET %d new messages' % len(new_messages)) if len(new_messages) > 0: self.process_new_messages(new_messages)