From e06d5f37f8912802d2937cc73d99942e6cb21ea4 Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 16 Jul 2018 00:36:52 +0100 Subject: switch to using configparser for config files --- .gitignore | 2 +- Config.py | 8 +++++--- README.md | 4 ++-- bot.conf.example | 23 +++++++++++++++++++++++ bot.json.example | 21 --------------------- 5 files changed, 31 insertions(+), 27 deletions(-) create mode 100644 bot.conf.example delete mode 100644 bot.json.example diff --git a/.gitignore b/.gitignore index d5cd73af..ae9b6d30 100644 --- a/.gitignore +++ b/.gitignore @@ -63,5 +63,5 @@ target/ # custom *.db -*.json +*.conf modules/nongit-*.py diff --git a/Config.py b/Config.py index 06a00378..21a144cf 100644 --- a/Config.py +++ b/Config.py @@ -1,7 +1,7 @@ -import json, os +import configparser, os class Config(object): - def __init__(self, bot, location="bot.json"): + def __init__(self, bot, location="bot.conf"): self.bot = bot self.location = location self.full_location = os.path.join(bot.bot_directory, @@ -12,4 +12,6 @@ class Config(object): def load_config(self): if os.path.isfile(self.full_location): with open(self.full_location) as config_file: - self.bot.config = json.loads(config_file.read()) + parser = configparser.ConfigParser() + parser.read_string(config_file.read()) + self.bot.config = dict(parser["bot"].items()) diff --git a/README.md b/README.md index 07f2b374..047dc437 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,10 @@ Python3 event-driven modular IRC bot! * [suds](https://pypi.python.org/pypi/suds-jurko) ## Configurating -To get BitBot off the ground, there's some API-keys and the like in bot.json.example. move it to bot.json, fill in the API keys you want (and remove the ones you don't want - this will automatically disable the modules that rely on them.) +To get BitBot off the ground, there's some API-keys and the like in bot.conf.example. move it to bot.conf, fill in the API keys you want (and remove the ones you don't want - this will automatically disable the modules that rely on them.) ## Eagle -BitBot's National Rail module can optionally include output from Network Rail's SCHEDULE via [Eagle](https://github.com/EvelynSubarrow/Eagle). Configuration on BitBot's end is covered by the `eagle-` keys in bot.json.example. +BitBot's National Rail module can optionally include output from Network Rail's SCHEDULE via [Eagle](https://github.com/EvelynSubarrow/Eagle). Configuration on BitBot's end is covered by the `eagle-` keys in bot.conf.example. ## Running Just run `./start.py` diff --git a/bot.conf.example b/bot.conf.example new file mode 100644 index 00000000..76df4848 --- /dev/null +++ b/bot.conf.example @@ -0,0 +1,23 @@ +[bot] +openweathermap-api-key = +wolframalpha-api-key = +google-api-key = +google-search-id = +bighugethesaurus-api-key = +wordnik-api-key = +lastfm-api-key = +twitter-api-key = +twitter-api-secret = +twitter-access-token = +twitter-access-secret = +trakt-api-key = +bitly-api-key = +soundcloud-api-key = +tfl-api-id = +tfl-api-key = +nre-api-key = +eagle-api-key = +eagle-api-url = +pushbullet-api-key = +pushbullet-channel-tag = +omdbapi-api-key = diff --git a/bot.json.example b/bot.json.example deleted file mode 100644 index 14fc0dd5..00000000 --- a/bot.json.example +++ /dev/null @@ -1,21 +0,0 @@ -{ - "openweathermap-api-key" : "", - "wolframalpha-api-key" : "", - "google-api-key" : "", - "google-search-id" : "", - "bighugethesaurus-api-key" : "", - "wordnik-api-key" : "", - "lastfm-api-key" : "", - "twitter-api-key" : "", - "twitter-api-secret" : "", - "twitter-access-token" : "", - "twitter-access-secret" : "", - "trakt-api-key" : "", - "bitly-api-key" : "", - "soundcloud-api-key" : "", - "tfl-api-id" : "", - "tfl-api-key" : "", - "eagle-api-url" : "", - "eagle-api-key" : "", - "omdbapi-api-key" : "" -} -- cgit v1.3.1-10-gc9f91