Auto-kick people who change nicks to a nick matching $bad_away_nicks

This commit is contained in:
Pragmatic Software 2014-10-28 20:35:33 +00:00
parent c979efcfa6
commit 5a63fbd705
2 changed files with 15 additions and 1 deletions

View File

@ -73,6 +73,8 @@ sub initialize {
$self->{pbot}->{registry}->add_default('text', 'antiflood', 'debug_checkban', $conf{debug_checkban} // 0);
$self->{pbot}->{registry}->add_default('text', 'antiflood', 'bad_away_nicks', $conf{bad_away_nicks} // '[[:punct:]](afk|away|sleep|z+|work|gone)[[:punct:]]*$');
$self->{pbot}->{commands}->register(sub { return $self->unbanme(@_) }, "unbanme", 0);
$self->{pbot}->{commands}->register(sub { return $self->whitelist(@_) }, "whitelist", 10);
}
@ -196,6 +198,18 @@ sub check_flood {
$self->{nickflood}->{$account}->{changes}++;
}
my $bad_away_nicks = $self->{pbot}->{registry}->get_value('antiflood', 'bad_away_nicks');
if($newnick =~ m/$bad_away_nicks/i) {
$self->{pbot}->{logger}->log("$newnick matches bad away nick regex, kicking...\n");
my @channels = $self->{pbot}->{messagehistory}->{database}->get_channels($account);
foreach my $chan (@channels) {
if($chan =~ m/^#/) {
$self->{pbot}->{chanops}->add_op_command($chan, "kick $chan $newnick No away nicks: http://sackheads.org/~bnaylor/spew/away_msgs.html");
$self->{pbot}->{chanops}->gain_ops($chan);
}
}
}
} else {
$self->{pbot}->{logger}->log(sprintf("%-18s | %-65s | %s\n", lc $channel eq lc $mask ? "QUIT" : $channel, $mask, $text));
}

View File

@ -13,7 +13,7 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 796,
BUILD_REVISION => 797,
BUILD_DATE => "2014-10-28",
};