mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-11 04:22:35 +01:00
Add chanlist command to list channel data
This commit is contained in:
parent
a5ae7478e1
commit
42c2554655
@ -29,11 +29,7 @@ sub new {
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
|
||||
my $pbot = delete $conf{pbot};
|
||||
if(not defined $pbot) {
|
||||
Carp::croak ("Missing pbot reference to Channels");
|
||||
}
|
||||
|
||||
my $pbot = delete $conf{pbot} // Carp::croak("Missing pbot reference to Channels");
|
||||
my $filename = delete $conf{filename};
|
||||
|
||||
$self->{pbot} = $pbot;
|
||||
@ -43,6 +39,7 @@ sub initialize {
|
||||
$pbot->commands->register(sub { $self->unset(@_) }, "chanunset", 40);
|
||||
$pbot->commands->register(sub { $self->add(@_) }, "chanadd", 40);
|
||||
$pbot->commands->register(sub { $self->remove(@_) }, "chanrem", 40);
|
||||
$pbot->commands->register(sub { $self->list(@_) }, "chanlist", 10);
|
||||
}
|
||||
|
||||
sub set {
|
||||
@ -91,6 +88,22 @@ sub remove {
|
||||
return "/msg $nick " . $self->channels->remove($arguments);
|
||||
}
|
||||
|
||||
sub list {
|
||||
my ($self, $from, $nick, $user, $host, $arguments) = @_;
|
||||
my $result;
|
||||
|
||||
foreach my $index (sort keys %{ $self->channels->hash }) {
|
||||
$result .= "$index: {";
|
||||
my $comma = ' ';
|
||||
foreach my $key (sort keys %{ ${ $self->channels->hash }{$index} }) {
|
||||
$result .= "$comma$key => ${ $self->channels->hash }{$index}{$key}";
|
||||
$comma = ', ';
|
||||
}
|
||||
$result .= " }\n";
|
||||
}
|
||||
return "/msg $nick $result";
|
||||
}
|
||||
|
||||
sub load_channels {
|
||||
my $self = shift;
|
||||
|
||||
|
@ -13,8 +13,8 @@ use warnings;
|
||||
# These are set automatically by the build/commit script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 503,
|
||||
BUILD_DATE => "2014-03-04",
|
||||
BUILD_REVISION => 504,
|
||||
BUILD_DATE => "2014-03-05",
|
||||
};
|
||||
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user