From 5586020d1e1022e6ae10b91f60faea0dd071f23d Mon Sep 17 00:00:00 2001 From: Joscha Date: Fri, 12 Apr 2019 20:40:27 +0000 Subject: [PATCH] Change config file format --- CHANGELOG.md | 1 + examples/echo/bot.conf | 4 ++-- yaboli/bot.py | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1e14a0..a0ed73a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Next version +- change config file format - add `ALIASES` variable to `Bot` - add `on_connected` function to `Client` diff --git a/examples/echo/bot.conf b/examples/echo/bot.conf index 87719ea..8d48222 100644 --- a/examples/echo/bot.conf +++ b/examples/echo/bot.conf @@ -1,5 +1,5 @@ -[basic] -name = EchoBot +[general] +nick = EchoBot [rooms] test diff --git a/yaboli/bot.py b/yaboli/bot.py index 23ecf32..7c96f29 100644 --- a/yaboli/bot.py +++ b/yaboli/bot.py @@ -21,14 +21,18 @@ class Bot(Client): HELP_SPECIFIC: Optional[List[str]] = None KILL_REPLY: str = "/me dies" - BASIC_SECTION = "basic" + GENERAL_SECTION = "general" ROOMS_SECTION = "rooms" def __init__(self, config_file: str) -> None: self.config = configparser.ConfigParser(allow_no_value=True) self.config.read(config_file) - super().__init__(self.config[self.BASIC_SECTION].get("name", "")) + nick = self.config[self.GENERAL_SECTION].get("nick") + if nick is None: + logger.warn("No nick set in config file. Defaulting to empty nick") + nick = "" + super().__init__(nick) self._commands: List[Command] = []