From 92c07d12ad6bf246e1fc506603867bc52c8398a2 Mon Sep 17 00:00:00 2001 From: Karho Date: Sat, 18 Feb 2017 00:06:41 +0800 Subject: [PATCH] Update bot.py Changing the function process_result on result_id in c.COLORS such that there is a try-except statement to prevent a deadlock in choosing colors. --- bot.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 6b46fcb..eac8179 100644 --- a/bot.py +++ b/bot.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # # Telegram bot to play UNO in group chats -# Copyright (c) 2016 Jannes Höke +# Copyright (c) 2016-2017 Jannes Höke and Karho Yau # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -36,7 +36,7 @@ from user_setting import UserSetting from utils import display_name import card as c from errors import (NoGameInChatError, LobbyClosedError, AlreadyJoinedError, - NotEnoughPlayersError, DeckEmptyError) + NotEnoughPlayersError, DeckEmptyError, PlayerLeftError) from utils import send_async, answer_async, error, TIMEOUT from shared_vars import botan, gm, updater, dispatcher from internationalization import _, __, user_locale, game_locales @@ -605,7 +605,13 @@ def process_result(bot, update): elif result_id == 'pass': game.turn() elif result_id in c.COLORS: - game.choose_color(result_id) + try: + game.choose_color(result_id) + except PlayerLeftError: + send_async(bot, chat.id, + text=__("There are errors in choosing color. " + "Color is now unchanged.", multi=game.translate)) + game.turn() else: reset_waiting_time(bot, player) do_play_card(bot, player, result_id)