mirror of
https://github.com/pragma-/pbot.git
synced 2025-03-30 04:17:12 +02:00
Interpreter: fix-up a/an article in front of &{cmdsub}s
This commit is contained in:
parent
68490b6ac5
commit
b638757f92
@ -15,6 +15,7 @@ use parent 'PBot::Core::Class', 'PBot::Core::Registerable';
|
||||
use PBot::Imports;
|
||||
|
||||
use PBot::Core::MessageHistory::Constants ':all';
|
||||
use PBot::Core::Utils::Indefinite;
|
||||
use PBot::Core::Utils::ValidateString;
|
||||
|
||||
use Encode;
|
||||
@ -593,9 +594,25 @@ sub handle_result {
|
||||
if (exists $context->{subcmd}) {
|
||||
my $command = pop @{$context->{subcmd}};
|
||||
|
||||
if (@{$context->{subcmd}} == 0 or $context->{alldone}) { delete $context->{subcmd}; }
|
||||
if (@{$context->{subcmd}} == 0 or $context->{alldone}) {
|
||||
delete $context->{subcmd};
|
||||
}
|
||||
|
||||
if ($command =~ s/\b(an?)(\s+)&\{subcmd\}/&{subcmd}/i) {
|
||||
# fix-up a/an article
|
||||
my ($article, $spaces) = ($1, $2);
|
||||
my $fixed_article = select_indefinite_article $result;
|
||||
|
||||
if ($article eq 'AN') {
|
||||
$fixed_article = uc $fixed_article;
|
||||
} elsif ($article eq 'An' or $article eq 'A') {
|
||||
$fixed_article = ucfirst $fixed_article;
|
||||
}
|
||||
|
||||
$command =~ s/&\{subcmd\}/$fixed_article$spaces$result/;
|
||||
} else {
|
||||
$command =~ s/&\{subcmd\}/$result/;
|
||||
}
|
||||
|
||||
if (not $context->{alldone}) {
|
||||
$context->{command} = $command;
|
||||
|
Loading…
x
Reference in New Issue
Block a user