~kickstats

This commit is contained in:
Luke Slater 2011-09-12 16:38:10 +01:00
parent 33fc7712a8
commit c453c80536
2 changed files with 21 additions and 1 deletions

View File

@ -22,8 +22,8 @@ var quotes = function(dbot) {
if(q) {
if(quotes.hasOwnProperty(q[1])) {
var quote = quotes[q[1]].pop();
dbot.say(data.channel, '\'' + quote + '\' removed from ' + q[1]);
rmAllowed = false;
dbot.say(data.channel, '\'' + quote + '\' removed from ' + q[1]);
} else {
dbot.say(data.channel, 'No quotes exist under ' + q[1]);
}

View File

@ -13,6 +13,26 @@ var userCommands = function(dbot) {
} else {
dbot.say(data.channel, params[1] + ' has been kicked ' + dbot.db.kicks[params[1]] + ' times.');
}
},
'~kickstats': function(data, params) {
var kickArr = [];
for(var kickUser in dbot.db.kicks) {
if(dbot.db.kicks.hasOwnProperty(kickUser)) {
kickArr.push([kickUser, dbot.db.kicks[kickUser]]);
}
}
var orderedKicks = kickArr.sort(function(a, b) { return a[1] - b[1]; });
var topKicks = kickArr.slice(kickArr.length - 5).reverse();
var kickString = "Top Kicks: ";
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);
}
};