3
0
mirror of https://github.com/pragma-/pbot.git synced 2025-02-18 14:30:40 +01:00

Channels: add get_meta() convenience subroutine

This commit is contained in:
Pragmatic Software 2018-08-05 22:44:46 -07:00
parent 4e996717c8
commit 1f43e003d8

View File

@ -107,25 +107,28 @@ sub list {
sub is_active { sub is_active {
my ($self, $channel) = @_; my ($self, $channel) = @_;
return exists $self->{channels}->hash->{$channel} && $self->{channels}->hash->{$channel}->{enabled}; return exists $self->{channels}->hash->{$channel} && $self->{channels}->hash->{$channel}->{enabled};
} }
sub is_active_op { sub is_active_op {
my ($self, $channel) = @_; my ($self, $channel) = @_;
return $self->is_active($channel) && $self->{channels}->hash->{$channel}->{chanop}; return $self->is_active($channel) && $self->{channels}->hash->{$channel}->{chanop};
} }
sub get_meta {
my ($self, $channel, $key) = @_;
my $index = $self->{channels}->find_hash($channel);
return undef if not defined $index;
return $self->{channels}->{hash}->{$index}->{$key};
}
sub load_channels { sub load_channels {
my $self = shift; my $self = shift;
$self->{channels}->load(); $self->{channels}->load();
} }
sub save_channels { sub save_channels {
my $self = shift; my $self = shift;
$self->{channels}->save(); $self->{channels}->save();
} }