From 8b479752eeb57daeaf2b9f0347fc0c46dd5d4fc5 Mon Sep 17 00:00:00 2001
From: David Phillips <david@sighup.nz>
Date: Mon, 10 Sep 2018 19:38:10 +1200
Subject: Handle/respond to action vs message appropriately

---
 Plugin/Jinx.pm | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/Plugin/Jinx.pm b/Plugin/Jinx.pm
index 12f1dce..6f0291f 100644
--- a/Plugin/Jinx.pm
+++ b/Plugin/Jinx.pm
@@ -9,7 +9,7 @@ use warnings;
 # Last message we responded to with a jinx
 my $last_response = undef;
 
-# Last message said on the channel
+# Last message said on the channel, and whether it's action or message
 my $last = undef;
 my %config;
 
@@ -26,11 +26,31 @@ sub message {
 
 	return if defined $last_response and $what eq $last_response;
 
-	if (defined $last and $last eq $what ) {
+	if (defined $last and $last eq $what) {
 		$last_response = $last;
 		return $last;
 	}
 
+	$logger->("Storing $what");
+
+	$last = $what;
+	$last_response = undef;
+	return;
+}
+
+sub action {
+	my ($self, $logger, $me, $who, $where, $raw_what, $what, $irc) = @_;
+
+	return if defined $last_response and $what eq $last_response;
+
+	if (defined $last and $last eq $what) {
+		$last_response = $last;
+		$irc->yield(ctcp => $where->[0] => "ACTION" => $what);
+		return;
+	}
+
+	$logger->("Storing action $what");
+
 	$last = $what;
 	$last_response = undef;
 	return;
-- 
cgit v1.1