From b36968ce6116b5ffa5c90fee0489cf2144ad95c6 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Tue, 29 Jun 2021 09:00:27 -0700 Subject: [PATCH] Interpreter: via /msg, restore trigger to command if stripped trigger produces empty command --- PBot/Interpreter.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/PBot/Interpreter.pm b/PBot/Interpreter.pm index 6e8798c0..e32fd701 100644 --- a/PBot/Interpreter.pm +++ b/PBot/Interpreter.pm @@ -112,6 +112,17 @@ sub process_line { if ($is_command) { $command = $cmd_text; $command =~ s/^$bot_trigger//; # strip leading bot trigger, if any + + # restore command if stripping bot trigger makes command empty + # (they wanted to invoke a command named after the trigger itself) + # TODO: this could potentially be confusing when trying to invoke + # commands that are sequential instances of the bot trigger, e.g. + # attempting to invoke a factoid named `...` while the bot trigger + # is `.` could now prove confusing via /msg or stdin. Might need + # to rethink this and just require bot trigger all the time ... + # but for now let's see how this goes and if people can figure it + # out with minimal confusion. + $command = $cmd_text if not length $command; goto CHECK_EMBEDDED_CMD; }