forked from GitHub/dbot
Merge pull request #677 from Scritches/master
'kick' and 'kill_namespam' module changes
This commit is contained in:
commit
ab6cb80ea2
@ -39,7 +39,8 @@ var commands = function(dbot) {
|
||||
if (this.recentTimeouts[user.id] == 0) {
|
||||
delete this.recentTimeouts[user.id];
|
||||
}
|
||||
}.bind(this), 3600000);
|
||||
}
|
||||
.bind(this), 3600000);
|
||||
|
||||
if (this.recentTimeouts[user.id] == 3) {
|
||||
duration = null;
|
||||
@ -51,7 +52,8 @@ var commands = function(dbot) {
|
||||
event.reply(response);
|
||||
});
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
.bind(this));
|
||||
},
|
||||
|
||||
'~unquiet': function (event) {
|
||||
@ -66,7 +68,9 @@ var commands = function(dbot) {
|
||||
} else {
|
||||
this.api.unquiet(server, this.hosts[server][quietee], channel);
|
||||
}
|
||||
event.reply(dbot.t('unquieted', { 'quietee': quietee }));
|
||||
event.reply(dbot.t('unquieted', {
|
||||
'quietee': quietee
|
||||
}));
|
||||
dbot.api.report.notify('unquiet', server, event.rUser, channel,
|
||||
dbot.t('unquiet_notify', {
|
||||
'unquieter': quieter,
|
||||
@ -98,7 +102,8 @@ var commands = function(dbot) {
|
||||
|
||||
// Kick and ban from all channels on the network.
|
||||
'~nban': function (event) {
|
||||
if(!event.input) return;
|
||||
if (!event.input)
|
||||
return;
|
||||
|
||||
var server = event.server,
|
||||
banner = event.user,
|
||||
@ -116,7 +121,10 @@ var commands = function(dbot) {
|
||||
dbot.api.nickserv.getUserHost(event.server, banee, function (host) {
|
||||
// Add host record entry
|
||||
if (host) {
|
||||
var didKill = false;
|
||||
|
||||
if ((reason.match('#line') || reason.match('#specialk') || reason.match('#kline')) && _.include(dbot.access.moderator(), event.rUser.primaryNick)) {
|
||||
didKill = true;
|
||||
var t = ' !P ';
|
||||
if (timeout) {
|
||||
t = ' !T ' + (timeout * 60);
|
||||
@ -124,6 +132,8 @@ var commands = function(dbot) {
|
||||
dbot.say(event.server, 'operserv', 'akill add ' + banee + t + banee + ' banned by ' + banner + ': ' + reason);
|
||||
}
|
||||
|
||||
// Do not ban if user was killed - redundant
|
||||
if(!didKill) {
|
||||
// Ban from current channel first
|
||||
this.api.ban(server, host, event.channel);
|
||||
this.api.kick(server, banee, event.channel, reason +
|
||||
@ -138,14 +148,18 @@ var commands = function(dbot) {
|
||||
// Ban the user from all channels
|
||||
var i = 0;
|
||||
var banChannel = function (channels) {
|
||||
if(i >= channels.length) return;
|
||||
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);
|
||||
i++;
|
||||
banChannel(channels);
|
||||
}
|
||||
.bind(this);
|
||||
banChannel(channels);
|
||||
}
|
||||
|
||||
this.hosts[event.server][banee] = host;
|
||||
|
||||
@ -164,9 +178,13 @@ var commands = function(dbot) {
|
||||
timeout += ' hours';
|
||||
}
|
||||
|
||||
if(!_.has(this.tempBans, event.server)) this.tempBans[event.server] = {};
|
||||
// Do not schedule unbans if the user was killed as no ban was put in place
|
||||
if(!didKill) {
|
||||
if (!_.has(this.tempBans, event.server))
|
||||
this.tempBans[event.server] = {};
|
||||
this.tempBans[event.server][banee] = msTimeout;
|
||||
this.internalAPI.addTempBan(event.server, banee, msTimeout);
|
||||
}
|
||||
|
||||
var notifyString = dbot.t('tbanned', {
|
||||
'network': network,
|
||||
@ -232,9 +250,12 @@ var commands = function(dbot) {
|
||||
// err
|
||||
dbot.say(event.server, 'NickServ', 'FREEZE ' + banee + ' ON ' + reason);
|
||||
} else {
|
||||
event.reply(dbot.t('no_user', { 'user': banee }));
|
||||
event.reply(dbot.t('no_user', {
|
||||
'user': banee
|
||||
}));
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
.bind(this));
|
||||
},
|
||||
|
||||
'~nunban': function (event) {
|
||||
@ -244,7 +265,9 @@ var commands = function(dbot) {
|
||||
|
||||
this.api.networkUnban(event.server, unbanee, unbanner, host, function (err) {
|
||||
if (err) {
|
||||
event.reply(dbot.t('nunban_error', { 'unbanee': unbanee }));
|
||||
event.reply(dbot.t('nunban_error', {
|
||||
'unbanee': unbanee
|
||||
}));
|
||||
}
|
||||
});
|
||||
},
|
||||
@ -281,7 +304,9 @@ var commands = function(dbot) {
|
||||
var orderedKickLeague = function (list, topWhat) {
|
||||
var kickArr = _.chain(list)
|
||||
.pairs()
|
||||
.sortBy(function(kick) { return kick[1] })
|
||||
.sortBy(function (kick) {
|
||||
return kick[1]
|
||||
})
|
||||
.reverse()
|
||||
.first(10)
|
||||
.value();
|
||||
@ -310,7 +335,13 @@ var commands = function(dbot) {
|
||||
}
|
||||
|
||||
if (!_.has(this.voteQuiets, user.id)) {
|
||||
this.voteQuiets[user.id] = { 'user': user.id, 'reason': reason, 'channel': event.channel, 'yes': [event.rUser.primaryNick], 'no': [] };
|
||||
this.voteQuiets[user.id] = {
|
||||
'user': user.id,
|
||||
'reason': reason,
|
||||
'channel': event.channel,
|
||||
'yes': [event.rUser.primaryNick],
|
||||
'no': []
|
||||
};
|
||||
event.reply(event.user + ' has started a vote to quiet ' + target + ' for "' + reason + '." Type either "~voteyes ' + target + '" or "~voteno ' + target + '" in the next 90 seconds.');
|
||||
|
||||
this.voteQuiets[user.id].timer = setTimeout(function () {
|
||||
@ -337,8 +368,10 @@ var commands = function(dbot) {
|
||||
|
||||
setTimeout(function () {
|
||||
delete this.voteQuiets[user.id];
|
||||
}.bind(this), 600000);
|
||||
}.bind(this), 90000);
|
||||
}
|
||||
.bind(this), 600000);
|
||||
}
|
||||
.bind(this), 90000);
|
||||
} else {
|
||||
if (this.voteQuiets[user.id].spent) {
|
||||
event.reply('A votequiet attempt has already been made on this user in the last 10 minutes.');
|
||||
@ -357,7 +390,8 @@ var commands = function(dbot) {
|
||||
vq.spent = true;
|
||||
setTimeout(function () {
|
||||
delete this.voteQuiets[user.id];
|
||||
}.bind(this), 600000);
|
||||
}
|
||||
.bind(this), 600000);
|
||||
event.reply(response);
|
||||
});
|
||||
}
|
||||
@ -369,7 +403,8 @@ var commands = function(dbot) {
|
||||
} else {
|
||||
event.reply('Target does not seem to be in the channel.');
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
.bind(this));
|
||||
} else {
|
||||
event.reply('Target does not seem to be in the channel.');
|
||||
}
|
||||
@ -399,7 +434,8 @@ var commands = function(dbot) {
|
||||
vq.spent = true;
|
||||
setTimeout(function () {
|
||||
delete this.voteQuiets[user.id];
|
||||
}.bind(this), 600000);
|
||||
}
|
||||
.bind(this), 600000);
|
||||
event.reply(response);
|
||||
});
|
||||
}
|
||||
@ -412,7 +448,8 @@ var commands = function(dbot) {
|
||||
} else {
|
||||
event.reply('No idea who that is m8');
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
.bind(this));
|
||||
},
|
||||
|
||||
'~voteno': function (event) {
|
||||
@ -440,7 +477,8 @@ var commands = function(dbot) {
|
||||
} else {
|
||||
event.reply('No idea who that is m8');
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -78,7 +78,8 @@ var kick = function(dbot) {
|
||||
}), false, quietee);
|
||||
});
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
.bind(this));
|
||||
callback(dbot.t('tquieted', {
|
||||
'quietee': quietee,
|
||||
'minutes': duration
|
||||
@ -89,10 +90,11 @@ var kick = function(dbot) {
|
||||
'quieter': quieter.primaryNick,
|
||||
'quietee': quietee,
|
||||
'reason': reason
|
||||
}), false, quietee
|
||||
);
|
||||
}), false, quietee);
|
||||
} else {
|
||||
callback(dbot.t('quieted', { 'quietee': quietee }));
|
||||
callback(dbot.t('quieted', {
|
||||
'quietee': quietee
|
||||
}));
|
||||
dbot.api.report.notify('quiet', server, quieter.primaryNick, channel,
|
||||
dbot.t('quiet_notify', {
|
||||
'quieter': quieter.primaryNick,
|
||||
@ -115,9 +117,12 @@ var kick = function(dbot) {
|
||||
function () {});
|
||||
}
|
||||
} else {
|
||||
event.reply(dbot.t('no_user', { 'user': quietee }));
|
||||
event.reply(dbot.t('no_user', {
|
||||
'user': quietee
|
||||
}));
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
.bind(this));
|
||||
},
|
||||
|
||||
'networkUnban': function (server, unbanee, unbanner, manualHost, callback) {
|
||||
@ -156,13 +161,16 @@ var kick = function(dbot) {
|
||||
// Unban
|
||||
var i = 0;
|
||||
var unbanChannel = function (channels) {
|
||||
if(i >= channels.length) return;
|
||||
if (i >= channels.length)
|
||||
return;
|
||||
var channel = channels[i];
|
||||
this.api.unban(server, host, channel);
|
||||
setTimeout(function () {
|
||||
i++; unbanChannel(channels);
|
||||
i++;
|
||||
unbanChannel(channels);
|
||||
}, 1000);
|
||||
}.bind(this);
|
||||
}
|
||||
.bind(this);
|
||||
unbanChannel(channels);
|
||||
|
||||
dbot.say(server, 'NickServ', 'FREEZE ' + unbanee + ' OFF');
|
||||
@ -171,13 +179,15 @@ var kick = function(dbot) {
|
||||
// Attempt to look up the host on-the-fly
|
||||
dbot.api.nickserv.getUserHost(server, unbanee, unbanner, function (host) {
|
||||
if (host) {
|
||||
if(!_.has(this.hosts, server)) this.hosts[server] = {};
|
||||
if (!_.has(this.hosts, server))
|
||||
this.hosts[server] = {};
|
||||
this.hosts[server][unbanee] = host;
|
||||
this.api.networkUnban(server, unbanee, unbanner);
|
||||
} else {
|
||||
callback(true); // No host could be found
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
.bind(this));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -188,15 +198,20 @@ var kick = function(dbot) {
|
||||
dbot.api.timers.addTimeout(timeout, function () {
|
||||
this.api.networkUnban(server, banee, bot, undefined, function (err) {});
|
||||
delete this.tempBans[server][banee];
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
}.bind(this)
|
||||
}
|
||||
.bind(this));
|
||||
}
|
||||
.bind(this));
|
||||
}
|
||||
.bind(this)
|
||||
};
|
||||
|
||||
this.listener = function (event) {
|
||||
if (event.kickee == dbot.config.name) {
|
||||
dbot.instance.join(event, event.channel.name);
|
||||
event.reply(dbot.t('kicked_dbot', { 'botname': dbot.config.name }));
|
||||
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)) {
|
||||
@ -219,7 +234,8 @@ var kick = function(dbot) {
|
||||
}) + ')');
|
||||
}
|
||||
}
|
||||
}.bind(this);
|
||||
}
|
||||
.bind(this);
|
||||
this.on = 'KICK';
|
||||
|
||||
this.onLoad = function () {
|
||||
@ -229,7 +245,8 @@ var kick = function(dbot) {
|
||||
dbot.db.hosts[k] = {};
|
||||
}, this);
|
||||
}
|
||||
if(!_.has(dbot.db, 'tempBans')) dbot.db.tempBans = {};
|
||||
if (!_.has(dbot.db, 'tempBans'))
|
||||
dbot.db.tempBans = {};
|
||||
this.hosts = dbot.db.hosts;
|
||||
this.tempBans = dbot.db.tempBans;
|
||||
this.voteQuiets = {};
|
||||
@ -244,7 +261,8 @@ var kick = function(dbot) {
|
||||
if (_.has(dbot.modules, 'web')) {
|
||||
dbot.api.web.addIndexLink('/bans', 'Ban List');
|
||||
}
|
||||
}.bind(this);
|
||||
}
|
||||
.bind(this);
|
||||
};
|
||||
|
||||
exports.fetch = function (dbot) {
|
||||
|
@ -9,7 +9,9 @@ var pages = function(dbot) {
|
||||
},
|
||||
|
||||
'/underbans': function (req, res) {
|
||||
this.db.search('nbans', { 'server': server }, function(ban) {
|
||||
this.db.search('nbans', {
|
||||
'server': server
|
||||
}, function (ban) {
|
||||
if (ban.reason.match('#underban')) {
|
||||
bans.push(ban);
|
||||
}
|
||||
@ -25,7 +27,9 @@ var pages = function(dbot) {
|
||||
var server = req.params.server,
|
||||
bans = [];
|
||||
|
||||
this.db.search('nbans', { 'server': server }, function(ban) {
|
||||
this.db.search('nbans', {
|
||||
'server': server
|
||||
}, function (ban) {
|
||||
bans.push(ban);
|
||||
}, function () {
|
||||
res.render('bans', {
|
||||
|
@ -6,5 +6,6 @@
|
||||
"________ ______"
|
||||
],
|
||||
"cliconn_channel": "#dnsbl",
|
||||
"cliconn_patterns": []
|
||||
"cliconn_patterns": [],
|
||||
"exempt_channels": []
|
||||
}
|
||||
|
@ -12,7 +12,10 @@ var kill_namespam = function(dbot) {
|
||||
dbot.modules.admin.internalAPI.saveConfig();
|
||||
}.bind(this);
|
||||
|
||||
this.matchedKill = {};
|
||||
|
||||
this.listener = function(event) {
|
||||
if(event.action == 'PRIVMSG') {
|
||||
// Here we listen for atropos
|
||||
if(event.channel == this.config.cliconn_channel) {
|
||||
if(event.message.match('▶')) {
|
||||
@ -28,18 +31,15 @@ var kill_namespam = function(dbot) {
|
||||
'pattern': matchedPattern
|
||||
}));
|
||||
} else {
|
||||
var ip = event.message.split(' ')[1]
|
||||
|
||||
// Alternatively you can just do dbot.api.kick.kill(event.server, event.user, message);
|
||||
dbot.say(event.server, 'operserv', 'akill add *@'+ ip +' !P Naughty Nelly Auto-kill v6.2. Matched pattern: /'+ matchedPattern +'/');
|
||||
|
||||
var msg = dbot.t('clikill_act', {
|
||||
'ip': ip,
|
||||
'pattern': matchedPattern
|
||||
});
|
||||
event.reply(msg);
|
||||
dbot.api.report.notify('autokill', event.server, event.rUser,
|
||||
dbot.config.servers[event.server].admin_channel, msg, ip, ip);
|
||||
if(!this.matchedKill[host]) {
|
||||
// Defer killing this connection until after they join a non-exempted channel
|
||||
this.matchedKill[host] = {
|
||||
ip: event.message.split(' ')[1],
|
||||
server: event.server,
|
||||
matchedPattern: matchedPattern,
|
||||
rUser: event.rUser
|
||||
};
|
||||
}
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
@ -87,8 +87,31 @@ var kill_namespam = function(dbot) {
|
||||
|
||||
dbot.api.report.notify('spam', event.server, event.user, event.channel, message, event.host, event.user);
|
||||
}
|
||||
} else if (event.action == 'JOIN') {
|
||||
|
||||
if(this.matchedKill[event.host]) {
|
||||
if(this.config.exempt_channels.indexOf(event.channel) == -1) {
|
||||
var kill = this.matchedKill[event.host];
|
||||
delete this.matchedKill[event.host];
|
||||
|
||||
// Alternatively you can just do dbot.api.kick.kill(event.server, event.user, message);
|
||||
dbot.say(event.server, 'operserv', 'akill add *@'+ kill.ip +' !P Naughty Nelly Auto-kill v6.2. Matched pattern: /'+ kill.matchedPattern +'/');
|
||||
|
||||
var msg = dbot.t('clikill_act', {
|
||||
'ip': kill.ip,
|
||||
'pattern': kill.matchedPattern
|
||||
});
|
||||
dbot.api.report.notify('autokill', kill.server, kill.rUser,
|
||||
dbot.config.servers[kill.server].admin_channel, msg, kill.ip, kill.ip);
|
||||
}
|
||||
}
|
||||
} else if (event.action == 'QUIT') {
|
||||
if(this.matchedKill[event.host]) {
|
||||
delete this.matchedKill[event.host];
|
||||
}
|
||||
}
|
||||
}.bind(this);
|
||||
this.on = 'PRIVMSG';
|
||||
this.on = ['PRIVMSG', 'JOIN', 'QUIT'];
|
||||
|
||||
this.commands = {
|
||||
'~add_spamkill': function(event) {
|
||||
|
Loading…
Reference in New Issue
Block a user