switch to using configparser for config files
This commit is contained in:
parent
2012a388da
commit
e06d5f37f8
5 changed files with 31 additions and 27 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -63,5 +63,5 @@ target/
|
|||
|
||||
# custom
|
||||
*.db
|
||||
*.json
|
||||
*.conf
|
||||
modules/nongit-*.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())
|
||||
|
|
|
@ -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`
|
||||
|
|
23
bot.conf.example
Normal file
23
bot.conf.example
Normal file
|
@ -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 =
|
|
@ -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" : ""
|
||||
}
|
Loading…
Reference in a new issue