~nban no longer adds redundant +b if user was killed

This commit is contained in:
Scritches 2018-05-05 13:45:54 -04:00
parent ed69582c7a
commit f3dcc0e693

View File

@ -121,7 +121,10 @@ 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) {
var didKill = false;
if ((reason.match('#line') || reason.match('#specialk') || reason.match('#kline')) && _.include(dbot.access.moderator(), event.rUser.primaryNick)) { if ((reason.match('#line') || reason.match('#specialk') || reason.match('#kline')) && _.include(dbot.access.moderator(), event.rUser.primaryNick)) {
didKill = true;
var t = ' !P '; var t = ' !P ';
if (timeout) { if (timeout) {
t = ' !T ' + (timeout * 60); t = ' !T ' + (timeout * 60);
@ -129,31 +132,34 @@ var commands = function (dbot) {
dbot.say(event.server, 'operserv', 'akill add ' + banee + t + banee + ' banned by ' + banner + ': ' + reason); dbot.say(event.server, 'operserv', 'akill add ' + banee + t + banee + ' banned by ' + banner + ': ' + reason);
} }
// Ban from current channel first // Do not ban if user was killed - redundant
this.api.ban(server, host, event.channel); if(!didKill) {
this.api.kick(server, banee, event.channel, reason + // Ban from current channel first
' (network-wide ban)'); this.api.ban(server, host, event.channel);
channels = _.without(channels, event.channel); this.api.kick(server, banee, event.channel, reason +
if (!_.isUndefined(adminChannel)) {
channels = _.without(channels, adminChannel);
} else {
adminChannel = event.channel.name;
}
// Ban the user from all channels
var i = 0;
var banChannel = function (channels) {
if (i >= channels.length)
return;
var channel = channels[i];
this.api.ban(server, host, channel);
this.api.kick(server, banee, channel, reason +
' (network-wide ban)'); ' (network-wide ban)');
i++; 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;
var banChannel = function (channels) {
if (i >= channels.length)
return;
var channel = channels[i];
this.api.ban(server, host, channel);
this.api.kick(server, banee, channel, reason +
' (network-wide ban)');
i++;
banChannel(channels);
}
.bind(this);
banChannel(channels); banChannel(channels);
} }
.bind(this);
banChannel(channels);
this.hosts[event.server][banee] = host; this.hosts[event.server][banee] = host;
@ -172,10 +178,13 @@ var commands = function (dbot) {
timeout += ' hours'; timeout += ' hours';
} }
if (!_.has(this.tempBans, event.server)) // Do not schedule unbans if the user was killed as no ban was put in place
this.tempBans[event.server] = {}; if(!didKill) {
this.tempBans[event.server][banee] = msTimeout; if (!_.has(this.tempBans, event.server))
this.internalAPI.addTempBan(event.server, banee, msTimeout); this.tempBans[event.server] = {};
this.tempBans[event.server][banee] = msTimeout;
this.internalAPI.addTempBan(event.server, banee, msTimeout);
}
var notifyString = dbot.t('tbanned', { var notifyString = dbot.t('tbanned', {
'network': network, 'network': network,