quote locks

This commit is contained in:
Luke Slater 2011-10-14 13:24:18 +01:00
parent 1f4c3fec8f
commit a5960b8daf
2 changed files with 19 additions and 6 deletions

View File

@ -66,6 +66,11 @@ var adminCommands = function(dbot) {
'modehate': function(data, params) { 'modehate': function(data, params) {
dbot.db.modehate.push(params[1]); dbot.db.modehate.push(params[1]);
dbot.say(data.channel, 'Now modehating on ' + params[1]); dbot.say(data.channel, 'Now modehating on ' + params[1]);
},
'lock': function(data, params) {
dbot.db.locks.push(params[1]);
dbot.say(data.channel, 'Locked ' + params[1] + ' quotes.');
} }
}; };

View File

@ -46,18 +46,26 @@ var quotes = function(dbot) {
var q = data.message.valMatch(/^~rmlast ([\d\w\s]*)/, 2); var q = data.message.valMatch(/^~rmlast ([\d\w\s]*)/, 2);
if(q) { if(q) {
if(quotes.hasOwnProperty(q[1])) { if(quotes.hasOwnProperty(q[1])) {
var quote = quotes[q[1]].pop(); if(!dbot.db.locks.include(q[1])) {
rmAllowed = false; var quote = quotes[q[1]].pop();
dbot.say(data.channel, '\'' + quote + '\' removed from ' + q[1]); rmAllowed = false;
dbot.say(data.channel, '\'' + quote + '\' removed from ' + q[1]);
} else {
dbot.say(data.channel, param[1] + ' is locked. Commence incineration.');
}
} else { } else {
dbot.say(data.channel, 'No quotes exist under ' + q[1]); dbot.say(data.channel, 'No quotes exist under ' + q[1]);
} }
} else { } else {
var last = addStack.pop(); var last = addStack.pop();
if(last) { if(last) {
quotes[last].pop(); if(!dbot.db.locks.include(last)) {
rmAllowed = false; quotes[last].pop();
dbot.say(data.channel, 'Last quote removed from ' + last + '.'); rmAllowed = false;
dbot.say(data.channel, 'Last quote removed from ' + last + '.');
} else {
dbot.say(data.channel, last + ' is locked. Commence incineration.');
}
} else { } else {
dbot.say(data.channel, 'No quotes were added recently.'); dbot.say(data.channel, 'No quotes were added recently.');
} }