3
0
mirror of https://github.com/reality/dbot.git synced 2025-01-23 18:44:14 +01:00

nban records a host record [#497][#495]

This commit is contained in:
reality 2013-06-09 21:07:17 +00:00
parent 9226da5b76
commit 2b7b67b894
3 changed files with 54 additions and 46 deletions

View File

@ -48,58 +48,65 @@ var commands = function(dbot) {
adminChannel = this.config.admin_channel[event.server]; adminChannel = this.config.admin_channel[event.server];
channels = dbot.config.servers[server].channels; channels = dbot.config.servers[server].channels;
var notifyString = dbot.t('nbanned', { dbot.api.nickserv.getUserHost(event.server, banee, function(host) {
'banner': banner, // Add host record entry
'banee': banee, if(!_.has(this.hosts, event.server)) this.hosts[event.server] = {};
'reason': reason this.hosts[event.server][banee] = host;
});
// TODO: When this is merged into database branch, have it use the // Create notify string
// api.quotes.addQuote function var notifyString = dbot.t('nbanned', {
if(this.config.document_bans && _.has(dbot.modules, 'quotes')) {
dbot.db.quoteArrs['ban_' + banee.toLowerCase()] = [ dbot.t('nban_quote', {
'banee': banee,
'banner': banner, 'banner': banner,
'time': new Date().toUTCString(), 'banee': banee,
'reason': reason 'reason': reason
}) ]; });
notifyString += ' ' + dbot.t('quote_recorded', { 'user': banee });
}
// Notify moderators, banee // TODO: When this is merged into database branch, have it use the
if(this.config.admin_channel[event.server]) { // api.quotes.addQuote function
channels = _.without(channels, adminChannel); if(this.config.document_bans && _.has(dbot.modules, 'quotes')) {
dbot.db.quoteArrs['ban_' + banee.toLowerCase()] = [ dbot.t('nban_quote', {
dbot.api.report.notify(server, adminChannel, notifyString); 'banee': banee,
dbot.say(event.server, adminChannel, notifyString); 'banner': banner,
'time': new Date().toUTCString(),
var network = event.server; 'reason': reason
if(this.config.network_name[event.server]) { }) ];
network = this.config.network_name[event.server];
notifyString += ' ' + dbot.t('quote_recorded', { 'user': banee });
} }
dbot.say(event.server, banee, dbot.t('nbanned_notify', { // Notify moderators, banee
'network': network, if(this.config.admin_channel[event.server]) {
'banner': banner, channels = _.without(channels, adminChannel);
'reason': reason,
'admin_channel': adminChannel
}));
}
// Ban the user from all channels dbot.api.report.notify(server, adminChannel, notifyString);
var i = 0; dbot.say(event.server, adminChannel, notifyString);
var banChannel = function(channels) {
if(i >= channels.length) return; var network = event.server;
var channel = channels[i]; if(this.config.network_name[event.server]) {
this.api.ban(server, banee, channel); network = this.config.network_name[event.server];
this.api.kick(server, banee, channel, reason + }
' (network-wide ban requested by ' + banner + ')');
setTimeout(function() { dbot.say(event.server, banee, dbot.t('nbanned_notify', {
i++; banChannel(channels); 'network': network,
}, 1000); 'banner': banner,
}.bind(this); 'reason': reason,
banChannel(channels); 'admin_channel': adminChannel
}));
}
// 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, banee, channel);
this.api.kick(server, banee, channel, reason +
' (network-wide ban requested by ' + banner + ')');
setTimeout(function() {
i++; banChannel(channels);
}, 1000);
}.bind(this);
banChannel(channels);
}.bind(this));
}, },
/*** Kick Stats ***/ /*** Kick Stats ***/

View File

@ -1,5 +1,5 @@
{ {
"dbKeys": [ "kicks", "kickers" ], "dbKeys": [ "kicks", "kickers", "hosts" ],
"dependencies": [ "command", "report", "users" ], "dependencies": [ "command", "report", "users" ],
"help": "http://github.com/reality/depressionbot/blob/master/modules/kick/README.md", "help": "http://github.com/reality/depressionbot/blob/master/modules/kick/README.md",
"ignorable": true, "ignorable": true,

View File

@ -1,6 +1,7 @@
var _ = require('underscore')._; var _ = require('underscore')._;
var kick = function(dbot) { var kick = function(dbot) {
this.hosts = dbot.db.hosts;
this.api = { this.api = {
'ban': function(server, user, channel) { 'ban': function(server, user, channel) {