3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-17 09:29:30 +01:00

Factoid/Variables: minor refactor, no semantic changes

This commit is contained in:
Pragmatic Software 2024-11-02 17:58:14 -07:00
parent c6f6823df9
commit 73c4ed465d
No known key found for this signature in database
GPG Key ID: CC916B6E3C84ECCE
2 changed files with 10 additions and 11 deletions

View File

@ -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/;

View File

@ -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",
};