From 3138250c7f7a1f5c1dfa3dfdb97fec87e483d0fc Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 10 Sep 2019 13:51:54 +0200 Subject: [PATCH] Correctly unregister forcestart key in mm --- royalnet/bots/telegram.py | 5 ++++- royalnet/commands/royalgames/mm.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/royalnet/bots/telegram.py b/royalnet/bots/telegram.py index 62438433..81b6137b 100644 --- a/royalnet/bots/telegram.py +++ b/royalnet/bots/telegram.py @@ -50,7 +50,10 @@ class TelegramBot(GenericBot): interface.keys_callbacks[key_name] = callback def unregister_keyboard_key(interface, key_name: str): - del interface.keys_callbacks[key_name] + try: + del interface.keys_callbacks[key_name] + except KeyError: + raise KeyError(f"Key '{key_name}' is not registered") return TelegramInterface diff --git a/royalnet/commands/royalgames/mm.py b/royalnet/commands/royalgames/mm.py index 92e30b96..686bcae7 100644 --- a/royalnet/commands/royalgames/mm.py +++ b/royalnet/commands/royalgames/mm.py @@ -330,7 +330,7 @@ class MmCommand(Command): self.interface.unregister_keyboard_key(f"mm_{mmevent.mmid}_r_YES") self.interface.unregister_keyboard_key(f"mm_{mmevent.mmid}_r_LATER") self.interface.unregister_keyboard_key(f"mm_{mmevent.mmid}_r_NO") - self.interface.unregister_keyboard_key(f"mm_{mmevent.mmid}_start") + self.interface.unregister_keyboard_key(f"mm_{mmevent.mmid}_forcestart") def __init__(self, interface): super().__init__(interface)