forked from GitHub/dbot
various fixes to the reporting system and related stuff
This commit is contained in:
parent
ac9488bad9
commit
c10b65ef3b
@ -7,7 +7,7 @@ var commands = function(dbot) {
|
||||
'~quiet': function(event) {
|
||||
var server = event.server,
|
||||
quieter = event.user,
|
||||
duration = event.input[1].trim(),
|
||||
duration = event.input[1],
|
||||
channel = (event.input[2] || event.channel.name).trim(),
|
||||
quietee = event.input[3].trim(),
|
||||
reason = event.input[4] || "N/A";
|
||||
@ -17,14 +17,15 @@ var commands = function(dbot) {
|
||||
if(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));
|
||||
if(_.has(dbot.modules, 'remind')) {
|
||||
msTimeout = dbot.api.remind.parseTime(duration);
|
||||
if(!msTimeout) {
|
||||
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 {
|
||||
duration += ' minutes';
|
||||
}
|
||||
@ -44,7 +45,7 @@ var commands = function(dbot) {
|
||||
dbot.t('unquiet_notify', {
|
||||
'unquieter': dbot.config.name,
|
||||
'quietee': quietee
|
||||
}));
|
||||
}), false, quietee);
|
||||
});
|
||||
}
|
||||
}.bind(this));
|
||||
@ -58,7 +59,7 @@ var commands = function(dbot) {
|
||||
'quieter': event.rUser.primaryNick,
|
||||
'quietee': quietee,
|
||||
'reason': reason
|
||||
})
|
||||
}), false, quietee
|
||||
);
|
||||
} else {
|
||||
event.reply(dbot.t('quieted', { 'quietee': quietee }));
|
||||
@ -67,7 +68,7 @@ var commands = function(dbot) {
|
||||
'quieter': quieter,
|
||||
'quietee': quietee,
|
||||
'reason': reason
|
||||
}));
|
||||
}), false, quietee);
|
||||
}
|
||||
|
||||
this.api.devoice(server, quietee, channel);
|
||||
@ -106,7 +107,7 @@ var commands = function(dbot) {
|
||||
dbot.t('unquiet_notify', {
|
||||
'unquieter': quieter,
|
||||
'quietee': quietee
|
||||
}));
|
||||
}), false, quietee);
|
||||
}
|
||||
},
|
||||
|
||||
@ -128,7 +129,7 @@ var commands = function(dbot) {
|
||||
'kicker': kicker,
|
||||
'kickee': kickee,
|
||||
'reason': reason
|
||||
}));
|
||||
}), false, kickee);
|
||||
},
|
||||
|
||||
// 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) {
|
||||
// Add host record entry
|
||||
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
|
||||
this.api.ban(server, host, event.channel);
|
||||
this.api.kick(server, banee, event.channel, reason +
|
||||
' (network-wide ban requested by ' + banner + ')');
|
||||
' (network-wide ban)');
|
||||
channels = _.without(channels, event.channel);
|
||||
if(!_.isUndefined(adminChannel)) {
|
||||
channels = _.without(channels, adminChannel);
|
||||
} else {
|
||||
adminChannel = event.channel.name;
|
||||
}
|
||||
|
||||
// Ban the user from all channels
|
||||
var i = 0;
|
||||
@ -164,7 +178,7 @@ var commands = function(dbot) {
|
||||
var channel = channels[i];
|
||||
this.api.ban(server, host, channel);
|
||||
this.api.kick(server, banee, channel, reason +
|
||||
' (network-wide ban requested by ' + banner + ')');
|
||||
' (network-wide ban)');
|
||||
i++; banChannel(channels);
|
||||
}.bind(this);
|
||||
banChannel(channels);
|
||||
@ -181,7 +195,7 @@ var commands = function(dbot) {
|
||||
if(!msTimeout) {
|
||||
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 {
|
||||
timeout += ' hours';
|
||||
}
|
||||
@ -228,7 +242,7 @@ var commands = function(dbot) {
|
||||
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);
|
||||
|
||||
if(!_.isUndefined(timeout)) {
|
||||
@ -326,10 +340,12 @@ var commands = function(dbot) {
|
||||
commands['~kickstats'].access = 'regular';
|
||||
commands['~quiet'].access = 'voice';
|
||||
commands['~unquiet'].access = 'voice';
|
||||
commands['~nban'].access = 'power_user';
|
||||
commands['~nunban'].access = 'power_user';
|
||||
|
||||
commands['~ckick'].regex = /^ckick (#[^ ]+ )?([^ ]+) ?(.*)?$/;
|
||||
commands['~nban'].regex = /^nban ([\d\.dhms^ ]+)?([^ ]+) (.+)$/;
|
||||
commands['~quiet'].regex = /^quiet ([\d\.dhms^ ]+)?(#[^ ]+ )?([^ ]+) ?(.*)?$/;
|
||||
commands['~nban'].regex = /^nban (\d[\d\.dhms^ ]+)?([^ ]+) (.+)$/;
|
||||
commands['~quiet'].regex = /^quiet (\d[\d\.hms^ ]+)?(#[^ ]+ )?([^ ]+) ?(.*)?$/;
|
||||
commands['~unquiet'].regex = /^unquiet (#[^ ]+ )?([^ ]+) ?$/;
|
||||
|
||||
return commands;
|
||||
|
@ -50,7 +50,7 @@ var kick = function(dbot) {
|
||||
'unbanee': unbanee,
|
||||
'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);
|
||||
|
||||
// Notify Unbanee
|
||||
|
@ -89,6 +89,9 @@ var commands = function(dbot) {
|
||||
|
||||
'~sustatus': function(event) {
|
||||
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) {
|
||||
if(user) {
|
||||
@ -106,11 +109,32 @@ var commands = function(dbot) {
|
||||
dbot.modules.report.db.search('notifies', {
|
||||
'server': event.server
|
||||
}, 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 ||
|
||||
notify.message.indexOf(' ' + alias + ' has been unbanned') != -1 ||
|
||||
notify.message.indexOf('issued a warning to ' + alias + ' ') != -1 ||
|
||||
notify.message.indexOf('has quieted ' + alias + ' ') != -1 ||
|
||||
notify.message.indexOf('issued a warning to ' + alias) != -1 ||
|
||||
notify.message.indexOf('has quieted ' + alias) != -1 ||
|
||||
notify.message.indexOf('has reported ' + alias + ' ') != -1) {
|
||||
if(notify.type == 'ban') {
|
||||
ban++;
|
||||
@ -132,6 +156,7 @@ var commands = function(dbot) {
|
||||
items[notify.time] = notify.message;
|
||||
}
|
||||
});
|
||||
*/
|
||||
}, function() {
|
||||
if(quiet != 0 || warn != 0 || report != 0) {
|
||||
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);
|
||||
});
|
||||
|
||||
if(sTimes.length < 50) {
|
||||
if(sTimes.length < 70) {
|
||||
_.each(sTimes, function(time) {
|
||||
event.reply('[' + moment(parseInt(time)).format('DD/MM/YYYY') + '] ' + items[time]);
|
||||
});
|
||||
@ -198,9 +223,10 @@ var commands = function(dbot) {
|
||||
}, function() {
|
||||
if(ban) {
|
||||
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.');
|
||||
} else {
|
||||
} else if(!ban) {
|
||||
event.reply(user.primaryNick + ' has no record.');
|
||||
}
|
||||
});
|
||||
@ -240,7 +266,7 @@ var commands = function(dbot) {
|
||||
'reporter': event.rUser.primaryNick,
|
||||
'reportee': nick,
|
||||
'reason': reason
|
||||
}));
|
||||
}), false, nick);
|
||||
event.reply(dbot.t('reported', { 'reported': nick }));
|
||||
} else {
|
||||
event.reply(dbot.t('user_not_found', {
|
||||
@ -333,33 +359,6 @@ var commands = function(dbot) {
|
||||
} else {
|
||||
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 (#[^ ]+ )?([^ ]+) (.*)$/;
|
||||
|
@ -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)) {
|
||||
dbot.say(event.server, event.user, dbot.t('missed_notifies', {
|
||||
'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;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ var warning = function(dbot) {
|
||||
+ 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);
|
||||
|
||||
var uString = dbot.t('warn_user', {
|
||||
@ -38,6 +38,8 @@ var warning = function(dbot) {
|
||||
dbot.say(server, warnee.currentNick, uString);
|
||||
}
|
||||
|
||||
dbot.api.event.emit('new_warning', [ warner, warnee, reason ]);
|
||||
|
||||
callback(null);
|
||||
});
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user