3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-23 04:19:27 +01:00

BlackList: hostmask parameter is now full regex

This commit is contained in:
Pragmatic Software 2020-06-18 10:03:20 -07:00
parent efdf70b9bb
commit 4c795c4d4f

View File

@ -169,32 +169,35 @@ sub check_blacklist {
return 0 if not defined $channel;
my $result = eval {
foreach my $black_channel (keys %{$self->{blacklist}}) {
foreach my $black_hostmask (keys %{$self->{blacklist}->{$black_channel}}) {
my $flag = '';
$flag = $1 if $black_hostmask =~ s/^\$(.)://;
my $black_channel_escaped = quotemeta $black_channel;
my $black_hostmask_escaped = quotemeta $black_hostmask;
next if $channel !~ /^$black_channel$/i;
$black_channel_escaped =~ s/\\(\.|\*)/$1/g;
$black_hostmask_escaped =~ s/\\(\.|\*)/$1/g;
next if $channel !~ /^$black_channel_escaped$/i;
if ($flag eq 'a' && defined $nickserv && $nickserv =~ /^$black_hostmask_escaped$/i) {
if ($flag eq 'a' && defined $nickserv && $nickserv =~ /^$black_hostmask$/i) {
$self->{pbot}->{logger}->log("$hostmask nickserv $nickserv blacklisted in channel $channel (matches [\$a:$black_hostmask] host and [$black_channel] channel)\n");
return 1;
} elsif ($flag eq 'r' && defined $gecos && $gecos =~ /^$black_hostmask_escaped$/i) {
} elsif ($flag eq 'r' && defined $gecos && $gecos =~ /^$black_hostmask$/i) {
$self->{pbot}->{logger}->log("$hostmask GECOS $gecos blacklisted in channel $channel (matches [\$r:$black_hostmask] host and [$black_channel] channel)\n");
return 1;
} elsif ($flag eq '' && $hostmask =~ /^$black_hostmask_escaped$/i) {
} elsif ($flag eq '' && $hostmask =~ /^$black_hostmask$/i) {
$self->{pbot}->{logger}->log("$hostmask blacklisted in channel $channel (matches [$black_hostmask] host and [$black_channel] channel)\n");
return 1;
}
}
}
return 0;
};
if ($@) {
$self->{pbot}->{logger}->log("Error in blacklist: $@\n");
return 0;
}
return $result;
}
1;