2012-02-11 17:17:52 +01:00
|
|
|
// Commands that probably belong elsewhere.
|
2011-08-22 18:54:12 +02:00
|
|
|
var userCommands = function(dbot) {
|
|
|
|
var dbot = dbot;
|
|
|
|
|
|
|
|
var commands = {
|
2012-02-11 17:17:52 +01:00
|
|
|
// Give a karma comment for a given user
|
2011-08-22 18:54:12 +02:00
|
|
|
'~kc': function(data, params) {
|
|
|
|
dbot.say('aisbot', '.karma ' + data.message.split(' ')[1]);
|
|
|
|
dbot.waitingForKarma = data.channel;
|
|
|
|
},
|
|
|
|
|
2012-02-11 17:17:52 +01:00
|
|
|
// Give the number of times a given user has been kicked and has kicked
|
|
|
|
// other people.
|
2011-08-22 18:54:12 +02:00
|
|
|
'~kickcount': function(data, params) {
|
2011-08-24 02:57:52 +02:00
|
|
|
if(!dbot.db.kicks.hasOwnProperty(params[1])) {
|
2011-10-12 18:43:53 +02:00
|
|
|
var kicks = '0';
|
2011-10-12 18:45:00 +02:00
|
|
|
} else {
|
|
|
|
var kicks = dbot.db.kicks[params[1]];
|
2011-08-22 18:54:12 +02:00
|
|
|
}
|
2011-10-12 18:43:53 +02:00
|
|
|
|
|
|
|
if(!dbot.db.kickers.hasOwnProperty(params[1])) {
|
|
|
|
var kicked = '0';
|
2011-10-12 18:45:00 +02:00
|
|
|
} else {
|
|
|
|
var kicked = dbot.db.kickers[params[1]];
|
2011-10-12 18:43:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dbot.say(data.channel, params[1] + ' has been kicked ' + kicks + ' times and has kicked people ' + kicked + ' times.');
|
2011-09-12 17:38:10 +02:00
|
|
|
},
|
|
|
|
|
2012-02-11 17:17:52 +01:00
|
|
|
// Output a list of the people who have been kicked the most and those
|
|
|
|
// who have kicked other people the most.
|
2011-09-12 17:38:10 +02:00
|
|
|
'~kickstats': function(data, params) {
|
2012-02-11 17:17:52 +01:00
|
|
|
var orderedKickLeague = function(list, topWhat) {
|
|
|
|
var kickArr = [];
|
|
|
|
for(var kickUser in list) {
|
|
|
|
if(list.hasOwnProperty(kickUser)) {
|
|
|
|
kickArr.push([kickUser, list[kickUser]]);
|
|
|
|
}
|
2011-09-12 17:38:10 +02:00
|
|
|
}
|
2011-10-12 18:49:00 +02:00
|
|
|
|
2012-02-11 17:17:52 +01:00
|
|
|
kickArr = kickArr.sort(function(a, b) { return a[1] - b[1]; });
|
|
|
|
kickArr = kickArr.slice(kickArr.length - 10).reverse();
|
|
|
|
var kickString = "Top " + topWhat + ": ";
|
2011-10-12 18:49:00 +02:00
|
|
|
|
2012-02-11 17:19:40 +01:00
|
|
|
for(var i=0;i<kickArr.length;i++) {
|
|
|
|
kickString += kickArr[i][0] + " (" + kickArr[i][1] + "), ";
|
2011-10-12 18:49:00 +02:00
|
|
|
}
|
|
|
|
|
2012-02-11 17:17:52 +01:00
|
|
|
return kickString.slice(0, -2);
|
|
|
|
};
|
2011-09-12 17:38:10 +02:00
|
|
|
|
2012-02-11 17:17:52 +01:00
|
|
|
dbot.say(data.channel, orderedKickLeague(dbot.db.kicks, 'Kicked'));
|
|
|
|
dbot.say(data.channel, orderedKickLeague(dbot.db.kickers, 'Kickers'));
|
2011-08-22 18:54:12 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
2011-08-28 16:00:22 +02:00
|
|
|
'onLoad': function() {
|
|
|
|
return commands;
|
|
|
|
}
|
2011-08-22 19:56:36 +02:00
|
|
|
};
|
2011-08-22 18:54:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
|
|
|
return userCommands(dbot);
|
|
|
|
};
|