packages/ircbot: implement basic overridable config

This commit is contained in:
Max Headroom 2022-09-25 19:28:08 +02:00
parent 6982def2c7
commit 7a6f7b5cc0

View file

@ -1,6 +1,7 @@
import os
import sys
import justirc
import json
import importlib
class EventHandler(object):
@ -11,7 +12,7 @@ class EventHandler(object):
...
def main():
config = dict(
default_config = dict(
debug=False,
nick='smith',
channel='#general',
@ -19,7 +20,11 @@ def main():
port=6697,
tls=True,
)
run_bot(config)
config = dict()
if (config_file := os.getenv("IRCBOT_CONFIG")) and config_file != "":
with open(config_file) as f:
config = json.load(f)
run_bot(default_config | config)
def shutdown_bot_hooks(bot):
for name, hook in bot.hooks: