3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-23 19:22:40 +01:00

Add can_gain_ops(), has_unban_timeout() and has_unmute_timeout() subroutines

This commit is contained in:
Pragmatic Software 2015-06-25 20:54:38 -07:00
parent 452ac7fc4c
commit 95a4be6cb0

View File

@ -56,12 +56,17 @@ sub initialize {
$self->{pbot}->{timer}->register(sub { $self->check_unmute_timeouts }, 10);
}
sub can_gain_ops {
my ($self, $channel) = @_;
return exists $self->{pbot}->{channels}->{channels}->hash->{$channel} && $self->{pbot}->{channels}->{channels}->hash->{$channel}{chanop};
}
sub gain_ops {
my $self = shift;
my $channel = shift;
return if exists $self->{op_requested}->{$channel};
return if not exists $self->{pbot}->{channels}->{channels}->hash->{$channel} or not $self->{pbot}->{channels}->{channels}->hash->{$channel}{chanop};
return if not $self->can_gain_ops($channel);
if(not exists $self->{is_opped}->{$channel}) {
$self->{pbot}->{conn}->privmsg("chanserv", "op $channel");
@ -79,7 +84,7 @@ sub lose_ops {
sub add_op_command {
my ($self, $channel, $command) = @_;
return if not exists $self->{pbot}->{channels}->{channels}->hash->{$channel} or not $self->{pbot}->{channels}->{channels}->hash->{$channel}{chanop};
return if not $self->can_gain_ops($channel);
push @{ $self->{op_commands}->{$channel} }, $command;
}
@ -199,6 +204,17 @@ sub part_channel {
delete $self->{op_requested}->{$channel};
}
sub has_ban_timeout {
my ($self, $channel, $mask) = @_;
return exists $self->{unban_timeout}->hash->{$channel}->{$mask};
}
sub has_mute_timeout {
my ($self, $channel, $mask) = @_;
return exists $self->{unmute_timeout}->hash->{$channel}->{$mask};
}
sub check_unban_timeouts {
my $self = shift;