3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-03 01:48:38 +02: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 $text;
my $usage = "Usage: list <modules|commands|admins>";
if (not defined $arguments) {
return "Usage: list <modules|factoids|commands|admins>";
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 <modules|commands|factoids|admins>";
return $usage;
}
sub factmove {