3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-24 11:42:36 +01:00

kickstats

This commit is contained in:
Luke Slater 2011-10-12 17:49:00 +01:00
parent cbd96fb765
commit 50e7b46047

View File

@ -34,7 +34,26 @@ var userCommands = function(dbot) {
var orderedKicks = kickArr.sort(function(a, b) { return a[1] - b[1]; });
var topKicks = kickArr.slice(kickArr.length - 5).reverse();
var kickString = "Top Kicks: ";
var kickString = "Top Kicked: ";
for(var i=0;i<topKicks.length;i++) {
kickString += topKicks[i][0] + " (" + topKicks[i][1] + "), ";
}
kickString = kickString.slice(0, -2);
dbot.say(data.channel, kickString);
// code repetition bad
var kickArr = [];
for(var kickUser in dbot.db.kickers) {
if(dbot.db.kickers.hasOwnProperty(kickUser)) {
kickArr.push([kickUser, dbot.db.kickers[kickUser]]);
}
}
var orderedKicks = kickArr.sort(function(a, b) { return a[1] - b[1]; });
var topKicks = kickArr.slice(kickArr.length - 5).reverse();
var kickString = "Top Kickers: ";
for(var i=0;i<topKicks.length;i++) {
kickString += topKicks[i][0] + " (" + topKicks[i][1] + "), ";