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

Plugin/Wordle: add info command; minor tweak to start error-handling

This commit is contained in:
Pragmatic Software 2024-10-15 11:54:32 -07:00
parent d29a60978e
commit 71a4c4c331
No known key found for this signature in database
GPG Key ID: CC916B6E3C84ECCE
2 changed files with 15 additions and 7 deletions

View File

@ -29,7 +29,7 @@ sub unload($self) {
} }
use constant { use constant {
USAGE => 'Usage: wordle start [length [wordlist]] | custom <word> <channel> [wordlist] | guess <word> | letters | show | giveup', USAGE => 'Usage: wordle start [length [wordlist]] | custom <word> <channel> [wordlist] | guess <word> | letters | show | info | giveup',
NO_WORDLE => 'There is no Wordle yet. Use `wordle start` to begin a game.', NO_WORDLE => 'There is no Wordle yet. Use `wordle start` to begin a game.',
DEFAULT_LIST => 'american', DEFAULT_LIST => 'american',
@ -152,6 +152,14 @@ sub wordle($self, $context) {
return $self->show_wordle($channel, 1); return $self->show_wordle($channel, 1);
} }
when ('info') {
if (not defined $self->{$channel}->{wordle}) {
return NO_WORDLE;
}
return "Current wordlist: $self->{$channel}->{wordlist} ($self->{$channel}->{length}); guesses attempted: $self->{$channel}->{guess_count}\n";
}
when ('giveup') { when ('giveup') {
if (not defined $self->{$channel}->{wordle}) { if (not defined $self->{$channel}->{wordle}) {
return NO_WORDLE; return NO_WORDLE;
@ -168,10 +176,6 @@ sub wordle($self, $context) {
return "Invalid arguments; Usage: wordle start [word length [wordlist]]"; return "Invalid arguments; Usage: wordle start [word length [wordlist]]";
} }
if (defined $self->{$channel}->{wordle} && $self->{$channel}->{correct} == 0) {
return "There is already a Wordle underway! Use `wordle show` to see the current progress or `wordle giveup` to end it.";
}
my $length = DEFAULT_LENGTH; my $length = DEFAULT_LENGTH;
my $wordlist = $args[1] // DEFAULT_LIST; my $wordlist = $args[1] // DEFAULT_LIST;
@ -191,6 +195,10 @@ sub wordle($self, $context) {
$length = $args[0]; $length = $args[0];
} }
if (defined $self->{$channel}->{wordle} && $self->{$channel}->{correct} == 0) {
return "There is already a Wordle underway! Use `wordle show` to see the current progress or `wordle giveup` to end it.";
}
return $self->make_wordle($channel, $length, undef, $wordlist); return $self->make_wordle($channel, $length, undef, $wordlist);
} }

View File

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