dbot/modules/admin.js

86 lines
2.7 KiB
JavaScript
Raw Normal View History

var fs = require('fs');
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-09-12 19:11:32 +02:00
'opme': function(data, params) {
dbot.instance.send('MODE #42 +v ', dbot.admin);
},
'part': function(data, params) {
dbot.instance.part(params[1]);
},
'reload': function(data, params) {
2011-08-24 17:15:42 +02:00
dbot.db = JSON.parse(fs.readFileSync('db.json', 'utf-8'));
dbot.reloadModules();
dbot.say(data.channel, 'Reloaded that shit.');
},
'say': function(data, params) {
var c = params[1];
var m = params.slice(2).join(' ');
dbot.say(c, m);
},
'load': function(data, params) {
dbot.moduleNames.push(params[1]);
dbot.reloadModules();
dbot.say(data.channel, 'Loaded new module: ' + params[1]);
},
'unload': function(data, params) {
if(dbot.moduleNames.include(params[1])) {
dbot.moduleNames[params[1]] = undefined;
dbot.reloadModules();
dbot.say(data.channel, 'Turned off module: ' + params[1]);
} else {
dbot.say(data.channel, 'Module ' + params[1] + ' isn\'t loaded... Idiot...');
}
2011-10-09 17:06:28 +02:00
},
'ban': function(data, params) {
2011-10-09 17:15:44 +02:00
if(dbot.db.bans.hasOwnProperty(params[2])) {
2011-10-09 17:06:28 +02:00
dbot.db.bans[params[2]].push(params[1]);
2011-10-10 14:30:44 +02:00
} else {
dbot.db.bans[params[2]] = [ params[1] ];
2011-10-09 17:06:28 +02:00
}
2011-10-09 17:07:42 +02:00
dbot.say(data.channel, params[1] + ' banned from ' + params[2]);
2011-10-09 17:15:44 +02:00
},
'unban': function(data, params) {
if(dbot.db.bans.hasOwnProperty(params[2]) && dbot.db.bans[params[2]].include(params[1])) {
dbot.db.bans[params[2]].splice(dbot.db.bans[params[2]].indexOf(params[1]), 1);
dbot.say(data.channel, params[1] + ' unbanned from ' + params[2]);
} else {
dbot.say(data.channel, 'It appears ' + params[1] + 'wasn\'t banned from that command, you fool.');
}
2011-10-12 19:09:55 +02:00
},
'modehate': function(data, params) {
2011-10-12 19:21:38 +02:00
dbot.db.modehate.push(params[2]);
}
};
return {
'listener': function(data) {
params = data.message.split(' ');
if(commands.hasOwnProperty(params[0]) && data.user == dbot.admin)
commands[params[0]](data, params);
},
'on': 'PRIVMSG'
};
};
exports.fetch = function(dbot) {
return adminCommands(dbot);
};