diff options
author | David Phillips <david@sighup.nz> | 2018-09-10 21:08:59 +1200 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2018-09-10 21:08:59 +1200 |
commit | d211249f073d5a19883766fcd5fd5833b9c869c6 (patch) | |
tree | 9c65404ea14e6bc6636897b5c0716811073ffd15 /Plugin | |
parent | a2e167cbe2ace2ded2b19c12513100d5be5247db (diff) | |
download | idalius-d211249f073d5a19883766fcd5fd5833b9c869c6.tar.xz |
Make Jinx.pm work per-channel
Diffstat (limited to 'Plugin')
-rw-r--r-- | Plugin/Jinx.pm | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/Plugin/Jinx.pm b/Plugin/Jinx.pm index 04c43c8..0c3f542 100644 --- a/Plugin/Jinx.pm +++ b/Plugin/Jinx.pm @@ -7,10 +7,10 @@ use strict; use warnings; # Last message we responded to with a jinx -my $last_response = undef; +my %last_response; # Last message said on the channel -my $last = undef; +my %last; my %config; sub configure { @@ -23,32 +23,38 @@ sub configure { sub on_message { my ($self, $logger, $me, $who, $where, $raw_what, $what, $irc) = @_; + my $channel = $where->[0]; - return if defined $last_response and $what eq $last_response; + return if $last_response{$channel} and $what eq $last_response{$channel}; - if (defined $last and $last eq $what) { - $last_response = $last; - return $last; + if ($last{$channel} and $last{$channel} eq $what) { + $last_response{$channel} = $what; + return $what; } - $last = $what; - $last_response = undef; + $logger->("Storing on_message for $channel $what"); + + $last{$channel} = $what; + $last_response{$channel} = undef; return; } sub on_action { my ($self, $logger, $me, $who, $where, $raw_what, $what, $irc) = @_; + my $channel = $where->[0]; - return if defined $last_response and $what eq $last_response; + return if $last_response{$channel} and $what eq $last_response{$channel}; - if (defined $last and $last eq $what) { - $last_response = $last; - $irc->yield(ctcp => $where->[0] => "ACTION" => $what); + if ($last{$channel} and $last{$channel} eq $what) { + $last_response{$channel} = $what; + $irc->yield(ctcp => $channel->[0] => "ACTION" => $what); return; } - $last = $what; - $last_response = undef; + $logger->("Storing on_action for $channel $what"); + + $last{$channel} = $what; + $last_response{$channel} = undef; return; } 1; |