Save bot config file
This commit is contained in:
parent
ac70f45229
commit
7b7ddaa0d1
2 changed files with 8 additions and 1 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
## Next version
|
## Next version
|
||||||
|
|
||||||
- add !restart to botrulez
|
- add !restart to botrulez
|
||||||
|
- save (overwrite) `Bot` config file
|
||||||
|
|
||||||
## 0.2.0 (2019-04-12)
|
## 0.2.0 (2019-04-12)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,10 @@ class Bot(Client):
|
||||||
ROOMS_SECTION = "rooms"
|
ROOMS_SECTION = "rooms"
|
||||||
|
|
||||||
def __init__(self, config_file: str) -> None:
|
def __init__(self, config_file: str) -> None:
|
||||||
|
self.config_file = config_file
|
||||||
|
|
||||||
self.config = configparser.ConfigParser(allow_no_value=True)
|
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")
|
nick = self.config[self.GENERAL_SECTION].get("nick")
|
||||||
if nick is None:
|
if nick is None:
|
||||||
|
|
@ -39,6 +41,10 @@ class Bot(Client):
|
||||||
|
|
||||||
self.start_time = datetime.datetime.now()
|
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:
|
async def started(self) -> None:
|
||||||
for room, password in self.config[self.ROOMS_SECTION].items():
|
for room, password in self.config[self.ROOMS_SECTION].items():
|
||||||
if password is None:
|
if password is None:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue