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:
parent
efdf70b9bb
commit
4c795c4d4f
@ -169,32 +169,35 @@ sub check_blacklist {
|
|||||||
|
|
||||||
return 0 if not defined $channel;
|
return 0 if not defined $channel;
|
||||||
|
|
||||||
foreach my $black_channel (keys %{$self->{blacklist}}) {
|
my $result = eval {
|
||||||
foreach my $black_hostmask (keys %{$self->{blacklist}->{$black_channel}}) {
|
foreach my $black_channel (keys %{$self->{blacklist}}) {
|
||||||
my $flag = '';
|
foreach my $black_hostmask (keys %{$self->{blacklist}->{$black_channel}}) {
|
||||||
$flag = $1 if $black_hostmask =~ s/^\$(.)://;
|
my $flag = '';
|
||||||
|
$flag = $1 if $black_hostmask =~ s/^\$(.)://;
|
||||||
|
|
||||||
my $black_channel_escaped = quotemeta $black_channel;
|
next if $channel !~ /^$black_channel$/i;
|
||||||
my $black_hostmask_escaped = quotemeta $black_hostmask;
|
|
||||||
|
|
||||||
$black_channel_escaped =~ s/\\(\.|\*)/$1/g;
|
if ($flag eq 'a' && defined $nickserv && $nickserv =~ /^$black_hostmask$/i) {
|
||||||
$black_hostmask_escaped =~ s/\\(\.|\*)/$1/g;
|
$self->{pbot}->{logger}->log("$hostmask nickserv $nickserv blacklisted in channel $channel (matches [\$a:$black_hostmask] host and [$black_channel] channel)\n");
|
||||||
|
return 1;
|
||||||
next if $channel !~ /^$black_channel_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");
|
||||||
if ($flag eq 'a' && defined $nickserv && $nickserv =~ /^$black_hostmask_escaped$/i) {
|
return 1;
|
||||||
$self->{pbot}->{logger}->log("$hostmask nickserv $nickserv blacklisted in channel $channel (matches [\$a:$black_hostmask] host and [$black_channel] channel)\n");
|
} elsif ($flag eq '' && $hostmask =~ /^$black_hostmask$/i) {
|
||||||
return 1;
|
$self->{pbot}->{logger}->log("$hostmask blacklisted in channel $channel (matches [$black_hostmask] host and [$black_channel] channel)\n");
|
||||||
} elsif ($flag eq 'r' && defined $gecos && $gecos =~ /^$black_hostmask_escaped$/i) {
|
return 1;
|
||||||
$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) {
|
|
||||||
$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 0;
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user