h/core/config.py

36 lines
736 B
Python
Raw Normal View History

import inspect
import json
import os
2010-03-01 02:32:41 +00:00
def load():
2010-03-01 02:32:41 +00:00
return
def save(conf):
json.dump(conf, open('config', 'w'), sort_keys=True, indent=2)
if not os.path.exists('config'):
open('config', 'w').write(inspect.cleandoc(
'''
{
"connections":
{
"local irc":
{
"server": "localhost",
"nick": "skybot",
"channels": ["#test"]
}
}
}''') + '\n')
bot.config = json.load(open('config'))
bot._config_mtime = os.stat('config').st_mtime
2010-03-01 02:32:41 +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'))