named rmlast

This commit is contained in:
Luke Slater 2011-09-04 15:49:52 +01:00
parent c413053a7b
commit ece8974659

View File

@ -18,16 +18,24 @@ var quotes = function(dbot) {
'~rmlast': function(data, params) { '~rmlast': function(data, params) {
if(rmAllowed == true) { if(rmAllowed == true) {
var last = addStack.pop(); var q = data.message.valMatch(/^~rmlast ([\d\w\s]*)/, 2);
if(last) { if(q) {
quotes[last].pop(); if(quotes.hasOwnProperty(q[1])) {
if(quotes[last] === undefined) { var quote = quotes[q[1]].pop();
delete quotes[last]; dbot.say('\'' + quote + '\' removed from ' + q[1]);
rmAllowed = false;
} else {
dbot.say(data.channel, 'No quotes exist under ' + q[1]);
} }
rmAllowed = false;
dbot.say(data.channel, 'Last quote removed from ' + last + '.');
} else { } else {
dbot.say(data.channel, 'No quotes were added recently.'); var last = addStack.pop();
if(last) {
quotes[last].pop();
rmAllowed = false;
dbot.say(data.channel, 'Last quote removed from ' + last + '.');
} else {
dbot.say(data.channel, 'No quotes were added recently.');
}
} }
} else { } else {
dbot.say(data.channel, 'No spamming that shit. Try again in a few minutes...'); dbot.say(data.channel, 'No spamming that shit. Try again in a few minutes...');