3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-22 11:59:43 +01:00

Plugin/WordMorph: add check command to check if a word exists

This commit is contained in:
Pragmatic Software 2022-09-06 08:02:07 -07:00
parent adaf4e2ed3
commit 0196e61b72
2 changed files with 17 additions and 3 deletions

View File

@ -35,7 +35,7 @@ sub unload {
} }
use constant { use constant {
USAGE => 'Usage: wordmorph start [steps to solve [word length]] | custom <word1> <word2> | solve <solution> | show | hint [from direction] | giveup', USAGE => 'Usage: wordmorph start [steps to solve [word length]] | custom <word1> <word2> | solve <solution> | hint [from direction] | check <word> | show | giveup',
NO_MORPH_AVAILABLE => "There is no word morph available. Use `wordmorph start [steps to solve [word length]]` to create one.", NO_MORPH_AVAILABLE => "There is no word morph available. Use `wordmorph start [steps to solve [word length]]` to create one.",
DB_UNAVAILABLE => "Word morph database not available.", DB_UNAVAILABLE => "Word morph database not available.",
LEFT => 0, LEFT => 0,
@ -56,6 +56,20 @@ sub wordmorph {
my $channel = $context->{from}; my $channel = $context->{from};
given ($command) { given ($command) {
when ('check') {
if (!@args || @args > 1) {
return 'Usage: wordmorph check <word>; check if a word exists in the Word Morph database';
}
return DB_UNAVAILABLE if not $self->{db};
if (not exists $self->{db}->{length $args[0]}->{$args[0]}) {
return "I do not know this word `$args[0]`.";
} else {
return "Yes, `$args[0]` is a word I know.";
}
}
when ('hint') { when ('hint') {
if (not defined $self->{$channel}->{morph}) { if (not defined $self->{$channel}->{morph}) {
return NO_MORPH_AVAILABLE; return NO_MORPH_AVAILABLE;

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 => 4581, BUILD_REVISION => 4582,
BUILD_DATE => "2022-09-04", BUILD_DATE => "2022-09-06",
}; };
sub initialize {} sub initialize {}