From 5d7bc0ad146ec57841c9b458b46f2dd02849c8f4 Mon Sep 17 00:00:00 2001 From: n3hima / Joe MacMahon Date: Sat, 14 Jan 2012 10:27:23 +0000 Subject: [PATCH] Added an ~rm command which can remove quotes which are not the most-recently-added quote --- modules/quotes.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/quotes.js b/modules/quotes.js index 229f70c..b4c8b4c 100644 --- a/modules/quotes.js +++ b/modules/quotes.js @@ -83,6 +83,34 @@ var quotes = function(dbot) { } }, + '~rm': function(data, params) { + if(rmAllowed == true || data.user == dbot.admin) { + var q = data.message.valMatch(/^~rm ([\d\w\s-]*) (.+)$/, 3); + if(q) { + if(quotes.hasOwnProperty(q[1])) { + if(!dbot.db.locks.include(q[1])) { + var index = quotes[q[1]].indexOf(q[2]); + if(index != -1) { + quotes[q[1]].splice(index, 1); + rmAllowed = false; + dbot.say(data.channel, '\'' + q[2] + '\' removed from ' + q[1]); + } else { + dbot.say(data.channel, '\'' + q[2] + '\' doesn\'t exist under user \'' + q[1] + '\'.'); + } + } else { + dbot.say(data.channel, q[1] + ' is locked. Initiate incineration.'); + } + } else { + dbot.say(data.channel, 'No quotes exist under ' + q[1]); + } + } else { + dbot.say(data.channel, 'Invalid syntax. Initiate incineration.'); + } + } else { + dbot.say(data.channel, 'No spamming that shit. Try again in a few minutes...'); + } + }, + '~qcount': function(data, params) { var q = data.message.valMatch(/^~qcount ([\d\w\s-]*)/, 2); if(q) {