From 6b7476c18f9340ace52a890203f91d3382f1d73b Mon Sep 17 00:00:00 2001 From: leandrotoledo Date: Mon, 20 Jul 2015 08:59:41 -0300 Subject: [PATCH] Updates echobot and getUpdates logging --- examples/echobot.py | 2 +- telegram/bot.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/echobot.py b/examples/echobot.py index dc07df4a3..4834ca2e2 100644 --- a/examples/echobot.py +++ b/examples/echobot.py @@ -24,7 +24,7 @@ def echo(): if LAST_UPDATE_ID < update.update_id: # chat_id is required to reply any message chat_id = update.message.chat_id - message = update.message.text + message = update.message.text.encode('utf-8') if (message): # Reply the message diff --git a/telegram/bot.py b/telegram/bot.py index 6aa6874a6..89c675822 100644 --- a/telegram/bot.py +++ b/telegram/bot.py @@ -50,6 +50,8 @@ class Bot(TelegramObject): self.username = bot.username self.__auth = True + + self.log.info('Starting bot %s' % self.name) except TelegramError: raise TelegramError({'message': 'Bad token'}) @@ -533,6 +535,12 @@ class Bot(TelegramObject): json_data = self._requestUrl(url, 'POST', data=data) data = self._parseAndCheckTelegram(json_data) + if data: + self.log.info( + 'Getting updates: %s' % [u['update_id'] for u in data]) + else: + self.log.info('No new updates found.') + return [Update.de_json(x) for x in data] @log