From 0462e4153d3a6bcfaea490b98b3fb2fb5f071127 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Mon, 16 Mar 2026 14:08:54 -0700 Subject: [PATCH] Plugins/Wordle: minor improvements --- lib/PBot/Plugin/Wordle.pm | 10 ++++++++-- lib/PBot/VERSION.pm | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/PBot/Plugin/Wordle.pm b/lib/PBot/Plugin/Wordle.pm index 05c16c30..1fc071a5 100644 --- a/lib/PBot/Plugin/Wordle.pm +++ b/lib/PBot/Plugin/Wordle.pm @@ -252,6 +252,10 @@ sub wordle($self, $context) { if (not defined $args[0]) { return "$context->{nick}: You are playing the $gameid Wordle."; } else { + if ($gameid !~ /^[a-zA-Z0-9_]{1,16}$/) { + return "Invalid game-id `$gameid`; must be up to 16 alphanumeric characters"; + } + $self->{players}->{$channel}->{$context->{message_account}}->{gameid} = $gameid; $self->{games}->{$channel}->{$gameid}->{exists} = 1; return "$context->{nick} is now playing the $gameid Wordle!"; @@ -1023,6 +1027,7 @@ sub guesses2state($self, $channel, $gameid) { my $g = $guess; $g =~ s/\x02|\x0F|\x11|\x1D|\x1E|\x1F|\x03([0-9][0-9]?(,[0-9][0-9]?)?)?//g; + $g =~ s/ß/ẞ/g; # avoid uppercasing to SS in German my @states = ($g =~ /..(.)/g); foreach my $state (@states) { @@ -1136,8 +1141,8 @@ sub state2pattern($self, $state) { } sub pattern2words($self, $channel, $gameid, $pattern) { - my @keys = keys $self->{games}->{$channel}->{$gameid}->{words}->%*; - return grep { /$pattern/i } @keys; + my @keys = map { lc } keys $self->{games}->{$channel}->{$gameid}->{words}->%*; + return grep { /$pattern/ } @keys; } sub check_games($self) { @@ -1145,6 +1150,7 @@ sub check_games($self) { my $botnick = $self->{pbot}->{registry}->get_value('irc', 'botnick'); foreach my $channel (keys $self->{games}->%*) { foreach my $gameid (keys $self->{games}->{$channel}->%*) { + next if $gameid eq 'main'; next if not exists $self->{games}->{$channel}->{$gameid}->{wordle}; if ($now - $self->{games}->{$channel}->{$gameid}->{guess_time} > 60 * 60 * 24) { my $wordle = join '', $self->{games}->{$channel}->{$gameid}->{wordle}->@*; diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index b0cadabf..ca3f492c 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,8 +25,8 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4941, - BUILD_DATE => "2026-03-15", + BUILD_REVISION => 4942, + BUILD_DATE => "2026-03-16", }; sub initialize {}