various fixes to the reporting system and related stuff

This commit is contained in:
reality 2016-01-28 18:29:51 +00:00
parent ac9488bad9
commit c10b65ef3b
5 changed files with 77 additions and 60 deletions

View File

@ -7,7 +7,7 @@ var commands = function(dbot) {
'~quiet': function(event) { '~quiet': function(event) {
var server = event.server, var server = event.server,
quieter = event.user, quieter = event.user,
duration = event.input[1].trim(), duration = event.input[1],
channel = (event.input[2] || event.channel.name).trim(), channel = (event.input[2] || event.channel.name).trim(),
quietee = event.input[3].trim(), quietee = event.input[3].trim(),
reason = event.input[4] || "N/A"; reason = event.input[4] || "N/A";
@ -17,14 +17,15 @@ var commands = function(dbot) {
if(host) { if(host) {
this.hosts[server][quietee] = host; this.hosts[server][quietee] = host;
if(!_.isUndefined(duration)) { if(!_.isUndefined(duration) && !_.isNull(duration)) {
duration = duration.trim();
var msTimeout = new Date(new Date().getTime() + (parseFloat(duration) * 60000)); var msTimeout = new Date(new Date().getTime() + (parseFloat(duration) * 60000));
if(_.has(dbot.modules, 'remind')) { if(_.has(dbot.modules, 'remind')) {
msTimeout = dbot.api.remind.parseTime(duration); msTimeout = dbot.api.remind.parseTime(duration);
if(!msTimeout) { if(!msTimeout) {
return event.reply('Invalid time. Remember you must give e.g. 5m now.'); return event.reply('Invalid time. Remember you must give e.g. 5m now.');
} }
duration = duration.replace(/([\d]+)d/, '$1 days').replace(/([\d]+)h/, '$1 hours ').replace(/([\d]+)m/, '$1 minutes ').replace(/([\d]+)s/, '$1 seconds'); duration = duration.replace(/([\d]+)d/, '$1 days').replace(/([\d]+)h/, '$1 hours ').replace(/([\d]+)m/, '$1 minutes ').replace(/([\d]+)s/, '$1 seconds').trim();
} else { } else {
duration += ' minutes'; duration += ' minutes';
} }
@ -44,7 +45,7 @@ var commands = function(dbot) {
dbot.t('unquiet_notify', { dbot.t('unquiet_notify', {
'unquieter': dbot.config.name, 'unquieter': dbot.config.name,
'quietee': quietee 'quietee': quietee
})); }), false, quietee);
}); });
} }
}.bind(this)); }.bind(this));
@ -58,7 +59,7 @@ var commands = function(dbot) {
'quieter': event.rUser.primaryNick, 'quieter': event.rUser.primaryNick,
'quietee': quietee, 'quietee': quietee,
'reason': reason 'reason': reason
}) }), false, quietee
); );
} else { } else {
event.reply(dbot.t('quieted', { 'quietee': quietee })); event.reply(dbot.t('quieted', { 'quietee': quietee }));
@ -67,7 +68,7 @@ var commands = function(dbot) {
'quieter': quieter, 'quieter': quieter,
'quietee': quietee, 'quietee': quietee,
'reason': reason 'reason': reason
})); }), false, quietee);
} }
this.api.devoice(server, quietee, channel); this.api.devoice(server, quietee, channel);
@ -106,7 +107,7 @@ var commands = function(dbot) {
dbot.t('unquiet_notify', { dbot.t('unquiet_notify', {
'unquieter': quieter, 'unquieter': quieter,
'quietee': quietee 'quietee': quietee
})); }), false, quietee);
} }
}, },
@ -128,7 +129,7 @@ var commands = function(dbot) {
'kicker': kicker, 'kicker': kicker,
'kickee': kickee, 'kickee': kickee,
'reason': reason 'reason': reason
})); }), false, kickee);
}, },
// Kick and ban from all channels on the network. // Kick and ban from all channels on the network.
@ -151,11 +152,24 @@ var commands = function(dbot) {
dbot.api.nickserv.getUserHost(event.server, banee, function(host) { dbot.api.nickserv.getUserHost(event.server, banee, function(host) {
// Add host record entry // Add host record entry
if(host) { if(host) {
if((reason.match('#line') || reason.match('#specialk') || reason.match('#kline')) && _.include(dbot.access.moderator(), event.rUser.primaryNick)) {
var t = ' !P ';
if(timeout) {
t = ' !T ' + (timeout * 60);
}
dbot.say(event.server, 'operserv', 'akill add '+banee + t + banee + ' banned by ' + banner + ': ' + reason);
}
// Ban from current channel first // Ban from current channel first
this.api.ban(server, host, event.channel); this.api.ban(server, host, event.channel);
this.api.kick(server, banee, event.channel, reason + this.api.kick(server, banee, event.channel, reason +
' (network-wide ban requested by ' + banner + ')'); ' (network-wide ban)');
channels = _.without(channels, event.channel); channels = _.without(channels, event.channel);
if(!_.isUndefined(adminChannel)) {
channels = _.without(channels, adminChannel);
} else {
adminChannel = event.channel.name;
}
// Ban the user from all channels // Ban the user from all channels
var i = 0; var i = 0;
@ -164,7 +178,7 @@ var commands = function(dbot) {
var channel = channels[i]; var channel = channels[i];
this.api.ban(server, host, channel); this.api.ban(server, host, channel);
this.api.kick(server, banee, channel, reason + this.api.kick(server, banee, channel, reason +
' (network-wide ban requested by ' + banner + ')'); ' (network-wide ban)');
i++; banChannel(channels); i++; banChannel(channels);
}.bind(this); }.bind(this);
banChannel(channels); banChannel(channels);
@ -181,7 +195,7 @@ var commands = function(dbot) {
if(!msTimeout) { if(!msTimeout) {
return event.reply('Invalid time. Remember you must give e.g. 5m now.'); return event.reply('Invalid time. Remember you must give e.g. 5m now.');
} }
timeout = timeout.replace(/([\d]+)d/, '$1 days').replace(/([\d]+)h/, '$1 hours ').replace(/([\d]+)m/, '$1 minutes ').replace(/([\d]+)s/, '$1 seconds'); timeout = timeout.replace(/([\d]+)d/, '$1 days').replace(/([\d]+)h/, '$1 hours ').replace(/([\d]+)m/, '$1 minutes ').replace(/([\d]+)s/, '$1 seconds').trim();
} else { } else {
timeout += ' hours'; timeout += ' hours';
} }
@ -228,7 +242,7 @@ var commands = function(dbot) {
adminChannel = event.channel.name; adminChannel = event.channel.name;
} }
dbot.api.report.notify('ban', server, event.rUser, adminChannel, notifyString); dbot.api.report.notify('ban', server, event.rUser, adminChannel, notifyString, false, banee);
dbot.say(event.server, adminChannel, notifyString); dbot.say(event.server, adminChannel, notifyString);
if(!_.isUndefined(timeout)) { if(!_.isUndefined(timeout)) {
@ -326,10 +340,12 @@ var commands = function(dbot) {
commands['~kickstats'].access = 'regular'; commands['~kickstats'].access = 'regular';
commands['~quiet'].access = 'voice'; commands['~quiet'].access = 'voice';
commands['~unquiet'].access = 'voice'; commands['~unquiet'].access = 'voice';
commands['~nban'].access = 'power_user';
commands['~nunban'].access = 'power_user';
commands['~ckick'].regex = /^ckick (#[^ ]+ )?([^ ]+) ?(.*)?$/; commands['~ckick'].regex = /^ckick (#[^ ]+ )?([^ ]+) ?(.*)?$/;
commands['~nban'].regex = /^nban ([\d\.dhms^ ]+)?([^ ]+) (.+)$/; commands['~nban'].regex = /^nban (\d[\d\.dhms^ ]+)?([^ ]+) (.+)$/;
commands['~quiet'].regex = /^quiet ([\d\.dhms^ ]+)?(#[^ ]+ )?([^ ]+) ?(.*)?$/; commands['~quiet'].regex = /^quiet (\d[\d\.hms^ ]+)?(#[^ ]+ )?([^ ]+) ?(.*)?$/;
commands['~unquiet'].regex = /^unquiet (#[^ ]+ )?([^ ]+) ?$/; commands['~unquiet'].regex = /^unquiet (#[^ ]+ )?([^ ]+) ?$/;
return commands; return commands;

View File

@ -50,7 +50,7 @@ var kick = function(dbot) {
'unbanee': unbanee, 'unbanee': unbanee,
'unbanner': unbanner.currentNick 'unbanner': unbanner.currentNick
}); });
dbot.api.report.notify('unban', server, unbanner, adminChannel, notifyString); dbot.api.report.notify('unban', server, unbanner, adminChannel, notifyString, false, unbanee);
dbot.say(server, adminChannel, notifyString); dbot.say(server, adminChannel, notifyString);
// Notify Unbanee // Notify Unbanee

View File

@ -89,6 +89,9 @@ var commands = function(dbot) {
'~sustatus': function(event) { '~sustatus': function(event) {
var user = event.input[1]; var user = event.input[1];
if(event.channel == '#tripsit.me') {
return event.reply('~_~ do that in #moderators ~_~');
}
dbot.api.users.resolveUser(event.server, user, function(err, user) { dbot.api.users.resolveUser(event.server, user, function(err, user) {
if(user) { if(user) {
@ -106,11 +109,32 @@ var commands = function(dbot) {
dbot.modules.report.db.search('notifies', { dbot.modules.report.db.search('notifies', {
'server': event.server 'server': event.server
}, function(notify) { }, function(notify) {
_.each(aliases, function(alias) { if(_.include(aliases, notify.target)) {
if(notify.type == 'ban') {
ban++;
if(notify.time > latest_ban.time) {
latest_ban = notify;
}
} else if(notify.type == 'unban') {
unban++;
if(notify.time > latest_unban.time) {
latest_unban = notify;
}
} else if(notify.type == 'quiet') {
quiet++;
} else if(notify.type == 'warn') {
warn++;
} else if(notify.type == 'report') {
report++;
}
items[notify.time] = notify.message;
}
/*_.each(aliases, function(alias) {
if(notify.message.indexOf('banned ' + alias + ' ') != -1 || if(notify.message.indexOf('banned ' + alias + ' ') != -1 ||
notify.message.indexOf(' ' + alias + ' has been unbanned') != -1 || notify.message.indexOf(' ' + alias + ' has been unbanned') != -1 ||
notify.message.indexOf('issued a warning to ' + alias + ' ') != -1 || notify.message.indexOf('issued a warning to ' + alias) != -1 ||
notify.message.indexOf('has quieted ' + alias + ' ') != -1 || notify.message.indexOf('has quieted ' + alias) != -1 ||
notify.message.indexOf('has reported ' + alias + ' ') != -1) { notify.message.indexOf('has reported ' + alias + ' ') != -1) {
if(notify.type == 'ban') { if(notify.type == 'ban') {
ban++; ban++;
@ -132,6 +156,7 @@ var commands = function(dbot) {
items[notify.time] = notify.message; items[notify.time] = notify.message;
} }
}); });
*/
}, function() { }, function() {
if(quiet != 0 || warn != 0 || report != 0) { if(quiet != 0 || warn != 0 || report != 0) {
event.reply(user.primaryNick + ' has been warned ' + warn + ' times, quieted ' + quiet + ' times, and reported ' + report + ' times.'); event.reply(user.primaryNick + ' has been warned ' + warn + ' times, quieted ' + quiet + ' times, and reported ' + report + ' times.');
@ -140,7 +165,7 @@ var commands = function(dbot) {
return parseInt(a) - parseInt(b); return parseInt(a) - parseInt(b);
}); });
if(sTimes.length < 50) { if(sTimes.length < 70) {
_.each(sTimes, function(time) { _.each(sTimes, function(time) {
event.reply('[' + moment(parseInt(time)).format('DD/MM/YYYY') + '] ' + items[time]); event.reply('[' + moment(parseInt(time)).format('DD/MM/YYYY') + '] ' + items[time]);
}); });
@ -198,9 +223,10 @@ var commands = function(dbot) {
}, function() { }, function() {
if(ban) { if(ban) {
event.reply(user.primaryNick + ' was banned on ' + new Date(ban).toUTCString()); event.reply(user.primaryNick + ' was banned on ' + new Date(ban).toUTCString());
} else if(quiet != 0 || warn != 0) { }
if(quiet != 0 || warn != 0) {
event.reply(user.primaryNick + ' has been warned ' + warn + ' times, and quieted ' + quiet + ' times.'); event.reply(user.primaryNick + ' has been warned ' + warn + ' times, and quieted ' + quiet + ' times.');
} else { } else if(!ban) {
event.reply(user.primaryNick + ' has no record.'); event.reply(user.primaryNick + ' has no record.');
} }
}); });
@ -240,7 +266,7 @@ var commands = function(dbot) {
'reporter': event.rUser.primaryNick, 'reporter': event.rUser.primaryNick,
'reportee': nick, 'reportee': nick,
'reason': reason 'reason': reason
})); }), false, nick);
event.reply(dbot.t('reported', { 'reported': nick })); event.reply(dbot.t('reported', { 'reported': nick }));
} else { } else {
event.reply(dbot.t('user_not_found', { event.reply(dbot.t('user_not_found', {
@ -333,33 +359,6 @@ var commands = function(dbot) {
} else { } else {
event.reply('Channel not known.'); event.reply('Channel not known.');
} }
},
'~concerning': function(event) {
var nick = event.params[1].trim();
dbot.api.nickserv.getUserHost(event.server, nick, function(host) {
if(host) {
var results = [];
this.db.scan('notifies', function(notify) {
if(notify && _.has(notify, 'host') && (notify.host == host || notify.message.split(' ')[0] == nick)) {
results.push(notify);
}
}, function() {
event.reply(nick + ' has sought help ' + results.length + ' times under the host ' + host + ' or nick ' + nick);
_.each(results, function(n) {
event.reply('[' + moment(parseInt(n.time)).format('DD/MM/YYYY HH:mm:ss') + '][' + n.user.split('.')[0] + '] ' + n.message);
});
});
} else {
dbot.api.quotes.getQuote('deal with it', function(quote) {
var out = 'Couldn\'t find user\'s host, but that doesn\'t necessarily mean they don\'t exist. This is the lazy way of doing it for now... ';
if(quote) {
out += quote;
}
event.reply(out);
});
}
}.bind(this));
} }
}; };
commands['~report'].regex = /^report (#[^ ]+ )?([^ ]+) (.*)$/; commands['~report'].regex = /^report (#[^ ]+ )?([^ ]+) (.*)$/;

View File

@ -54,7 +54,7 @@ var report = function(dbot) {
if(_.has(this.pending, event.rUser.id) && this.pNotify[event.rUser.id] === true && !_.include(event.rUser.mobile, event.rUser.currentNick)) { if(_.has(this.pending, event.rUser.id) && this.pNotify[event.rUser.id] === true && !_.include(event.rUser.mobile, event.rUser.currentNick)) {
dbot.say(event.server, event.user, dbot.t('missed_notifies', { dbot.say(event.server, event.user, dbot.t('missed_notifies', {
'user': event.rUser.primaryNick, 'user': event.rUser.primaryNick,
'link': dbot.api.web.getUrl('notify/missing') 'link': dbot.api.web.getUrl('notify/stream/missing')
})); }));
this.pNotify[event.rUser.id] = false; this.pNotify[event.rUser.id] = false;
} }

View File

@ -25,7 +25,7 @@ var warning = function(dbot) {
+ warnee.primaryNick) + warnee.primaryNick)
}); });
dbot.api.report.notify('warn', server, warner, adminChannel, notifyString); dbot.api.report.notify('warn', server, warner, adminChannel, notifyString, false, warnee.primaryNick);
dbot.say(server, adminChannel, notifyString); dbot.say(server, adminChannel, notifyString);
var uString = dbot.t('warn_user', { var uString = dbot.t('warn_user', {
@ -38,6 +38,8 @@ var warning = function(dbot) {
dbot.say(server, warnee.currentNick, uString); dbot.say(server, warnee.currentNick, uString);
} }
dbot.api.event.emit('new_warning', [ warner, warnee, reason ]);
callback(null); callback(null);
}); });
} else { } else {