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

Do not attempt to enforce antiaway/rejoin if not chanop

This commit is contained in:
Pragmatic Software 2015-06-20 07:24:13 -07:00
parent fea56842d3
commit 0d4c5c301f
2 changed files with 7 additions and 1 deletions

View File

@ -37,10 +37,11 @@ sub on_nickchange {
my $bad_nicks = $self->{pbot}->{registry}->get_value('antiaway', 'bad_nicks'); my $bad_nicks = $self->{pbot}->{registry}->get_value('antiaway', 'bad_nicks');
if($newnick =~ m/$bad_nicks/i) { if($newnick =~ m/$bad_nicks/i) {
$self->{pbot}->{logger}->log("$newnick matches bad away nick regex, kicking...\n");
my $kick_msg = $self->{pbot}->{registry}->get_value('antiaway', 'kick_msg'); my $kick_msg = $self->{pbot}->{registry}->get_value('antiaway', 'kick_msg');
my $channels = $self->{pbot}->{nicklist}->get_channels($newnick); my $channels = $self->{pbot}->{nicklist}->get_channels($newnick);
foreach my $chan (@$channels) { foreach my $chan (@$channels) {
next if not exists $self->{pbot}->{channels}->{channels}->hash->{$chan} or not $self->{pbot}->{channels}->{channels}->hash->{$chan}{chanop};
$self->{pbot}->{logger}->log("$newnick matches bad away nick regex, kicking from $chan\n");
$self->{pbot}->{chanops}->add_op_command($chan, "kick $chan $newnick $kick_msg"); $self->{pbot}->{chanops}->add_op_command($chan, "kick $chan $newnick $kick_msg");
$self->{pbot}->{chanops}->gain_ops($chan); $self->{pbot}->{chanops}->gain_ops($chan);
} }
@ -54,6 +55,7 @@ sub on_action {
my ($nick, $user, $host, $msg, $channel) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->{args}[0], $event->{event}->{to}[0]); my ($nick, $user, $host, $msg, $channel) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->{args}[0], $event->{event}->{to}[0]);
return 0 if $channel !~ /^#/; return 0 if $channel !~ /^#/;
return 0 if not exists $self->{pbot}->{channels}->{channels}->hash->{$channel} or not $self->{pbot}->{channels}->{channels}->hash->{$channel}{chanop};
my $bad_actions = $self->{pbot}->{registry}->get_value('antiaway', 'bad_actions'); my $bad_actions = $self->{pbot}->{registry}->get_value('antiaway', 'bad_actions');
if($msg =~ m/$bad_actions/i) { if($msg =~ m/$bad_actions/i) {

View File

@ -38,6 +38,8 @@ sub on_kick {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $target, $channel, $reason) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->to, $event->{event}->{args}[0], $event->{event}->{args}[1]); my ($nick, $user, $host, $target, $channel, $reason) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->to, $event->{event}->{args}[0], $event->{event}->{args}[1]);
return 0 if not exists $self->{pbot}->{channels}->{channels}->hash->{$channel} or not $self->{pbot}->{channels}->{channels}->hash->{$channel}{chanop};
if (not exists $self->{kicks}->{$channel} if (not exists $self->{kicks}->{$channel}
or not exists $self->{kicks}->{$channel}->{$target}) { or not exists $self->{kicks}->{$channel}->{$target}) {
$self->{kicks}->{$channel}->{$target}->{rejoins} = 0; $self->{kicks}->{$channel}->{$target}->{rejoins} = 0;
@ -52,6 +54,8 @@ sub on_join {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $channel) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->to); my ($nick, $user, $host, $channel) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->to);
return 0 if not exists $self->{pbot}->{channels}->{channels}->hash->{$channel} or not $self->{pbot}->{channels}->{channels}->hash->{$channel}{chanop};
if (exists $self->{kicks}->{$channel} if (exists $self->{kicks}->{$channel}
and exists $self->{kicks}->{$channel}->{$nick}) { and exists $self->{kicks}->{$channel}->{$nick}) {
my $now = gettimeofday; my $now = gettimeofday;