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
|
|
|
},
|
|
|
|
|
|
|
|
'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) {
|
|
|
|
var c = params[1];
|
|
|
|
var m = params.slice(2).join(' ');
|
|
|
|
dbot.say(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) {
|
|
|
|
console.log(dbot.moduleNames);
|
|
|
|
if(dbot.moduleNames.include(params[1])) {
|
2011-08-25 18:54:59 +02:00
|
|
|
dbot.moduleNames[params[1]] = undefined;
|
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-08-22 19:56:36 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
'listener': function(data) {
|
|
|
|
params = data.message.split(' ');
|
|
|
|
|
2011-08-24 19:23:00 +02:00
|
|
|
if(commands.hasOwnProperty(params[0]) && data.user == dbot.admin)
|
2011-08-22 19:56:36 +02:00
|
|
|
commands[params[0]](data, params);
|
|
|
|
},
|
|
|
|
|
|
|
|
'on': 'PRIVMSG'
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
|
|
|
return adminCommands(dbot);
|
|
|
|
};
|