Save bot config file

This commit is contained in:
Joscha 2019-04-13 00:29:49 +00:00
parent ac70f45229
commit 7b7ddaa0d1
2 changed files with 8 additions and 1 deletions

View file

@ -3,6 +3,7 @@
## Next version
- add !restart to botrulez
- save (overwrite) `Bot` config file
## 0.2.0 (2019-04-12)

View file

@ -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: