2011-11-20 10:23:31 +01:00
|
|
|
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":
|
|
|
|
{
|
2012-02-29 01:30:47 +01:00
|
|
|
"EsperNet":
|
2011-11-20 10:23:31 +01:00
|
|
|
{
|
2012-02-29 01:30:47 +01:00
|
|
|
"server": "irc.esper.net",
|
|
|
|
"nick": "MyNewCloudBot",
|
2011-11-21 00:04:39 +01:00
|
|
|
"user": "cloudbot",
|
2012-03-20 07:58:04 +01:00
|
|
|
"realname": "CloudBot - http://git.io/cloudbotirc",
|
2011-11-21 00:04:39 +01:00
|
|
|
"nickserv_password": "",
|
2012-02-29 01:30:47 +01:00
|
|
|
"channels": ["#cloudbot"],
|
2012-05-03 21:56:35 +02:00
|
|
|
"invite_join": true,
|
|
|
|
"auto_rejoin": false,
|
|
|
|
"command_prefix": "."
|
2011-11-20 10:23:31 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"disabled_plugins": [],
|
|
|
|
"disabled_commands": [],
|
|
|
|
"acls": {},
|
2011-11-21 07:41:07 +01:00
|
|
|
"api_keys":
|
|
|
|
{
|
2013-07-08 22:09:58 +02:00
|
|
|
"tvdb": "",
|
|
|
|
"wolframalpha": "",
|
|
|
|
"lastfm": "",
|
|
|
|
"rottentomatoes": "",
|
2013-07-19 11:22:06 +02:00
|
|
|
"soundcloud": "",
|
2013-07-01 17:49:27 +02:00
|
|
|
"twitter_consumer_key": "",
|
|
|
|
"twitter_consumer_secret": "",
|
|
|
|
"twitter_access_token": "",
|
2013-07-08 22:09:58 +02:00
|
|
|
"twitter_access_secret": "",
|
|
|
|
"wunderground": ""
|
2011-11-21 07:41:07 +01:00
|
|
|
},
|
2013-08-01 09:03:40 +02:00
|
|
|
"permission_groups": {
|
|
|
|
"admins": ["addfactoid", "delfactoid", "ignore", "botcontrol"],
|
|
|
|
"moderators": ["addfactoid", "delfactoid", "ignore"]
|
|
|
|
},
|
|
|
|
"permission_users": {
|
|
|
|
"admins": ["example!user@example.com"],
|
|
|
|
"moderators": ["exampleb!user@example.com"]
|
|
|
|
},
|
|
|
|
plugins":
|
2012-03-02 03:38:32 +01:00
|
|
|
{
|
|
|
|
"factoids":
|
|
|
|
{
|
|
|
|
"prefix": false
|
2012-04-02 07:50:47 +02:00
|
|
|
},
|
|
|
|
"ignore":
|
|
|
|
{
|
|
|
|
"ignored": []
|
2012-03-02 03:38:32 +01:00
|
|
|
}
|
|
|
|
},
|
2011-11-20 10:23:31 +01:00
|
|
|
"censored_strings":
|
|
|
|
[
|
2012-02-29 02:33:16 +01:00
|
|
|
"mypass",
|
|
|
|
"mysecret"
|
2013-08-01 09:03:40 +02:00
|
|
|
]
|
2011-11-20 10:23:31 +01:00
|
|
|
}''') + '\n')
|
2012-02-28 08:49:44 +01:00
|
|
|
print "Config generated!"
|
2012-02-29 01:30:47 +01:00
|
|
|
print "Please edit the config now!"
|
2012-03-20 07:58:04 +01:00
|
|
|
print "For help, see http://git.io/cloudbotircwiki"
|
2012-02-28 08:49:44 +01:00
|
|
|
print "Thank you for using CloudBot!"
|
|
|
|
sys.exit()
|
2011-11-20 10:23:31 +01:00
|
|
|
|
2012-02-29 06:09:40 +01:00
|
|
|
|
2011-11-20 10:23:31 +01:00
|
|
|
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:
|
2012-02-29 09:48:56 +01:00
|
|
|
print 'error: malformed config', e
|
2011-11-20 10:23:31 +01:00
|
|
|
|
|
|
|
|
2011-11-21 00:04:39 +01:00
|
|
|
bot._config_mtime = 0
|
2012-03-02 03:38:32 +01:00
|
|
|
|