mirror of
https://github.com/reality/dbot.git
synced 2024-11-24 04:49:25 +01:00
underscorisation of kick [#81]
This commit is contained in:
parent
ca8a8ca9c2
commit
f36e6c781b
@ -1,3 +1,5 @@
|
||||
var _ = require('underscore')._;
|
||||
|
||||
var kick = function(dbot) {
|
||||
var commands = {
|
||||
// Give the number of times a given user has been kicked and has kicked
|
||||
@ -5,27 +7,35 @@ var kick = function(dbot) {
|
||||
'~kickcount': function(event) {
|
||||
var username = event.params[1];
|
||||
|
||||
if(!dbot.db.kicks.hasOwnProperty(username)) {
|
||||
if(!_.has(dbot.db.kicks, username)) {
|
||||
var kicks = '0';
|
||||
} else {
|
||||
var kicks = dbot.db.kicks[username];
|
||||
}
|
||||
|
||||
if(!dbot.db.kickers.hasOwnProperty(username)) {
|
||||
if(!_.has(dbot.db.kickers, username)) {
|
||||
var kicked = '0';
|
||||
} else {
|
||||
var kicked = dbot.db.kickers[username];
|
||||
}
|
||||
|
||||
event.reply(dbot.t('user_kicks', {'user': username, 'kicks': kicks, 'kicked': kicked}));
|
||||
event.reply(dbot.t('user_kicks', {
|
||||
'user': username,
|
||||
'kicks': kicks,
|
||||
'kicked': kicked
|
||||
}));
|
||||
},
|
||||
|
||||
// Output a list of the people who have been kicked the most and those
|
||||
// who have kicked other people the most.
|
||||
'~kickstats': function(event) {
|
||||
var orderedKickLeague = function(list, topWhat) {
|
||||
var kickArr = Object.prototype.sort(list, function(key, obj) { return obj[key]; });
|
||||
kickArr = kickArr.slice(kickArr.length - 10).reverse();
|
||||
var kickArr = _.chain(list)
|
||||
.pairs()
|
||||
.sortBy(function(kick) { return kick[1] })
|
||||
.reverse()
|
||||
.first(10)
|
||||
.value();
|
||||
|
||||
var kickString = "Top " + topWhat + ": ";
|
||||
for(var i=0;i<kickArr.length;i++) {
|
||||
@ -48,23 +58,26 @@ var kick = function(dbot) {
|
||||
'listener': function(event) {
|
||||
if(event.kickee == dbot.config.name) {
|
||||
dbot.instance.join(event, event.channel);
|
||||
event.reply(dbot.t('kicked_dbot', {'botname': dbot.config.name}));
|
||||
event.reply(dbot.t('kicked_dbot', { 'botname': dbot.config.name }));
|
||||
dbot.db.kicks[dbot.config.name] += 1;
|
||||
} else {
|
||||
if(!dbot.db.kicks.hasOwnProperty(event.kickee)) {
|
||||
if(!_.has(dbot.db.kicks, event.kickee)) {
|
||||
dbot.db.kicks[event.kickee] = 1;
|
||||
} else {
|
||||
dbot.db.kicks[event.kickee] += 1;
|
||||
}
|
||||
|
||||
if(!dbot.db.kickers.hasOwnProperty(event.user)) {
|
||||
if(!_.has(dbot.db.kickers, event.user)) {
|
||||
dbot.db.kickers[event.user] = 1;
|
||||
} else {
|
||||
dbot.db.kickers[event.user] += 1;
|
||||
}
|
||||
|
||||
event.reply(event.kickee + '-- (' + dbot.t('user_kicks',
|
||||
{'user': event.kickee, 'kicks': dbot.db.kicks[event.kickee], 'kicked': dbot.db.kickers[event.kickee]}) + ')');
|
||||
event.reply(event.kickee + '-- (' + dbot.t('user_kicks', {
|
||||
'user': event.kickee,
|
||||
'kicks': dbot.db.kicks[event.kickee],
|
||||
'kicked': dbot.db.kickers[event.kickee]
|
||||
}) + ')');
|
||||
}
|
||||
},
|
||||
on: 'KICK'
|
||||
|
Loading…
Reference in New Issue
Block a user