mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-20 10:59:29 +01:00
Repeatedly expand factoid variables for sub-expansions
This commit is contained in:
parent
51019a17ab
commit
6e0456940b
@ -367,10 +367,17 @@ sub find_factoid {
|
|||||||
sub expand_factoid_vars {
|
sub expand_factoid_vars {
|
||||||
my ($self, $from, $action) = @_;
|
my ($self, $from, $action) = @_;
|
||||||
|
|
||||||
while ($action =~ /(?<!\\)\$([a-zA-Z0-9_:\-#]+)/g) {
|
my $depth = 0;
|
||||||
|
while (1) {
|
||||||
|
last if ++$depth >= 10;
|
||||||
|
my $matches = 0;
|
||||||
|
my $const_action = $action;
|
||||||
|
while ($const_action =~ /(?<!\\)\$([a-zA-Z0-9_:\-#]+)/g) {
|
||||||
my $v = $1;
|
my $v = $1;
|
||||||
next if $v =~ m/^(nick|channel|randomnick|args|arg\[.+\])$/; # don't override special variables
|
next if $v =~ m/^(nick|channel|randomnick|args|arg\[.+\])$/; # don't override special variables
|
||||||
|
|
||||||
|
$matches++;
|
||||||
|
|
||||||
my $modifier = '';
|
my $modifier = '';
|
||||||
if ($v =~ s/(:.*)$//) {
|
if ($v =~ s/(:.*)$//) {
|
||||||
$modifier = $1;
|
$modifier = $1;
|
||||||
@ -416,9 +423,10 @@ sub expand_factoid_vars {
|
|||||||
$action =~ s/\$$var$modifier/$mylist[$line]/;
|
$action =~ s/\$$var$modifier/$mylist[$line]/;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
last if $matches == 0;
|
||||||
|
}
|
||||||
|
|
||||||
$action =~ s/\\\$/\$/g;
|
$action =~ s/\\\$/\$/g;
|
||||||
|
|
||||||
return $action;
|
return $action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user