aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRahiel Kasim <rahielkasim@gmail.com>2016-07-27 08:58:31 +0200
committerRahiel Kasim <rahielkasim@gmail.com>2016-07-27 08:58:31 +0200
commit9dc266c7cbbf6f23b96eaac9f6212ece50149f90 (patch)
tree2ff3b1b1253d5322074ea655a52b8e134b25dc72
parentde4550c076931d476f57f6ed71c7387c2276af24 (diff)
catch "Invalid server response" exception
-rw-r--r--bismillah.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/bismillah.py b/bismillah.py
index a4a003f..146dcca 100644
--- a/bismillah.py
+++ b/bismillah.py
@@ -21,7 +21,7 @@ from time import sleep, time
import sys
import telegram
-from telegram.error import NetworkError, Unauthorized
+from telegram.error import NetworkError, Unauthorized, TelegramError
from redis import StrictRedis
import ujson as json
@@ -75,9 +75,14 @@ def main():
try:
serve(bot, data)
except NetworkError:
- sleep(0.2)
+ sleep(1)
except Unauthorized: # user has removed or blocked the bot
update_id += 1
+ except TelegramError as e:
+ if "Invalid server response" in str(e):
+ sleep(3)
+ else:
+ raise e
def serve(bot, data):