3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-03 09:58:42 +02:00

Users: users command now strictly filters to channel argument if provided

This commit is contained in:
Pragmatic Software 2020-02-10 00:17:31 -08:00
parent 12be1e87dd
commit d0d1ae5194

View File

@ -318,13 +318,20 @@ sub logoutcmd {
sub users { sub users {
my ($self, $from, $nick, $user, $host, $arguments, $stuff) = @_; my ($self, $from, $nick, $user, $host, $arguments, $stuff) = @_;
my $channel = $self->{pbot}->{interpreter}->shift_arg($stuff->{arglist}); my $channel = $self->{pbot}->{interpreter}->shift_arg($stuff->{arglist});
$channel = $from if not defined $channel;
my $include_global = '';
if (not defined $channel) {
$channel = $from;
$include_global = '.*';
} else {
$channel = '.*' if $channel !~ /^#/;
}
my $text = "Users: "; my $text = "Users: ";
my $last_channel = ""; my $last_channel = "";
my $sep = ""; my $sep = "";
foreach my $chan (sort keys %{ $self->{users}->{hash} }) { foreach my $chan (sort keys %{ $self->{users}->{hash} }) {
next if $from =~ m/^#/ and $chan ne $channel and $chan ne '.*'; next if $from =~ m/^#/ and $chan ne $channel and $chan ne $include_global;
next if $from !~ m/^#/ and $channel =~ m/^#/ and $chan ne $channel; next if $from !~ m/^#/ and $channel =~ m/^#/ and $chan ne $channel;
if ($last_channel ne $chan) { if ($last_channel ne $chan) {