mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 14:29:29 +01:00
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
var adminCommands = function(dbot) {
|
|
var dbot = dbot;
|
|
|
|
var commands = {
|
|
'join': function(data, params) {
|
|
dbot.join(params[1]);
|
|
dbot.say(dbot.admin, 'Joined ' + params[1]);
|
|
},
|
|
|
|
'part': function(data, params) {
|
|
dbot.part(params[1]);
|
|
},
|
|
|
|
'reload': function(data, params) {
|
|
dbot.say(dbot.admin, 'Reloading DB.');
|
|
try {
|
|
dbot.db = JSON.parse(fs.readFileSync('db.json', 'utf-8'));
|
|
} catch(err) {
|
|
dbot.say(dbot.admin, 'DB reload failed.');
|
|
} finally {
|
|
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);
|
|
};
|