mirror of
https://github.com/reality/dbot.git
synced 2024-12-25 04:02:39 +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 = function(dbot) {
|
||||||
var commands = {
|
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) {
|
'~clearmissing': function(event) {
|
||||||
if(_.has(this.pending, event.rUser.id)) {
|
if(_.has(this.pending, event.rUser.id)) {
|
||||||
var count = this.pending[event.rUser.id].length;
|
var count = this.pending[event.rUser.id].length;
|
||||||
|
@ -81,5 +81,8 @@
|
|||||||
"not_nunsubbed": {
|
"not_nunsubbed": {
|
||||||
"en": "Already subscribed to notifications from {cName}.",
|
"en": "Already subscribed to notifications from {cName}.",
|
||||||
"de": "Du bist bereits für {cName} Benachrichtigungen angemeldet"
|
"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