mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 13:59:47 +01:00
Add permop
channel flag; when non-zero bot automatically ops itself when joining channel, otherwise bot ops itself only when needing to perform an op command and then deops itself after its deop timeout has elapsed
This commit is contained in:
parent
598e2e4988
commit
a09d3c1d63
@ -136,8 +136,7 @@ sub join_channel {
|
||||
|
||||
foreach my $channel (split /\s+/, $arguments) {
|
||||
$self->{pbot}->{logger}->log("$nick!$user\@$host made me join $channel\n");
|
||||
$self->{pbot}->{event_dispatcher}->dispatch_event('pbot.join', { channel => $channel });
|
||||
$self->{pbot}->{conn}->join($channel);
|
||||
$self->{pbot}->{chanops}->join_channel($channel);
|
||||
}
|
||||
|
||||
return "/msg $nick Joining $arguments";
|
||||
@ -151,8 +150,7 @@ sub part_channel {
|
||||
|
||||
foreach my $channel (split /\s+/, $arguments) {
|
||||
$self->{pbot}->{logger}->log("$nick!$user\@$host made me part $channel\n");
|
||||
$self->{pbot}->{event_dispatcher}->dispatch_event('pbot.part', { channel => $channel });
|
||||
$self->{pbot}->{conn}->part($channel);
|
||||
$self->{pbot}->{chanops}->part_channel($channel);
|
||||
}
|
||||
|
||||
return "/msg $nick Parting $arguments";
|
||||
|
@ -121,6 +121,32 @@ sub ban_user_timed {
|
||||
$self->{unban_timeout}->save;
|
||||
}
|
||||
|
||||
sub join_channel {
|
||||
my ($self, $channel) = @_;
|
||||
|
||||
$self->{pbot}->{event_dispatcher}->dispatch_event('pbot.join', { channel => $channel });
|
||||
$self->{pbot}->{conn}->join($channel);
|
||||
|
||||
delete $self->{is_opped}->{$channel};
|
||||
delete $self->{op_requested}->{$channel};
|
||||
|
||||
if (exists $self->{pbot}->{channels}->{channels}->hash->{$channel}
|
||||
and exists $self->{pbot}->{channels}->{channels}->hash->{$channel}{permop}
|
||||
and $self->{pbot}->{channels}->{channels}->hash->{$channel}{permop}) {
|
||||
$self->gain_ops($channel);
|
||||
}
|
||||
}
|
||||
|
||||
sub part_channel {
|
||||
my ($self, $channel) = @_;
|
||||
|
||||
$self->{pbot}->{event_dispatcher}->dispatch_event('pbot.part', { channel => $channel });
|
||||
$self->{pbot}->{conn}->part($channel);
|
||||
|
||||
delete $self->{is_opped}->{$channel};
|
||||
delete $self->{op_requested}->{$channel};
|
||||
}
|
||||
|
||||
sub check_unban_timeouts {
|
||||
my $self = shift;
|
||||
|
||||
@ -143,8 +169,12 @@ sub check_opped_timeouts {
|
||||
|
||||
foreach my $channel (keys %{ $self->{is_opped} }) {
|
||||
if($self->{is_opped}->{$channel}{timeout} < $now) {
|
||||
$self->lose_ops($channel);
|
||||
delete $self->{is_opped}->{$channel}; # assume chanserv is alive and deop will succeed
|
||||
unless (exists $self->{pbot}->{channels}->{channels}->hash->{$channel}
|
||||
and exists $self->{pbot}->{channels}->{channels}->hash->{$channel}{permop}
|
||||
and $self->{pbot}->{channels}->{channels}->hash->{$channel}{permop}) {
|
||||
$self->lose_ops($channel);
|
||||
delete $self->{is_opped}->{$channel}; # assume chanserv is alive and deop will succeed
|
||||
}
|
||||
} else {
|
||||
# my $timediff = $self->{is_opped}->{$channel}{timeout} - $now;
|
||||
# $self->{pbot}->{logger}->log("deop $channel in $timediff seconds\n");
|
||||
|
@ -70,6 +70,7 @@ sub add {
|
||||
my $hash = {};
|
||||
$hash->{enabled} = 1;
|
||||
$hash->{chanop} = 0;
|
||||
$hash->{permop} = 0;
|
||||
|
||||
return $self->{channels}->add($arguments, $hash);
|
||||
}
|
||||
|
@ -132,8 +132,7 @@ sub on_notice {
|
||||
foreach my $chan (keys %{ $self->{pbot}->{channels}->{channels}->hash }) {
|
||||
if($self->{pbot}->{channels}->{channels}->hash->{$chan}{enabled}) {
|
||||
$self->{pbot}->{logger}->log("Joining channel: $chan\n");
|
||||
$self->{pbot}->{event_dispatcher}->dispatch_event('pbot.join', { channel => $chan });
|
||||
$event->{conn}->join($chan);
|
||||
$self->{pbot}->{chanops}->join_channel($chan);
|
||||
}
|
||||
}
|
||||
$self->{pbot}->{joined_channels} = 1;
|
||||
|
@ -13,8 +13,8 @@ use warnings;
|
||||
# These are set automatically by the build/commit script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 800,
|
||||
BUILD_DATE => "2014-11-14",
|
||||
BUILD_REVISION => 801,
|
||||
BUILD_DATE => "2014-12-18",
|
||||
};
|
||||
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user