First :D
This commit is contained in:
commit
37588421f3
100 changed files with 22673 additions and 0 deletions
53
core/config.py
Normal file
53
core/config.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
import inspect
|
||||
import json
|
||||
import os
|
||||
|
||||
|
||||
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(
|
||||
r'''
|
||||
{
|
||||
"connections":
|
||||
{
|
||||
"local irc":
|
||||
{
|
||||
"server": "localhost",
|
||||
"nick": "skybot",
|
||||
"channels": ["#test"]
|
||||
}
|
||||
},
|
||||
"disabled_plugins": [],
|
||||
"disabled_commands": [],
|
||||
"acls": {},
|
||||
"api_keys": {},
|
||||
"censored_strings":
|
||||
[
|
||||
"DCC SEND",
|
||||
"1nj3ct",
|
||||
"thewrestlinggame",
|
||||
"startkeylogger",
|
||||
"hybux",
|
||||
"\\0",
|
||||
"\\x01",
|
||||
"!coz",
|
||||
"!tell /x"
|
||||
],
|
||||
"admins": []
|
||||
}''') + '\n')
|
||||
|
||||
|
||||
def config():
|
||||
# reload config from file if file has changed
|
||||
config_mtime = os.stat('config').st_mtime
|
||||
if bot._config_mtime != config_mtime:
|
||||
try:
|
||||
bot.config = json.load(open('config'))
|
||||
bot._config_mtime = config_mtime
|
||||
except ValueError, e:
|
||||
print 'ERROR: malformed config!', e
|
||||
|
||||
|
||||
bot._config_mtime = 0
|
Reference in a new issue