Make KILL_REPLY and RESTART_REPLY optional

This commit is contained in:
Joscha 2019-04-19 10:52:39 +00:00
parent ca56de710c
commit eb9cc4f9bd

View file

@ -19,8 +19,8 @@ class Bot(Client):
PING_REPLY: str = "Pong!" PING_REPLY: str = "Pong!"
HELP_GENERAL: Optional[str] = None HELP_GENERAL: Optional[str] = None
HELP_SPECIFIC: Optional[List[str]] = None HELP_SPECIFIC: Optional[List[str]] = None
KILL_REPLY: str = "/me dies" KILL_REPLY: Optional[str] = "/me dies"
RESTART_REPLY: str = "/me restarts" RESTART_REPLY: Optional[str] = "/me restarts"
GENERAL_SECTION = "general" GENERAL_SECTION = "general"
ROOMS_SECTION = "rooms" ROOMS_SECTION = "rooms"
@ -178,7 +178,10 @@ class Bot(Client):
args: SpecificArgumentData args: SpecificArgumentData
) -> None: ) -> None:
logger.info(f"Killed in &{room.name} by {message.sender.atmention}") logger.info(f"Killed in &{room.name} by {message.sender.atmention}")
if self.KILL_REPLY is not None:
await message.reply(self.KILL_REPLY) await message.reply(self.KILL_REPLY)
await self.part(room) await self.part(room)
async def cmd_restart(self, async def cmd_restart(self,
@ -187,7 +190,10 @@ class Bot(Client):
args: SpecificArgumentData args: SpecificArgumentData
) -> None: ) -> None:
logger.info(f"Restarted in &{room.name} by {message.sender.atmention}") logger.info(f"Restarted in &{room.name} by {message.sender.atmention}")
if self.RESTART_REPLY is not None:
await message.reply(self.RESTART_REPLY) await message.reply(self.RESTART_REPLY)
await self.stop() await self.stop()
BotConstructor = Callable[[configparser.ConfigParser, str], Bot] BotConstructor = Callable[[configparser.ConfigParser, str], Bot]