mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-25 13:29:29 +01:00
Plugin/Wordle: add accented words and German nouns
Accented words will be unidecoded to Latin letters so letter list remains A-Z. German words will include proper nouns since I had no easy way to distinguish them from regular nouns.
This commit is contained in:
parent
348465b034
commit
753773f06b
141447
data/wordle/french
141447
data/wordle/french
File diff suppressed because it is too large
Load Diff
133793
data/wordle/german
133793
data/wordle/german
File diff suppressed because it is too large
Load Diff
3882
data/wordle/italian
3882
data/wordle/italian
File diff suppressed because it is too large
Load Diff
17332
data/wordle/spanish
17332
data/wordle/spanish
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,8 @@ use parent 'PBot::Plugin::Base';
|
|||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
||||||
|
use Text::Unidecode;
|
||||||
|
|
||||||
sub initialize($self, %conf) {
|
sub initialize($self, %conf) {
|
||||||
$self->{pbot}->{commands}->add(
|
$self->{pbot}->{commands}->add(
|
||||||
name => 'wordle',
|
name => 'wordle',
|
||||||
@ -126,15 +128,11 @@ sub wordle($self, $context) {
|
|||||||
return "Usage: wordle custom <word> <channel> [wordlist]";
|
return "Usage: wordle custom <word> <channel> [wordlist]";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $custom_word = $args[0];
|
my $custom_word = unidecode $args[0];
|
||||||
my $custom_channel = $args[1];
|
my $custom_channel = $args[1];
|
||||||
my $custom_wordlist = $args[2];
|
my $custom_wordlist = $args[2];
|
||||||
my $length = length $custom_word;
|
my $length = length $custom_word;
|
||||||
|
|
||||||
if ($custom_word !~ /[a-z]/) {
|
|
||||||
return "Word must be all lowercase and cannot contain numbers or symbols.";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($length < MIN_LENGTH || $length > MAX_LENGTH) {
|
if ($length < MIN_LENGTH || $length > MAX_LENGTH) {
|
||||||
return "Invalid word length; must be >= ".MIN_LENGTH." and <= ".MAX_LENGTH.".";
|
return "Invalid word length; must be >= ".MIN_LENGTH." and <= ".MAX_LENGTH.".";
|
||||||
}
|
}
|
||||||
@ -218,14 +216,13 @@ sub load_words($self, $length, $wordlist = 'default') {
|
|||||||
die "Wordle database `" . $wordlist . "` not available. Set WORDLIST to a valid location of a wordlist file.\n";
|
die "Wordle database `" . $wordlist . "` not available. Set WORDLIST to a valid location of a wordlist file.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
open my $fh, '<', $wordlist or die "Failed to open Wordle database.";
|
open my $fh, '<:encoding(UTF-8)', $wordlist or die "Failed to open Wordle database.";
|
||||||
|
|
||||||
my %words;
|
my %words;
|
||||||
|
|
||||||
while (my $line = <$fh>) {
|
while (my $line = <$fh>) {
|
||||||
chomp $line;
|
chomp $line;
|
||||||
next if $line !~ /^[a-z]+$/;
|
$line = unidecode $line;
|
||||||
|
|
||||||
if (length $line == $length) {
|
if (length $line == $length) {
|
||||||
$words{uc $line} = 1;
|
$words{uc $line} = 1;
|
||||||
}
|
}
|
||||||
@ -270,7 +267,11 @@ sub make_wordle($self, $channel, $length, $word = undef, $wordlist = 'default')
|
|||||||
$self->{$channel}->{guess} .= ' ? ' x $self->{$channel}->{wordle}->@*;
|
$self->{$channel}->{guess} .= ' ? ' x $self->{$channel}->{wordle}->@*;
|
||||||
$self->{$channel}->{guess} .= $color{reset};
|
$self->{$channel}->{guess} .= $color{reset};
|
||||||
|
|
||||||
return $self->show_wordle($channel) . " Guess the word! Legend: $color{invalid}X $color{reset} not in word; $color{present}X$color{present_a}?$color{reset} wrong position; $color{correct}X$color{correct_a}*$color{reset} correct position";
|
my $language = $wordlist;
|
||||||
|
$language = ucfirst $language;
|
||||||
|
$language = 'American' if $language eq 'Default';
|
||||||
|
|
||||||
|
return $self->show_wordle($channel) . " Guess the $language word! Legend: $color{invalid}X $color{reset} not in word; $color{present}X$color{present_a}?$color{reset} wrong position; $color{correct}X$color{correct_a}*$color{reset} correct position";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub show_letters($self, $channel) {
|
sub show_letters($self, $channel) {
|
||||||
@ -304,6 +305,7 @@ sub guess_wordle($self, $channel, $guess) {
|
|||||||
return "The length of your guess does not match length of current Wordle. Try again.";
|
return "The length of your guess does not match length of current Wordle. Try again.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$guess = unidecode $guess;
|
||||||
$guess = uc $guess;
|
$guess = uc $guess;
|
||||||
|
|
||||||
if (not exists $self->{$channel}->{words}->{$guess}) {
|
if (not exists $self->{$channel}->{words}->{$guess}) {
|
||||||
|
@ -25,7 +25,7 @@ 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 => 4719,
|
BUILD_REVISION => 4720,
|
||||||
BUILD_DATE => "2024-03-16",
|
BUILD_DATE => "2024-03-16",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user