3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-03 01:48:38 +02:00

Users: improve find_user

This commit is contained in:
Pragmatic Software 2020-02-09 21:30:55 -08:00
parent cfc3ad855f
commit 1f94973bd2

View File

@ -184,8 +184,15 @@ sub find_user {
$hostmask = '.*' if not defined $hostmask;
$hostmask = lc $hostmask;
my $sort;
if ($channel =~ m/^#/) {
$sort = sub { $a cmp $b };
} else {
$sort = sub { $b cmp $a };
}
my $user = eval {
foreach my $channel_regex (keys %{ $self->{users}->{hash} }) {
foreach my $channel_regex (sort $sort keys %{ $self->{users}->{hash} }) {
if ($channel !~ m/^#/ or $channel =~ m/^$channel_regex$/i) {
foreach my $hostmask_regex (keys %{ $self->{users}->{hash}->{$channel_regex} }) {
next if $hostmask_regex eq '_name';