diff --git a/PBot/AntiFlood.pm b/PBot/AntiFlood.pm index 3fda4e9d..a7c17eb3 100644 --- a/PBot/AntiFlood.pm +++ b/PBot/AntiFlood.pm @@ -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)); } diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index 6682d51c..2867f7b8 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -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", };