From 6147a5afc7c5be4931b9e64c282f66abe81c7bab Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Thu, 4 Sep 2025 10:26:53 -0700 Subject: [PATCH] Plugin/Wordle: add solved duration --- lib/PBot/Plugin/Wordle.pm | 11 +++++++++-- lib/PBot/VERSION.pm | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/PBot/Plugin/Wordle.pm b/lib/PBot/Plugin/Wordle.pm index dbfde426..7d933597 100644 --- a/lib/PBot/Plugin/Wordle.pm +++ b/lib/PBot/Plugin/Wordle.pm @@ -158,13 +158,15 @@ sub wordle($self, $context) { return NO_WORDLE; } + my $started = concise ago time - $self->{$channel}->{start_time}; my $hard = $self->{$channel}->{hard_mode} ? 'on' : 'off'; - my $result = "Current wordlist: $self->{$channel}->{wordlist} ($self->{$channel}->{length}); hard mode: $hard; guesses: $self->{$channel}->{guess_count}; nonwords: $self->{$channel}->{nonword_count}; invalids: $self->{$channel}->{invalid_count}"; + my $result = "Current wordlist: $self->{$channel}->{wordlist} ($self->{$channel}->{length}); started $started; hard mode: $hard; guesses: $self->{$channel}->{guess_count}; nonwords: $self->{$channel}->{nonword_count}; invalids: $self->{$channel}->{invalid_count}"; if ($self->{$channel}->{correct}) { my $solved_on = concise ago (time - $self->{$channel}->{solved_on}); my $wordle = join '', $self->{$channel}->{wordle}->@*; - $result .= "; solved by: $self->{$channel}->{solved_by} ($solved_on); word was: $wordle"; + my $duration = concise duration $self->{$channel}->{start_time} - $self->{$channel}->{solved_on}; + $result .= "; solved by: $self->{$channel}->{solved_by} in $duration ($solved_on); word was: $wordle"; } elsif ($self->{$channel}->{givenup}) { my $givenup_on = concise ago (time - $self->{$channel}->{givenup_on}); my $wordle = join '', $self->{$channel}->{wordle}->@*; @@ -443,6 +445,7 @@ sub make_wordle($self, $channel, $length, $word = undef, $wordlist = DEFAULT_LIS $self->{$channel}->{nonword_count} = 0; $self->{$channel}->{invalid_count} = 0; $self->{$channel}->{letters} = {}; + $self->{$channel}->{start_time} = time; foreach my $letter ('A'..'Z') { $self->{$channel}->{letters}->{$letter} = 0; @@ -648,6 +651,10 @@ sub guess_wordle($self, $channel, $guess) { my $guesses = $self->{$channel}->{guess_count}; $guesses = " Correct in $guesses guess" . ($guesses != 1 ? 'es! ' : '! '); + my $duration = concise duration $self->{$channel}->{start_time} - time; + + $guesses .= "($duration) "; + my $nonwords = $self->{$channel}->{nonword_count}; my $invalids = $self->{$channel}->{invalid_count}; diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index 9c4c772e..73e32cfc 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 => 4885, + BUILD_REVISION => 4886, BUILD_DATE => "2025-09-04", };