2013-01-12 22:54:02 +01:00
|
|
|
var _ = require('underscore')._;
|
|
|
|
|
2012-12-11 17:04:52 +01:00
|
|
|
var report = function(dbot) {
|
|
|
|
var commands = {
|
|
|
|
'~report': function(event) {
|
|
|
|
var channelName = event.input[1];
|
|
|
|
var nick = event.input[2];
|
|
|
|
var reason = event.input[3];
|
|
|
|
|
2013-01-12 22:54:02 +01:00
|
|
|
if(_.has(event.allChannels, channelName)) {
|
2012-12-11 17:04:52 +01:00
|
|
|
var channel = event.allChannels[channelName];
|
2013-01-20 20:04:12 +01:00
|
|
|
if(dbot.api.users.isChannelUser(event.server, nick, channelName, true)) {
|
|
|
|
var nick = dbot.api.users.resolveUser(event.server, nick, true);
|
2013-01-12 22:54:02 +01:00
|
|
|
var ops = _.filter(channel.nicks, function(user) {
|
2013-04-12 20:31:02 +02:00
|
|
|
if(this.config.notifyVoice) {
|
|
|
|
return user.op || user.voice;
|
|
|
|
} else {
|
|
|
|
return user.op;
|
|
|
|
}
|
|
|
|
}, this);
|
2012-12-11 17:04:52 +01:00
|
|
|
|
2013-01-12 22:54:02 +01:00
|
|
|
_.each(ops, function(user) {
|
|
|
|
dbot.say(event.server, user.name, dbot.t('report', {
|
2012-12-30 17:33:25 +01:00
|
|
|
'reporter': event.user,
|
|
|
|
'reported': nick,
|
|
|
|
'channel': channelName,
|
|
|
|
'reason': reason
|
|
|
|
}));
|
2013-01-12 22:54:02 +01:00
|
|
|
}, this);
|
2012-12-11 17:04:52 +01:00
|
|
|
|
2012-12-30 17:33:25 +01:00
|
|
|
event.reply(dbot.t('reported', { 'reported': nick }));
|
2012-12-11 17:04:52 +01:00
|
|
|
} else {
|
2012-12-30 17:33:25 +01:00
|
|
|
event.reply(dbot.t('user_not_found', { 'reported': nick,
|
|
|
|
'channel': channelName }));
|
2012-12-11 17:04:52 +01:00
|
|
|
}
|
|
|
|
} else {
|
2012-12-30 17:33:25 +01:00
|
|
|
event.reply(dbot.t('not_in_channel', { 'channel': channelName }));
|
2012-12-11 17:04:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
commands['~report'].regex = [/^~report ([^ ]+) ([^ ]+) (.+)$/, 4];
|
2013-01-15 17:54:51 +01:00
|
|
|
this.commands = commands;
|
2012-12-11 17:04:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
2013-01-15 17:54:51 +01:00
|
|
|
return new report(dbot);
|
2012-12-11 17:04:52 +01:00
|
|
|
};
|