From eb9cc4f9bd2c583ddf77ff1e9f1e506b3ea21c94 Mon Sep 17 00:00:00 2001 From: Joscha Date: Fri, 19 Apr 2019 10:52:39 +0000 Subject: [PATCH] Make KILL_REPLY and RESTART_REPLY optional --- yaboli/bot.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/yaboli/bot.py b/yaboli/bot.py index c696820..eba8669 100644 --- a/yaboli/bot.py +++ b/yaboli/bot.py @@ -19,8 +19,8 @@ class Bot(Client): PING_REPLY: str = "Pong!" HELP_GENERAL: Optional[str] = None HELP_SPECIFIC: Optional[List[str]] = None - KILL_REPLY: str = "/me dies" - RESTART_REPLY: str = "/me restarts" + KILL_REPLY: Optional[str] = "/me dies" + RESTART_REPLY: Optional[str] = "/me restarts" GENERAL_SECTION = "general" ROOMS_SECTION = "rooms" @@ -178,7 +178,10 @@ class Bot(Client): args: SpecificArgumentData ) -> None: logger.info(f"Killed in &{room.name} by {message.sender.atmention}") - await message.reply(self.KILL_REPLY) + + if self.KILL_REPLY is not None: + await message.reply(self.KILL_REPLY) + await self.part(room) async def cmd_restart(self, @@ -187,7 +190,10 @@ class Bot(Client): args: SpecificArgumentData ) -> None: logger.info(f"Restarted in &{room.name} by {message.sender.atmention}") - await message.reply(self.RESTART_REPLY) + + if self.RESTART_REPLY is not None: + await message.reply(self.RESTART_REPLY) + await self.stop() BotConstructor = Callable[[configparser.ConfigParser, str], Bot]