Change config file format
This commit is contained in:
parent
f40fb2d45d
commit
5586020d1e
3 changed files with 9 additions and 4 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
## Next version
|
## Next version
|
||||||
|
|
||||||
|
- change config file format
|
||||||
- add `ALIASES` variable to `Bot`
|
- add `ALIASES` variable to `Bot`
|
||||||
- add `on_connected` function to `Client`
|
- add `on_connected` function to `Client`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
[basic]
|
[general]
|
||||||
name = EchoBot
|
nick = EchoBot
|
||||||
|
|
||||||
[rooms]
|
[rooms]
|
||||||
test
|
test
|
||||||
|
|
|
||||||
|
|
@ -21,14 +21,18 @@ class Bot(Client):
|
||||||
HELP_SPECIFIC: Optional[List[str]] = None
|
HELP_SPECIFIC: Optional[List[str]] = None
|
||||||
KILL_REPLY: str = "/me dies"
|
KILL_REPLY: str = "/me dies"
|
||||||
|
|
||||||
BASIC_SECTION = "basic"
|
GENERAL_SECTION = "general"
|
||||||
ROOMS_SECTION = "rooms"
|
ROOMS_SECTION = "rooms"
|
||||||
|
|
||||||
def __init__(self, config_file: str) -> None:
|
def __init__(self, config_file: str) -> None:
|
||||||
self.config = configparser.ConfigParser(allow_no_value=True)
|
self.config = configparser.ConfigParser(allow_no_value=True)
|
||||||
self.config.read(config_file)
|
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] = []
|
self._commands: List[Command] = []
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue