From 0786ee03a3f52b7cda2bd34bc33bd4a82ec0117b Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sat, 8 Jun 2024 14:24:20 -0700 Subject: [PATCH] applets/wiktionary.pl: show disambiguation when word is not found Requires latest version of https://github.com/pragma-/WiktionaryParser --- applets/wiktionary.pl | 23 ++++++++++++++++++----- lib/PBot/VERSION.pm | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/applets/wiktionary.pl b/applets/wiktionary.pl index f2ed0846..81d1cd85 100755 --- a/applets/wiktionary.pl +++ b/applets/wiktionary.pl @@ -105,11 +105,6 @@ if ($ENV{DEBUG}) { print Dumper($entries), "\n"; } -if (@$entries && ref $entries->[0] ne 'HASH') { - print "No entry for `$term` found in $lang; entries found in ", (join ', ', @$entries), "\n"; - exit; -} - my @valid_sections = qw/definitions etymology pronunciations participle/; if (not grep { $_ eq $section } @valid_sections) { @@ -119,6 +114,24 @@ if (not grep { $_ eq $section } @valid_sections) { my $entries_text = $section; +if (ref $entries eq 'HASH') { + $entries_text =~ s/y$/ies/; + print "No $entries_text for `$term`"; + + if ($entries->{languages}->@*) { + print " in $lang; try ", (join ', ', $entries->{languages}->@*); + } else { + print " found in any languages"; + } + + if ($entries->{disambig}->@*) { + print "; see also: ", (join ', ', $entries->{disambig}->@*); + } + + print "\n"; + exit; +} + my $total_entries_count = @$entries; if ($total_entries_count == 0) { diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index dd8e8c90..7ba4b83e 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,7 +25,7 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4759, + BUILD_REVISION => 4760, BUILD_DATE => "2024-06-08", };