2011-08-23 01:04:40 +02:00
|
|
|
var fs = require('fs');
|
|
|
|
|
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
|
|
|
},
|
|
|
|
|
2011-09-12 19:11:32 +02:00
|
|
|
'opme': function(data, params) {
|
2012-02-11 16:45:10 +01:00
|
|
|
dbot.instance.send('MODE ' + params[1] + ' +o ', dbot.admin);
|
2011-09-12 19:11:32 +02:00
|
|
|
},
|
|
|
|
|
2011-08-22 19:56:36 +02:00
|
|
|
'part': function(data, params) {
|
2011-08-25 14:32:54 +02:00
|
|
|
dbot.instance.part(params[1]);
|
2011-08-22 19:56:36 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
'reload': function(data, params) {
|
2011-08-24 17:15:42 +02:00
|
|
|
dbot.db = JSON.parse(fs.readFileSync('db.json', 'utf-8'));
|
|
|
|
dbot.reloadModules();
|
2011-08-24 19:23:00 +02:00
|
|
|
dbot.say(data.channel, 'Reloaded that shit.');
|
2011-08-22 19:56:36 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
'say': function(data, params) {
|
2012-03-09 22:44:05 +01:00
|
|
|
if (params[1] === "@") {
|
|
|
|
var c = data.channel;
|
|
|
|
} else {
|
|
|
|
var c = params[1];
|
|
|
|
}
|
2011-08-22 19:56:36 +02:00
|
|
|
var m = params.slice(2).join(' ');
|
|
|
|
dbot.say(c, m);
|
2011-08-24 19:23:00 +02:00
|
|
|
},
|
2012-03-09 22:44:05 +01:00
|
|
|
|
|
|
|
'act': function(data, params) {
|
|
|
|
if (params[1] === "@") {
|
|
|
|
var c = data.channel;
|
|
|
|
} else {
|
|
|
|
var c = params[1];
|
|
|
|
}
|
|
|
|
var m = params.slice(2).join(' ');
|
|
|
|
dbot.act(c, m);
|
|
|
|
},
|
2011-08-24 19:23:00 +02:00
|
|
|
|
|
|
|
'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])) {
|
2012-02-14 01:35:54 +01:00
|
|
|
var cacheKey = require.resolve('../modules/' + params[1]);
|
2012-02-14 01:32:31 +01:00
|
|
|
delete require.cache[cacheKey];
|
2012-02-14 01:41:34 +01:00
|
|
|
|
|
|
|
var moduleIndex = dbot.moduleNames.indexOf(params[1]);
|
|
|
|
dbot.moduleNames.splice(moduleIndex, 1);
|
|
|
|
|
2011-08-24 19:23:00 +02:00
|
|
|
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 22:30:48 +02:00
|
|
|
dbot.db.modehate.push(params[1]);
|
|
|
|
dbot.say(data.channel, 'Now modehating on ' + params[1]);
|
2011-10-14 14:24:18 +02:00
|
|
|
},
|
|
|
|
|
2011-10-18 17:49:04 +02:00
|
|
|
'unmodehate': function(data, params) {
|
|
|
|
dbot.db.modehate.splice(dbot.db.modehate.indexOf(params[1]), 1);
|
|
|
|
dbot.say(data.channel, 'No longer modehating on ' + params[1]);
|
|
|
|
},
|
|
|
|
|
2011-10-14 14:24:18 +02:00
|
|
|
'lock': function(data, params) {
|
|
|
|
dbot.db.locks.push(params[1]);
|
|
|
|
dbot.say(data.channel, 'Locked ' + params[1] + ' quotes.');
|
2011-08-22 19:56:36 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
2012-02-11 16:45:10 +01:00
|
|
|
// These commands are implemented as their own listener so it can easily
|
|
|
|
// check whether the user is the admin, and so that the admin can't ban
|
|
|
|
// themselves and then not be able to rectify it...
|
2011-08-22 19:56:36 +02:00
|
|
|
'listener': function(data) {
|
2011-10-18 17:57:37 +02:00
|
|
|
if(data.channel == dbot.name) data.channel = data.user;
|
2011-08-22 19:56:36 +02:00
|
|
|
|
2011-10-18 17:53:48 +02:00
|
|
|
params = data.message.split(' ');
|
2011-10-18 17:52:33 +02:00
|
|
|
if(commands.hasOwnProperty(params[0]) && data.user == dbot.admin) {
|
2011-08-22 19:56:36 +02:00
|
|
|
commands[params[0]](data, params);
|
2011-10-18 17:52:33 +02:00
|
|
|
dbot.save();
|
|
|
|
}
|
2011-08-22 19:56:36 +02:00
|
|
|
},
|
|
|
|
|
2012-03-07 17:54:03 +01:00
|
|
|
'onLoad': function() {
|
|
|
|
return {
|
|
|
|
'~resetadmin': function(data, params) {
|
|
|
|
dbot.admin = dbot.config.admin;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-08-22 19:56:36 +02:00
|
|
|
'on': 'PRIVMSG'
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
|
|
|
return adminCommands(dbot);
|
|
|
|
};
|