3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-17 09:29:30 +01:00

Plugin/Wordle: add solved-by to info and guess

This commit is contained in:
Pragmatic Software 2024-10-23 11:59:03 -07:00
parent 7db191e7c2
commit abdb88c7b3
No known key found for this signature in database
GPG Key ID: CC916B6E3C84ECCE
2 changed files with 20 additions and 5 deletions

View File

@ -12,6 +12,7 @@ use parent 'PBot::Plugin::Base';
use PBot::Imports;
use Storable qw(dclone);
use Time::Duration;
use utf8;
sub initialize($self, %conf) {
@ -157,7 +158,14 @@ sub wordle($self, $context) {
return NO_WORDLE;
}
return "Current wordlist: $self->{$channel}->{wordlist} ($self->{$channel}->{length}); guesses attempted: $self->{$channel}->{guess_count}\n";
my $result = "Current wordlist: $self->{$channel}->{wordlist} ($self->{$channel}->{length}); guesses attempted: $self->{$channel}->{guess_count}";
if ($self->{$channel}->{correct}) {
my $solved_on = concise ago (time - $self->{$channel}->{solved_on});
$result .= "; solved by: $self->{$channel}->{solved_by} ($solved_on)";
}
return $result;
}
when ('giveup') {
@ -268,10 +276,17 @@ sub wordle($self, $context) {
}
if ($self->{$channel}->{correct}) {
return "Wordle already solved. " . $self->show_wordle($channel);
return "Wordle already solved by $self->{$channel}->{solved_by}. " . $self->show_wordle($channel);
}
return $self->guess_wordle($channel, $args[0]);
my $result = $self->guess_wordle($channel, $args[0]);
if ($self->{$channel}->{correct}) {
$self->{$channel}->{solved_by} = $context->{nick};
$self->{$channel}->{solved_on} = time;
}
return $result;
}
when ('letters') {

View File

@ -25,8 +25,8 @@ use PBot::Imports;
# These are set by the /misc/update_version script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 4806,
BUILD_DATE => "2024-10-22",
BUILD_REVISION => 4807,
BUILD_DATE => "2024-10-23",
};
sub initialize {}