2010-02-23 03:32:09 +00:00
|
|
|
import inspect
|
|
|
|
import json
|
2009-11-18 00:19:26 +00:00
|
|
|
import os
|
|
|
|
|
2010-03-01 02:32:41 +00:00
|
|
|
|
2010-02-23 03:32:09 +00:00
|
|
|
def load():
|
2010-03-01 02:32:41 +00:00
|
|
|
return
|
|
|
|
|
2010-02-23 03:32:09 +00:00
|
|
|
|
|
|
|
def save(conf):
|
|
|
|
json.dump(conf, open('config', 'w'), sort_keys=True, indent=2)
|
2009-11-18 00:19:26 +00:00
|
|
|
|
|
|
|
if not os.path.exists('config'):
|
2010-02-23 03:32:09 +00:00
|
|
|
open('config', 'w').write(inspect.cleandoc(
|
|
|
|
'''
|
|
|
|
{
|
|
|
|
"connections":
|
|
|
|
{
|
|
|
|
"local irc":
|
|
|
|
{
|
|
|
|
"server": "localhost",
|
|
|
|
"nick": "skybot",
|
|
|
|
"channels": ["#test"]
|
2010-01-17 20:20:11 +00:00
|
|
|
}
|
2010-02-23 03:32:09 +00:00
|
|
|
}
|
|
|
|
}''') + '\n')
|
2009-11-18 00:19:26 +00:00
|
|
|
|
2010-02-23 03:32:09 +00:00
|
|
|
bot.config = json.load(open('config'))
|
2009-11-18 00:19:26 +00:00
|
|
|
bot._config_mtime = os.stat('config').st_mtime
|
|
|
|
|
2010-03-01 02:32:41 +00:00
|
|
|
|
2009-11-18 00:19:26 +00:00
|
|
|
def config():
|
|
|
|
# reload config from file if file has changed
|
|
|
|
if bot._config_mtime != os.stat('config').st_mtime:
|
2010-03-01 02:32:41 +00:00
|
|
|
bot.config = json.load(open('config'))
|