From bb5c825aab7b564efa7a2333d26a6b957498a178 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sat, 27 Dec 2014 05:08:42 +0000 Subject: [PATCH] Correct handling of anti-away /me actions --- PBot/AntiAway.pm | 14 +++++--------- PBot/VERSION.pm | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/PBot/AntiAway.pm b/PBot/AntiAway.pm index d5b83933..d29bc665 100644 --- a/PBot/AntiAway.pm +++ b/PBot/AntiAway.pm @@ -8,7 +8,6 @@ package PBot::AntiAway; use warnings; use strict; -use Data::Dumper; use Carp (); sub new { @@ -52,19 +51,16 @@ sub on_nickchange { sub on_action { my ($self, $event_type, $event) = @_; - my ($nick, $user, $host, $msg) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->{args}[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 !~ /^#/; - print "antiaway got action [$msg]\n"; my $bad_actions = $self->{pbot}->{registry}->get_value('antiaway', 'bad_actions'); - print "antiaway got action [$msg]\nbad_actions: [$bad_actions]\n"; if($msg =~ m/$bad_actions/i) { $self->{pbot}->{logger}->log("$nick $msg matches bad away actions regex, kicking...\n"); my $kick_msg = $self->{pbot}->{registry}->get_value('antiaway', 'kick_msg'); - my $channels = $self->{pbot}->{nicklist}->get_channels($nick); - foreach my $chan (@$channels) { - $self->{pbot}->{chanops}->add_op_command($chan, "kick $chan $nick $kick_msg"); - $self->{pbot}->{chanops}->gain_ops($chan); - } + $self->{pbot}->{chanops}->add_op_command($channel, "kick $channel $nick $kick_msg"); + $self->{pbot}->{chanops}->gain_ops($channel); } return 0; diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index 36c19489..2fd39531 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -13,7 +13,7 @@ use warnings; # These are set automatically by the build/commit script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 803, + BUILD_REVISION => 804, BUILD_DATE => "2014-12-26", };