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

Channels: add autojoin function

This commit is contained in:
Pragmatic Software 2019-12-21 19:43:05 -08:00
parent 274ee8dcd6
commit 3b93dbe4c3

View File

@ -107,6 +107,20 @@ sub list {
return $result;
}
sub autojoin {
my ($self) = @_;
return if $self->{pbot}->{joined_channels};
my $chans;
foreach my $chan (keys %{ $self->{pbot}->{channels}->{channels}->hash }) {
if ($self->{pbot}->{channels}->{channels}->hash->{$chan}{enabled}) {
$chans .= "$chan,";
}
}
$self->{pbot}->{logger}->log("Joining channels: $chans\n");
$self->{pbot}->{chanops}->join_channel($chans);
$self->{pbot}->{joined_channels} = 1;
}
sub is_active {
my ($self, $channel) = @_;
return exists $self->{channels}->hash->{$channel} && $self->{channels}->hash->{$channel}->{enabled};