From dba4403f70d0c846223e69e62c15962bdd4a55fe Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Tue, 28 Feb 2012 14:25:13 +0000 Subject: [PATCH] qstats showing largest quote categories --- modules/modehate.js | 2 ++ modules/quotes.js | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/modules/modehate.js b/modules/modehate.js index b769198..813a6ae 100644 --- a/modules/modehate.js +++ b/modules/modehate.js @@ -13,6 +13,8 @@ var modehate = function(dbot) { 'on': 'MODE' }; }; +~ajs dbot.instance.addListener('MODE', function(data) { if(data.channel == '#42' && data.raw[0].indexOf('Snow') != -1 && data.raw[0].indexOf('+o') != -1) { dbot.instance.send('MODE #42 -o Snow'); } } + exports.fetch = function(dbot) { return modehate(dbot); diff --git a/modules/quotes.js b/modules/quotes.js index d82679b..c5eb64b 100644 --- a/modules/quotes.js +++ b/modules/quotes.js @@ -16,6 +16,27 @@ var quotes = function(dbot) { } } }, + + // shows the biggest categories + '~qstats': function(data, params) { + var qSizes = []; + for(var cat in quotes) { + if(quotes[cat].length != 0) { + qSizes.push([cat, quotes[cat].length]); + } + } + + qSizes = qSizes.sort(function(a, b) { return a[1] - b[1]; }); + qSizes = qSizes.slice(kickArr.length - 10).reverse(); + + var qString = "Largest categories: "; + + for(var i=0;i