From df33de486c3e42f2e57725a463df0e00f20258ed Mon Sep 17 00:00:00 2001 From: Psychedelic Squid Date: Sat, 10 Mar 2012 18:10:04 +0000 Subject: [PATCH] Pruning. --- modules/quotes.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/quotes.js b/modules/quotes.js index 491233c..73f681c 100644 --- a/modules/quotes.js +++ b/modules/quotes.js @@ -205,6 +205,23 @@ var quotes = function(dbot) { } else { dbot.say(data.channel, 'Link to "'+params[1]+'" - http://nc.no.de:443/quotes/'+params[1]); } + }, + + '~qprune': function(data) { + var pruned = [] + for(key in quotes) { + if(quotes.hasOwnProperty(key)) { + if(quotes[key].length == 0) { + delete quotes[key]; + pruned.push(key); + } + } + } + if(pruned.length > 0) { + dbot.say(data.channel, "Pruned empty quote categories: " + pruned.join(", ")); + } else { + dbot.say(data.channel, "No empty quote categories. You're good to go!"); + } } };