From 9f275371762f69713ca66007ee61671d1506f732 Mon Sep 17 00:00:00 2001 From: leandrotoledo Date: Wed, 15 Jul 2015 07:47:13 -0300 Subject: [PATCH] Error handling when no updates available --- examples/echobot.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/echobot.py b/examples/echobot.py index edc2a2e8a..dc07df4a3 100644 --- a/examples/echobot.py +++ b/examples/echobot.py @@ -9,8 +9,11 @@ import time bot = telegram.Bot('TOKEN') # This will be our global variable to keep the latest update_id when requesting -# for updates. It starts with the latest update_id available. -LAST_UPDATE_ID = bot.getUpdates()[-1].update_id +# for updates. It starts with the latest update_id if available. +try: + LAST_UPDATE_ID = bot.getUpdates()[-1].update_id +except IndexError: + LAST_UPDATE_ID = None def echo():