3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-20 02:49:49 +01:00

list admins now lists only current channel when used in-channel

This commit is contained in:
Pragmatic Software 2020-01-04 22:13:07 -08:00
parent 6e25f96717
commit 4dacbfeb7a

View File

@ -712,13 +712,14 @@ sub list {
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
my $text; my $text;
my $usage = "Usage: list <modules|commands|admins>";
if (not defined $arguments) { if (not defined $arguments) {
return "Usage: list <modules|factoids|commands|admins>"; return $usage;
} }
if ($arguments =~ /^modules$/i) { if ($arguments =~ /^modules$/i) {
$from = '.*' if not defined $from or $from !~ /^#/; $text = "Loaded modules: ";
$text = "Loaded modules for channel $from: ";
foreach my $channel (sort keys %{ $self->{pbot}->{factoids}->{factoids}->hash }) { foreach my $channel (sort keys %{ $self->{pbot}->{factoids}->{factoids}->hash }) {
foreach my $command (sort keys %{ $self->{pbot}->{factoids}->{factoids}->hash->{$channel} }) { foreach my $command (sort keys %{ $self->{pbot}->{factoids}->{factoids}->hash->{$channel} }) {
if ($self->{pbot}->{factoids}->{factoids}->hash->{$channel}->{$command}->{type} eq 'module') { if ($self->{pbot}->{factoids}->{factoids}->hash->{$channel}->{$command}->{type} eq 'module') {
@ -738,17 +739,14 @@ sub list {
return $text; return $text;
} }
if ($arguments =~ /^factoids$/i) {
return "For a list of factoids see " . $self->{pbot}->{factoids}->export_site;
}
if ($arguments =~ /^admins$/i) { if ($arguments =~ /^admins$/i) {
$text = "Admins: "; $text = "Admins: ";
my $last_channel = ""; my $last_channel = "";
my $sep = ""; my $sep = "";
foreach my $channel (sort keys %{ $self->{pbot}->{admins}->{admins}->hash }) { 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) { if ($last_channel ne $channel) {
$text .= $sep . "Channel " . ($channel eq ".*" ? "all" : $channel) . ": "; $text .= $sep . ($channel eq ".*" ? "all" : $channel) . ": ";
$last_channel = $channel; $last_channel = $channel;
$sep = ""; $sep = "";
} }
@ -761,7 +759,7 @@ sub list {
} }
return $text; return $text;
} }
return "Usage: list <modules|commands|factoids|admins>"; return $usage;
} }
sub factmove { sub factmove {