X Tutup
Skip to content

Commit 9f27537

Browse files
committed
Error handling when no updates available
1 parent 6b5c55a commit 9f27537

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/echobot.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
bot = telegram.Bot('TOKEN')
1010

1111
# This will be our global variable to keep the latest update_id when requesting
12-
# for updates. It starts with the latest update_id available.
13-
LAST_UPDATE_ID = bot.getUpdates()[-1].update_id
12+
# for updates. It starts with the latest update_id if available.
13+
try:
14+
LAST_UPDATE_ID = bot.getUpdates()[-1].update_id
15+
except IndexError:
16+
LAST_UPDATE_ID = None
1417

1518

1619
def echo():

0 commit comments

Comments
 (0)
X Tutup