dbot/modules/admin.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

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]);
},
'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.');
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.');
} finally {
2011-08-22 22:46:43 +02:00
dbot.say(dbot.admin, 'DB Reload successful.');
}
},
'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);
};