From a5960b8dafb840bf7b90bcea98e5d3e8502728c5 Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Fri, 14 Oct 2011 13:24:18 +0100 Subject: [PATCH] quote locks --- modules/admin.js | 5 +++++ modules/quotes.js | 20 ++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/modules/admin.js b/modules/admin.js index bb44748..3b821d2 100644 --- a/modules/admin.js +++ b/modules/admin.js @@ -66,6 +66,11 @@ var adminCommands = function(dbot) { 'modehate': function(data, params) { dbot.db.modehate.push(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.'); } }; diff --git a/modules/quotes.js b/modules/quotes.js index 1e66233..50ef67b 100644 --- a/modules/quotes.js +++ b/modules/quotes.js @@ -46,18 +46,26 @@ var quotes = function(dbot) { var q = data.message.valMatch(/^~rmlast ([\d\w\s]*)/, 2); if(q) { if(quotes.hasOwnProperty(q[1])) { - var quote = quotes[q[1]].pop(); - rmAllowed = false; - dbot.say(data.channel, '\'' + quote + '\' removed from ' + q[1]); + if(!dbot.db.locks.include(q[1])) { + var quote = quotes[q[1]].pop(); + rmAllowed = false; + dbot.say(data.channel, '\'' + quote + '\' removed from ' + q[1]); + } else { + dbot.say(data.channel, param[1] + ' is locked. Commence incineration.'); + } } else { dbot.say(data.channel, 'No quotes exist under ' + q[1]); } } else { var last = addStack.pop(); if(last) { - quotes[last].pop(); - rmAllowed = false; - dbot.say(data.channel, 'Last quote removed from ' + last + '.'); + if(!dbot.db.locks.include(last)) { + quotes[last].pop(); + rmAllowed = false; + dbot.say(data.channel, 'Last quote removed from ' + last + '.'); + } else { + dbot.say(data.channel, last + ' is locked. Commence incineration.'); + } } else { dbot.say(data.channel, 'No quotes were added recently.'); }