From 668cc5e10c7097d51ba4e4fcae02f55d89283923 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sun, 27 Jan 2019 11:18:16 +0100 Subject: irc: Switch configuration to JSON --- crocoite/cli.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'crocoite') diff --git a/crocoite/cli.py b/crocoite/cli.py index a8de73b..b73051b 100644 --- a/crocoite/cli.py +++ b/crocoite/cli.py @@ -132,30 +132,30 @@ def recursive (): return 0 def irc (): - from configparser import ConfigParser + import json from .irc import Chromebot logger = Logger (consumer=[DatetimeConsumer (), JsonPrintConsumer ()]) parser = argparse.ArgumentParser(description='IRC bot.') - parser.add_argument('--config', '-c', help='Config file location', metavar='PATH', default='chromebot.ini') + parser.add_argument('--config', '-c', help='Config file location', metavar='PATH', default='chromebot.json') args = parser.parse_args () - config = ConfigParser () - config.read (args.config) + with open (args.config) as fd: + config = json.load (fd) s = config['irc'] loop = asyncio.get_event_loop() bot = Chromebot ( - host=s.get ('host'), - port=s.getint ('port'), - ssl=s.getboolean ('ssl'), - nick=s.get ('nick'), - channels=[s.get ('channel')], - tempdir=s.get ('tempdir'), - destdir=s.get ('destdir'), - processLimit=s.getint ('process_limit'), + host=s['host'], + port=s['port'], + ssl=s['ssl'], + nick=s['nick'], + channels=s['channels'], + tempdir=config['tempdir'], + destdir=config['destdir'], + processLimit=config['process_limit'], logger=logger, loop=loop) stop = lambda signum: bot.cancel () -- cgit v1.2.3