mirror of
https://github.com/reality/dbot.git
synced 2024-12-24 11:42:36 +01:00
ncount
This commit is contained in:
parent
80e9f245ab
commit
131233e7d0
@ -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<cCounts.length;i++) {
|
||||
cString += cCounts[i][0] + " (" + cCounts[i][1] + "), ";
|
||||
}
|
||||
cString = cString.slice(0, -2);
|
||||
|
||||
event.reply(dbot.t('total_notifies', {
|
||||
'user': event.user,
|
||||
'count': total,
|
||||
'cString': cString
|
||||
}));
|
||||
});
|
||||
},
|
||||
|
||||
'~clearmissing': function(event) {
|
||||
if(_.has(this.pending, event.rUser.id)) {
|
||||
var count = this.pending[event.rUser.id].length;
|
||||
|
@ -81,5 +81,8 @@
|
||||
"not_nunsubbed": {
|
||||
"en": "Already subscribed to notifications from {cName}.",
|
||||
"de": "Du bist bereits für {cName} Benachrichtigungen angemeldet"
|
||||
},
|
||||
"total_notifies": {
|
||||
"en": "{user} has a total of {count} notifies. Channels: {cString}"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user