aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jesopo2018-07-16 00:36:52 +0100
committerGravatar jesopo2018-07-16 00:36:52 +0100
commite06d5f37f8912802d2937cc73d99942e6cb21ea4 (patch)
treee65257e63d1e0f3f3b80f49d5dc4ccbcf85170db
parentmove sasl logic to it's own module (diff)
signature
switch to using configparser for config files
-rw-r--r--.gitignore2
-rw-r--r--Config.py8
-rw-r--r--README.md4
-rw-r--r--bot.conf.example23
-rw-r--r--bot.json.example21
5 files changed, 31 insertions, 27 deletions
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" : ""
-}