From e7bb648f96169ee1875909aec2c9c6ff3ba36289 Mon Sep 17 00:00:00 2001 From: Julian Marcos Date: Fri, 1 Sep 2023 14:12:35 +0000 Subject: [PATCH] Almost all options being config options The options in the bot configuration should be taken from the config.json not from the bot source file, as hardcoding options is bad I've also refactorized the handler, and made most options be config options --- bot.py | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/bot.py b/bot.py index c594e47..e1d4013 100644 --- a/bot.py +++ b/bot.py @@ -8,28 +8,22 @@ with open('config.json') as c: config = json.load(c) if __name__ == '__main__': - if len(sys.argv) > 1: - if sys.argv[1] == '--test-mode': - channels = ['#jmjl-devel'] - nick = 'ju[dev]' - prefix_plugins = True - cmd_prefix='^' - else: - channels = config['channels'] - prefix_plugins = False - cmd_prefix='&' - nick = 'ju' + if len(sys.argv) > 1 and if sys.argv[1] == '--test-mode': + channels = config['test']['channels'] + cmd_prefix = config['test']['cmd_prefix'] + nick = f"{config['nickname']}{config['test']['nick_suffix']}" + prefix_plugins = True else: channels = config['channels'] - nick = 'ju' + cmd_prefix = config['cmd_prefix'] + nick = config['nickname'] prefix_plugins = False - cmd_prefix='&' bot = pinhook.bot.Bot( channels, nick, 'localhost', - ops=['jmjl'], - ns_pass='ju {}'.format(config['password']), + ops=config['ops'], + ns_pass=f"{config['nickname'] {config['password']}", #ns_pass=config['password'], nickserv='nickserv', cmd_prefix=cmd_prefix,