From ba98220d44ddc1f0e1473fca94f1f8b932e1954f Mon Sep 17 00:00:00 2001 From: Rhea Parekh Date: Mon, 11 Jun 2018 19:02:23 +0530 Subject: [PATCH] bots: minor cleanup for trivia_quiz bot. --- zulip_bots/zulip_bots/bots/trivia_quiz/trivia_quiz.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/zulip_bots/zulip_bots/bots/trivia_quiz/trivia_quiz.py b/zulip_bots/zulip_bots/bots/trivia_quiz/trivia_quiz.py index 249070c..1b77380 100644 --- a/zulip_bots/zulip_bots/bots/trivia_quiz/trivia_quiz.py +++ b/zulip_bots/zulip_bots/bots/trivia_quiz/trivia_quiz.py @@ -38,7 +38,7 @@ class TriviaQuizHandler: return try: quiz_payload = get_quiz_from_id(quiz_id, bot_handler) - except KeyError: + except (KeyError, TypeError): bot_response = 'Invalid quiz id' bot_handler.send_reply(message, bot_response) return @@ -132,9 +132,7 @@ def get_quiz_from_payload(payload): def generate_quiz_id(storage) -> str: try: quiz_num = storage.get('quiz_id') - except KeyError: - quiz_num = 0 - except TypeError: + except (KeyError, TypeError): quiz_num = 0 quiz_num += 1 quiz_num = quiz_num % (1000)