From 5d3507421eb3a5182bbd8723a847c28671bfe0cc Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sat, 9 Mar 2024 20:29:25 -0800 Subject: [PATCH] Plugin/Wordle: fix not detecting duplicate letters --- lib/PBot/Core/Interpreter.pm | 1 + lib/PBot/Plugin/Wordle.pm | 7 +++++-- lib/PBot/VERSION.pm | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/PBot/Core/Interpreter.pm b/lib/PBot/Core/Interpreter.pm index 75c6f484..f6a4a088 100644 --- a/lib/PBot/Core/Interpreter.pm +++ b/lib/PBot/Core/Interpreter.pm @@ -953,6 +953,7 @@ sub add_message_to_output_queue($self, $channel, $message, $delay = 0) { hostmask => $message->{hostmask}, output => $message->{message}, command => $message->{command}, + keyword => $message->{keyword}, checkflood => $message->{checkflood} }; diff --git a/lib/PBot/Plugin/Wordle.pm b/lib/PBot/Plugin/Wordle.pm index 43d4b0c4..5b4b25f1 100644 --- a/lib/PBot/Plugin/Wordle.pm +++ b/lib/PBot/Plugin/Wordle.pm @@ -127,6 +127,7 @@ sub wordle($self, $context) { host => 'localhost', hostmask => "$botnick!wordle\@localhost", command => 'wordle', + keyword => 'wordle', checkflood => 1, message => "$context->{nick} started a custom $result", }; @@ -284,7 +285,6 @@ sub guess_wordle($self, $channel, $guess) { for (my $i = 0; $i < @wordle; $i++) { if ($guess[$i] eq $wordle[$i]) { - $seen{$guess[$i]}++; $correct++; push @result, "*$guess[$i]*"; $self->{$channel}->{letters}->{$guess[$i]} = LETTER_CORRECT; @@ -307,7 +307,10 @@ sub guess_wordle($self, $channel, $guess) { $self->{$channel}->{letters}->{$guess[$i]} = LETTER_PRESENT; } else { push @result, "$guess[$i]"; - $self->{$channel}->{letters}->{$guess[$i]} = LETTER_INVALID; + + if ($self->{$channel}->{letters}->{$guess[$i]} == 0) { + $self->{$channel}->{letters}->{$guess[$i]} = LETTER_INVALID; + } } } } diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index 175998d9..6ddd2596 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,7 +25,7 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4714, + BUILD_REVISION => 4715, BUILD_DATE => "2024-03-09", };