Multiple admins supported

This commit is contained in:
Luke Slater 2012-03-10 14:38:47 +00:00
parent 4e338c2475
commit d5296b0ea0
6 changed files with 10 additions and 13 deletions

View File

@ -6,11 +6,11 @@ var adminCommands = function(dbot) {
var commands = { var commands = {
'join': function(data, params) { 'join': function(data, params) {
dbot.instance.join(params[1]); dbot.instance.join(params[1]);
dbot.say(dbot.admin, 'Joined ' + params[1]); dbot.say(data.channel, 'Joined ' + params[1]);
}, },
'opme': function(data, params) { 'opme': function(data, params) {
dbot.instance.send('MODE ' + params[1] + ' +o ', dbot.admin); dbot.instance.send('MODE ' + params[1] + ' +o ', data.user);
}, },
'part': function(data, params) { 'part': function(data, params) {
@ -106,7 +106,7 @@ var adminCommands = function(dbot) {
if(data.channel == dbot.name) data.channel = data.user; if(data.channel == dbot.name) data.channel = data.user;
params = data.message.split(' '); params = data.message.split(' ');
if(commands.hasOwnProperty(params[0]) && data.user == dbot.admin) { if(commands.hasOwnProperty(params[0]) && dbot.admin.include(data.user)) {
commands[params[0]](data, params); commands[params[0]](data, params);
dbot.save(); dbot.save();
} }

View File

@ -26,7 +26,7 @@ var drama = function(dbot) {
var commands = { var commands = {
'~train': function(data, params) { '~train': function(data, params) {
if(data.user == dbot.admin || data.user == 'golem' || data.user == 'Sam') { if(dbot.admin.include(data.user)) {
bayes.train(last[params[1]][params[2]], params[3]); bayes.train(last[params[1]][params[2]], params[3]);
dbot.say(data.channel, 'Last thing ' + params[2] + ' said in ' + dbot.say(data.channel, 'Last thing ' + params[2] + ' said in ' +
params[1] + ' (' + last[params[1]][params[2]] + ') classified as \'' + params[3] + '\''); params[1] + ' (' + last[params[1]][params[2]] + ') classified as \'' + params[3] + '\'');
@ -34,7 +34,7 @@ var drama = function(dbot) {
}, },
'~rtrain': function(data, params) { '~rtrain': function(data, params) {
if(data.user == dbot.admin || data.user == 'golem' || data.user == 'Sam') { if(dbot.admin.include(data.user)) {
var category = params[1]; var category = params[1];
params.splice(0, 2); params.splice(0, 2);
var msg = params.join(' '); var msg = params.join(' ');

View File

@ -15,7 +15,7 @@ var js = function(dbot) {
'~ajs': function(data, params) { '~ajs': function(data, params) {
var q = data.message.valMatch(/^~ajs (.*)/, 2); var q = data.message.valMatch(/^~ajs (.*)/, 2);
if(data.user == dbot.admin) { if(dbot.admin.include(data.user)) {
dbot.say(data.channel, eval(q[1])); dbot.say(data.channel, eval(q[1]));
} }
} }

View File

@ -7,9 +7,6 @@ var puns = function(dbot) {
dbot.instance.say(data.channel, dbot.interpolatedQuote('realityonce')); dbot.instance.say(data.channel, dbot.interpolatedQuote('realityonce'));
} else if(dbot.db.quoteArrs.hasOwnProperty(data.user.toLowerCase())) { } else if(dbot.db.quoteArrs.hasOwnProperty(data.user.toLowerCase())) {
dbot.say(data.channel, data.user + ': ' + dbot.interpolatedQuote(data.user.toLowerCase())); dbot.say(data.channel, data.user + ': ' + dbot.interpolatedQuote(data.user.toLowerCase()));
} else if(dbot.instance.inChannel(data.channel)) {
dbot.instance.say('aisbot', '.karma ' + data.user);
dbot.waitingForKarma = data.channel;
} }
}, },

View File

@ -65,13 +65,13 @@ var quotes = function(dbot) {
}, },
'~rmlast': function(data, params) { '~rmlast': function(data, params) {
if(rmAllowed == true || data.user == dbot.admin) { if(rmAllowed == true || dbot.admin.include(data.user)) {
var q = data.message.valMatch(/^~rmlast ([\d\w\s-]*)/, 2); var q = data.message.valMatch(/^~rmlast ([\d\w\s-]*)/, 2);
if(q) { if(q) {
q[1] = q[1].trim() q[1] = q[1].trim()
key = q[1].toLowerCase(); key = q[1].toLowerCase();
if(quotes.hasOwnProperty(q[1])) { if(quotes.hasOwnProperty(q[1])) {
if(!dbot.db.locks.include(q[1]) || data.user == dbot.admin) { if(!dbot.db.locks.include(q[1]) || dbot.admin.include(data.user)) {
var quote = quotes[key].pop(); var quote = quotes[key].pop();
if(quotes[key].length === 0) { if(quotes[key].length === 0) {
delete quotes[key]; delete quotes[key];
@ -104,7 +104,7 @@ var quotes = function(dbot) {
}, },
'~rm': function(data, params) { '~rm': function(data, params) {
if(rmAllowed == true || data.user == dbot.admin) { if(rmAllowed == true || dbot.admin.include(data.user)) {
var q = data.message.valMatch(/^~rm ([\d\w\s-]*) (.+)$/, 3); var q = data.message.valMatch(/^~rm ([\d\w\s-]*) (.+)$/, 3);
if(q) { if(q) {
if(quotes.hasOwnProperty(q[1])) { if(quotes.hasOwnProperty(q[1])) {

2
run.js
View File

@ -39,7 +39,7 @@ var DBot = function(timers) {
// Populate bot properties with config data // Populate bot properties with config data
this.name = this.config.name || 'dbox'; this.name = this.config.name || 'dbox';
this.admin = this.config.admin || 'reality'; this.admin = this.config.admin || [ 'reality' ];
this.password = this.config.password || 'lolturtles'; this.password = this.config.password || 'lolturtles';
this.nickserv = this.config.nickserv || 'zippy'; this.nickserv = this.config.nickserv || 'zippy';
this.server = this.config.server || 'elara.ivixor.net'; this.server = this.config.server || 'elara.ivixor.net';