From 131233e7d0f512ef381de53266a55645feefe3ed Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 25 May 2014 20:47:30 +0000 Subject: [PATCH] ncount --- modules/report/commands.js | 32 ++++++++++++++++++++++++++++++++ modules/report/strings.json | 3 +++ 2 files changed, 35 insertions(+) diff --git a/modules/report/commands.js b/modules/report/commands.js index b1b32f7..4234c6f 100644 --- a/modules/report/commands.js +++ b/modules/report/commands.js @@ -2,6 +2,38 @@ var _ = require('underscore')._; var commands = function(dbot) { var commands = { + '~ncount': function(event) { + var chanCounts = {}, + total = 0; + + this.db.scan('notifies', function(notify) { + if(notify.user == event.rUser.id) { + if(!_.has(chanCounts, notify.channel)) chanCounts[notify.channel] = 0; + chanCounts[notify.channel]++; + total++; + } + }, function() { + var cCounts = _.chain(chanCounts) + .pairs() + .sortBy(function(p) { return p[1]; }) + .reverse() + .first(10) + .value(); + + var cString = ''; + for(var i=0;i