3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-06 11:28:43 +02:00

RelayUnreg: replace banned check with new is_banned(); check for +z; use AntiSpam::is_spam

This commit is contained in:
Pragmatic Software 2018-08-05 22:50:22 -07:00
parent 65644815e0
commit 82720e3da8

View File

@ -37,6 +37,10 @@ sub on_public {
# exit if channel hasn't muted $~a # exit if channel hasn't muted $~a
return 0 if not exists $self->{pbot}->{bantracker}->{banlist}->{$channel}->{'+q'}->{'$~a'}; return 0 if not exists $self->{pbot}->{bantracker}->{banlist}->{$channel}->{'+q'}->{'$~a'};
# exit if channel isn't +z
my $chanmodes = $self->{pbot}->{channels}->get_meta($channel, 'MODE');
return 0 if not defined $chanmodes or not $chanmodes =~ m/z/;
my $account = $self->{pbot}->{messagehistory}->{database}->get_message_account($nick, $user, $host); my $account = $self->{pbot}->{messagehistory}->{database}->get_message_account($nick, $user, $host);
my $nickserv = $self->{pbot}->{messagehistory}->{database}->get_current_nickserv_account($account); my $nickserv = $self->{pbot}->{messagehistory}->{database}->get_current_nickserv_account($account);
@ -61,6 +65,7 @@ sub on_public {
qr{eVestigator}, qr{eVestigator},
); );
# don't notify/relay for spammers
foreach my $filter (@filters) { foreach my $filter (@filters) {
if ($msg =~ m/$filter/i) { if ($msg =~ m/$filter/i) {
$self->{pbot}->{logger}->log("RelayUnreg: Ignoring filtered message.\n"); $self->{pbot}->{logger}->log("RelayUnreg: Ignoring filtered message.\n");
@ -68,6 +73,10 @@ sub on_public {
} }
} }
# don't notify/relay for spammers
return 0 if $self->{pbot}->{antispam}->is_spam($channel, $msg);
# don't notify/relay if user is voiced
return 0 if $self->{pbot}->{nicklist}->get_meta($channel, $nick, '+v'); return 0 if $self->{pbot}->{nicklist}->get_meta($channel, $nick, '+v');
$self->{pbot}->{logger}->log("RelayUnreg: Notifying $nick to register with NickServ in $channel.\n"); $self->{pbot}->{logger}->log("RelayUnreg: Notifying $nick to register with NickServ in $channel.\n");
@ -95,32 +104,9 @@ sub check_queue {
# if nick is still present in channel, send the message # if nick is still present in channel, send the message
if ($self->{pbot}->{nicklist}->is_present($channel, $nick)) { if ($self->{pbot}->{nicklist}->is_present($channel, $nick)) {
# ensure they're not banned (+z allows us to see +q/+b messages as normal ones) # ensure they're not banned (+z allows us to see +q/+b messages as normal ones)
my $message_account = $self->{pbot}->{messagehistory}->{database}->get_message_account($nick, $user, $host); my $banned = $self->{pbot}->{bantracker}->is_banned($nick, $user, $host, $channel);
my @nickserv_accounts = $self->{pbot}->{messagehistory}->{database}->get_nickserv_accounts($message_account); $self->{pbot}->{logger}->log("[RelayUnreg] $nick!$user\@$host $banned->{mode} as $banned->{banmask} in $banned->{channel} by $banned->{owner}, not relaying unregistered message\n") if $banned;
push @nickserv_accounts, undef; $self->{pbot}->{conn}->privmsg($channel, "(unreg) <$nick> $msg") unless $banned;
my $no_relay = 0;
foreach my $nickserv_account (@nickserv_accounts) {
my $baninfos = $self->{pbot}->{bantracker}->get_baninfo("$nick!$user\@$host", $channel, $nickserv_account);
if(defined $baninfos) {
foreach my $baninfo (@$baninfos) {
if($self->{pbot}->{antiflood}->whitelisted($baninfo->{channel}, $baninfo->{banmask}, 'ban') || $self->{pbot}->{antiflood}->whitelisted($baninfo->{channel}, "$nick!$user\@$host", 'user')) {
$self->{pbot}->{logger}->log("[RelayUnreg] $nick!$user\@$host banned as $baninfo->{banmask} in $baninfo->{channel}, but allowed through whitelist\n");
} else {
if($channel eq lc $baninfo->{channel}) {
my $mode = $baninfo->{type} eq "+b" ? "banned" : "quieted";
$self->{pbot}->{logger}->log("[RelayUnreg] $nick!$user\@$host $mode as $baninfo->{banmask} in $baninfo->{channel} by $baninfo->{owner}, not relaying unregistered message\n");
$no_relay = 1;
last;
}
}
}
}
}
$self->{pbot}->{conn}->privmsg($channel, "(unreg) <$nick> $msg") unless $no_relay;
} }
shift @{$self->{queue}}; shift @{$self->{queue}};
} }