2011-08-22 19:56:36 +02:00
|
|
|
var adminCommands = function(dbot) {
|
|
|
|
var dbot = dbot;
|
|
|
|
|
|
|
|
var commands = {
|
|
|
|
'join': function(data, params) {
|
2011-08-22 23:17:13 +02:00
|
|
|
dbot.instance.join(params[1]);
|
2011-08-22 22:46:43 +02:00
|
|
|
dbot.say(dbot.admin, 'Joined ' + params[1]);
|
2011-08-22 19:56:36 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
'part': function(data, params) {
|
|
|
|
dbot.part(params[1]);
|
|
|
|
},
|
|
|
|
|
|
|
|
'reload': function(data, params) {
|
2011-08-22 22:46:43 +02:00
|
|
|
dbot.say(dbot.admin, 'Reloading DB.');
|
2011-08-22 19:56:36 +02:00
|
|
|
try {
|
|
|
|
dbot.db = JSON.parse(fs.readFileSync('db.json', 'utf-8'));
|
|
|
|
} catch(err) {
|
2011-08-22 22:46:43 +02:00
|
|
|
dbot.say(dbot.admin, 'DB reload failed.');
|
2011-08-22 19:56:36 +02:00
|
|
|
} finally {
|
2011-08-22 22:46:43 +02:00
|
|
|
dbot.say(dbot.admin, 'DB Reload successful.');
|
2011-08-22 19:56:36 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
'say': function(data, params) {
|
|
|
|
var c = params[1];
|
|
|
|
var m = params.slice(2).join(' ');
|
|
|
|
dbot.say(c, m);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
'listener': function(data) {
|
|
|
|
params = data.message.split(' ');
|
|
|
|
|
|
|
|
if(commands.hasOwnProperty(params[0]))
|
|
|
|
commands[params[0]](data, params);
|
|
|
|
},
|
|
|
|
|
|
|
|
'on': 'PRIVMSG'
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
|
|
|
return adminCommands(dbot);
|
|
|
|
};
|