From 4dacbfeb7a80bce7e637dc2026d7334731fffa8e Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sat, 4 Jan 2020 22:13:07 -0800 Subject: [PATCH] `list admins` now lists only current channel when used in-channel --- PBot/FactoidCommands.pm | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/PBot/FactoidCommands.pm b/PBot/FactoidCommands.pm index 2d986d08..b9c9cf7a 100644 --- a/PBot/FactoidCommands.pm +++ b/PBot/FactoidCommands.pm @@ -712,13 +712,14 @@ sub list { my ($from, $nick, $user, $host, $arguments) = @_; my $text; + my $usage = "Usage: list "; + if (not defined $arguments) { - return "Usage: list "; + return $usage; } if ($arguments =~ /^modules$/i) { - $from = '.*' if not defined $from or $from !~ /^#/; - $text = "Loaded modules for channel $from: "; + $text = "Loaded modules: "; foreach my $channel (sort keys %{ $self->{pbot}->{factoids}->{factoids}->hash }) { foreach my $command (sort keys %{ $self->{pbot}->{factoids}->{factoids}->hash->{$channel} }) { if ($self->{pbot}->{factoids}->{factoids}->hash->{$channel}->{$command}->{type} eq 'module') { @@ -738,17 +739,14 @@ sub list { return $text; } - if ($arguments =~ /^factoids$/i) { - return "For a list of factoids see " . $self->{pbot}->{factoids}->export_site; - } - if ($arguments =~ /^admins$/i) { $text = "Admins: "; my $last_channel = ""; my $sep = ""; foreach my $channel (sort keys %{ $self->{pbot}->{admins}->{admins}->hash }) { + next if $from =~ m/^#/ and $channel ne $from and $channel ne '.*'; if ($last_channel ne $channel) { - $text .= $sep . "Channel " . ($channel eq ".*" ? "all" : $channel) . ": "; + $text .= $sep . ($channel eq ".*" ? "all" : $channel) . ": "; $last_channel = $channel; $sep = ""; } @@ -761,7 +759,7 @@ sub list { } return $text; } - return "Usage: list "; + return $usage; } sub factmove {