3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-18 16:42:39 +01:00
dbot/modules/kick/kick.js

52 lines
1.6 KiB
JavaScript
Raw Normal View History

2013-01-12 23:53:13 +01:00
var _ = require('underscore')._;
var kick = function(dbot) {
this.api = {
'ban': function(server, user, channel) {
2013-04-14 20:39:32 +02:00
dbot.say(event.server, this.config.chanserv, 'ban ' + user);
},
'quiet': function(server, user, channel) {
2013-04-14 20:39:32 +02:00
dbot.say(event.server, this.config.chanserv, 'quiet ' + user);
},
'kick': function(server, user, channel, msg) {
2013-02-05 20:26:29 +01:00
dbot.instance.connections[server].send('KICK ' + channel + ' ' + user + ' :' + msg);
}
};
2013-01-15 00:00:16 +01:00
this.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 }));
dbot.db.kicks[dbot.config.name] += 1;
} else {
if(!_.has(dbot.db.kicks, event.kickee)) {
dbot.db.kicks[event.kickee] = 1;
} else {
2013-01-15 00:00:16 +01:00
dbot.db.kicks[event.kickee] += 1;
}
2013-01-15 00:00:16 +01:00
if(!_.has(dbot.db.kickers, event.user)) {
dbot.db.kickers[event.user] = 1;
} else {
dbot.db.kickers[event.user] += 1;
}
2013-01-15 00:00:16 +01:00
if(!this.config.countSilently) {
event.reply(event.kickee + '-- (' + dbot.t('user_kicks', {
'user': event.kickee,
'kicks': dbot.db.kicks[event.kickee],
'kicked': dbot.db.kickers[event.kickee]
}) + ')');
}
2013-01-15 00:00:16 +01:00
}
}.bind(this);
2013-01-15 00:00:16 +01:00
this.on = 'KICK';
};
exports.fetch = function(dbot) {
2013-01-15 00:00:16 +01:00
return new kick(dbot);
};