mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-06 03:59:31 +01:00
Plugin/WordMorph: add check
command to check if a word exists
This commit is contained in:
parent
adaf4e2ed3
commit
0196e61b72
@ -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;
|
||||||
|
@ -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 {}
|
||||||
|
Loading…
Reference in New Issue
Block a user