mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-29 23:39:24 +01:00
Admins: find_admin now returns highest level admin
This commit is contained in:
parent
496a07ab9a
commit
75c17b2ec0
@ -145,6 +145,7 @@ sub find_admin {
|
|||||||
$hostmask = lc $hostmask;
|
$hostmask = lc $hostmask;
|
||||||
|
|
||||||
my $result = eval {
|
my $result = eval {
|
||||||
|
my $admin;
|
||||||
foreach my $channel_regex (keys %{ $self->{admins}->{hash} }) {
|
foreach my $channel_regex (keys %{ $self->{admins}->{hash} }) {
|
||||||
if ($from !~ m/^#/ or $from =~ m/^$channel_regex$/i) {
|
if ($from !~ m/^#/ or $from =~ m/^$channel_regex$/i) {
|
||||||
foreach my $hostmask_regex (keys %{ $self->{admins}->{hash}->{$channel_regex} }) {
|
foreach my $hostmask_regex (keys %{ $self->{admins}->{hash}->{$channel_regex} }) {
|
||||||
@ -154,15 +155,21 @@ sub find_admin {
|
|||||||
my $hostmask_quoted = quotemeta $hostmask_regex;
|
my $hostmask_quoted = quotemeta $hostmask_regex;
|
||||||
$hostmask_quoted =~ s/\\\*/.*?/g;
|
$hostmask_quoted =~ s/\\\*/.*?/g;
|
||||||
$hostmask_quoted =~ s/\\\?/./g;
|
$hostmask_quoted =~ s/\\\?/./g;
|
||||||
return $self->{admins}->{hash}->{$channel_regex}->{$hostmask_regex} if $hostmask =~ m/^$hostmask_quoted$/i;
|
if ($hostmask =~ m/^$hostmask_quoted$/i) {
|
||||||
|
my $temp = $self->{admins}->{hash}->{$channel_regex}->{$hostmask_regex};
|
||||||
|
$admin = $temp if not defined $admin or $admin->{level} < $temp->{level};
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
# direct comparison
|
# direct comparison
|
||||||
return $self->{admins}->{hash}->{$channel_regex}->{$hostmask_regex} if $hostmask eq lc $hostmask_regex;
|
if ($hostmask eq lc $hostmask_regex) {
|
||||||
|
my $temp = $self->{admins}->{hash}->{$channel_regex}->{$hostmask_regex};
|
||||||
|
$admin = $temp if not defined $admin or $admin->{level} < $temp->{level};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undef;
|
}
|
||||||
|
return $admin;
|
||||||
};
|
};
|
||||||
|
|
||||||
if ($@) {
|
if ($@) {
|
||||||
|
Loading…
Reference in New Issue
Block a user