mirror of
https://github.com/reality/dbot.git
synced 2024-12-25 12:12:35 +01:00
overall ~loudest
This commit is contained in:
parent
bb37adc63d
commit
10a46a3bde
@ -1,4 +1,5 @@
|
|||||||
var _ = require('underscore')._;
|
var _ = require('underscore')._,
|
||||||
|
async = require('async');
|
||||||
|
|
||||||
var commands = function(dbot) {
|
var commands = function(dbot) {
|
||||||
var commands = {
|
var commands = {
|
||||||
@ -75,6 +76,33 @@ var commands = function(dbot) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'~loudest': function(event) {
|
||||||
|
var lines = {};
|
||||||
|
this.db.scan('user_stats', function(uStats) {
|
||||||
|
lines[uStats.id] = uStats.lines;
|
||||||
|
}, function() {
|
||||||
|
var lCounts = _.chain(lines)
|
||||||
|
.pairs()
|
||||||
|
.sortBy(function(user) { return user[1]; })
|
||||||
|
.reverse()
|
||||||
|
.first(10)
|
||||||
|
.value();
|
||||||
|
|
||||||
|
async.eachSeries(lCounts, function(lCount, next) {
|
||||||
|
dbot.api.users.getUser(lCount[0], function(user) {
|
||||||
|
lCount[0] = user.primaryNick;
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
}, function() {
|
||||||
|
var output = "Loudest users: ";
|
||||||
|
for(var i=0;i<lCounts.length;i++) {
|
||||||
|
output += lCounts[i][0] + " (" + lCounts[i][1] + "), ";
|
||||||
|
}
|
||||||
|
event.reply(output.slice(0, -2));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
'~clines': function(event) {
|
'~clines': function(event) {
|
||||||
if(!event.cStats) return;
|
if(!event.cStats) return;
|
||||||
event.reply(dbot.t('sstats_clines', {
|
event.reply(dbot.t('sstats_clines', {
|
||||||
|
Loading…
Reference in New Issue
Block a user