From b58b778648699caf803653c89e34af856388221c Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sun, 3 Nov 2024 12:05:39 -0800 Subject: [PATCH] Applets: execute_applet() returns defined value to end interpreter loop Due to recent changes to support continued processing of empty string command results, ProcessManager::execute_process() now returns undefined value, which causes Interpreter::interpret() to continue looping through registered command interpreters after successfully handling a command. This causes some plugins, i.e. Plugin/Date.pm, to continue the interpret() loop after successfully handling a command, which causes additional interpreters to handle the command, leading to both a built-in command an a factoid command being invoked if they share the same name. Applets::execute_applet() now returns the defined empty string to let the interpreter loop know that the command has been handled. --- lib/PBot/Core/Applets.pm | 7 +++++-- lib/PBot/VERSION.pm | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/PBot/Core/Applets.pm b/lib/PBot/Core/Applets.pm index 3c91169d..78d55698 100644 --- a/lib/PBot/Core/Applets.pm +++ b/lib/PBot/Core/Applets.pm @@ -26,14 +26,17 @@ sub initialize { sub execute_applet($self, $context) { if ($self->{pbot}->{registry}->get_value('general', 'debugcontext')) { use Data::Dumper; - $Data::Dumper::Sortkeys = sub { [sort grep { not /(?:cmdlist|arglist)/ } keys %$context] }; + $Data::Dumper::Sortkeys = 1; $Data::Dumper::Indent = 2; $self->{pbot}->{logger}->log("execute_applet\n"); $self->{pbot}->{logger}->log(Dumper $context); - $Data::Dumper::Sortkeys = 1; } $self->{pbot}->{process_manager}->execute_process($context, sub { $self->launch_applet(@_) }); + + # return defined empty string to tell Interpreter::interpret() that we've + # handled this command so it stops looping through registered interpreters + return ''; } sub launch_applet($self, $context) { diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index a685b215..9e478628 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,8 +25,8 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4827, - BUILD_DATE => "2024-11-02", + BUILD_REVISION => 4828, + BUILD_DATE => "2024-11-03", }; sub initialize {}