diff --git a/CHANGELOG.md b/CHANGELOG.md index 0437e49..7adfa30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Next version - add !restart to botrulez +- save (overwrite) `Bot` config file ## 0.2.0 (2019-04-12) diff --git a/yaboli/bot.py b/yaboli/bot.py index de6af0e..d08bcdd 100644 --- a/yaboli/bot.py +++ b/yaboli/bot.py @@ -26,8 +26,10 @@ class Bot(Client): ROOMS_SECTION = "rooms" def __init__(self, config_file: str) -> None: + self.config_file = config_file + self.config = configparser.ConfigParser(allow_no_value=True) - self.config.read(config_file) + self.config.read(self.config_file) nick = self.config[self.GENERAL_SECTION].get("nick") if nick is None: @@ -39,6 +41,10 @@ class Bot(Client): self.start_time = datetime.datetime.now() + def save_config(self) -> None: + with open(self.config_file, "w") as f: + self.config.write(f) + async def started(self) -> None: for room, password in self.config[self.ROOMS_SECTION].items(): if password is None: