3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-23 12:29:27 +01:00

Correct handling of anti-away /me actions

This commit is contained in:
Pragmatic Software 2014-12-27 05:08:42 +00:00
parent e5909965f7
commit bb5c825aab
2 changed files with 6 additions and 10 deletions

View File

@ -8,7 +8,6 @@ package PBot::AntiAway;
use warnings; use warnings;
use strict; use strict;
use Data::Dumper;
use Carp (); use Carp ();
sub new { sub new {
@ -52,19 +51,16 @@ sub on_nickchange {
sub on_action { sub on_action {
my ($self, $event_type, $event) = @_; 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'); 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) { if($msg =~ m/$bad_actions/i) {
$self->{pbot}->{logger}->log("$nick $msg matches bad away actions regex, kicking...\n"); $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 $kick_msg = $self->{pbot}->{registry}->get_value('antiaway', 'kick_msg');
my $channels = $self->{pbot}->{nicklist}->get_channels($nick); $self->{pbot}->{chanops}->add_op_command($channel, "kick $channel $nick $kick_msg");
foreach my $chan (@$channels) { $self->{pbot}->{chanops}->gain_ops($channel);
$self->{pbot}->{chanops}->add_op_command($chan, "kick $chan $nick $kick_msg");
$self->{pbot}->{chanops}->gain_ops($chan);
}
} }
return 0; return 0;

View File

@ -13,7 +13,7 @@ use warnings;
# These are set automatically by the build/commit script # These are set automatically by the build/commit script
use constant { use constant {
BUILD_NAME => "PBot", BUILD_NAME => "PBot",
BUILD_REVISION => 803, BUILD_REVISION => 804,
BUILD_DATE => "2014-12-26", BUILD_DATE => "2014-12-26",
}; };