diff --git a/lib/PBot/Core/Factoids/Variables.pm b/lib/PBot/Core/Factoids/Variables.pm index ad491156..11d859ef 100644 --- a/lib/PBot/Core/Factoids/Variables.pm +++ b/lib/PBot/Core/Factoids/Variables.pm @@ -217,6 +217,7 @@ sub expand_action_arguments($self, $action, $input, $nick) { my %h; if (not defined $input or $input eq '') { + $input = ''; %h = (args => $nick); } else { %h = (args => $input); @@ -226,18 +227,16 @@ sub expand_action_arguments($self, $action, $input, $nick) { $jsonargs =~ s/^{".*":"//; $jsonargs =~ s/"}$//; - if (not defined $input or $input eq '') { - $input = ""; - $action =~ s/\$args:json|\$\{args:json\}/$jsonargs/ge; - $action =~ s/\$args(?![[\w])|\$\{args(?![[\w])\}/$nick/g; - } else { - $action =~ s/\$args:json|\$\{args:json\}/$jsonargs/g; - $action =~ s/\$args(?![[\w])|\$\{args(?![[\w])\}/$input/g; - } - my @args = $self->{pbot}->{interpreter}->split_line($input); $action =~ s/\$arglen\b|\$\{arglen\}/scalar @args/eg; + $action =~ s/\$args:json|\$\{args:json\}/$jsonargs/g; + + if ($input eq '') { + $action =~ s/\$p?args(?![[\w])|\$\{p?args(?![[\w])\}/$nick/g; + } else { + $action =~ s/\$args(?![[\w])|\$\{args(?![[\w])\}/$input/g; + } my $depth = 0; my $const_action = $action; @@ -248,7 +247,7 @@ sub expand_action_arguments($self, $action, $input, $nick) { last if ++$depth >= 100; if ($arg eq '*') { - if (not defined $input or $input eq '') { + if ($input eq '') { $action =~ s/\$arg\[\*\]|\$\{arg\[\*\]\}/$nick/; } else { $action =~ s/\$arg\[\*\]|\$\{arg\[\*\]\}/$input/; diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index feb9af05..345d4d9f 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 => 4822, + BUILD_REVISION => 4823, BUILD_DATE => "2024-11-02", };