3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-27 06:19:25 +01:00

Fix factoid expansion offset

This commit is contained in:
Pragmatic Software 2018-03-31 14:45:43 -07:00
parent 7087e610c8
commit fe33e3e777

View File

@ -416,6 +416,7 @@ sub expand_factoid_vars {
my $offset = 0; my $offset = 0;
while ($const_action =~ /(\ba\s*|\ban\s*)?(?<!\\)\$([a-zA-Z0-9_:#]+)/gi) { while ($const_action =~ /(\ba\s*|\ban\s*)?(?<!\\)\$([a-zA-Z0-9_:#]+)/gi) {
my ($a, $v) = ($1, $2); my ($a, $v) = ($1, $2);
$a = '' if not defined $a;
$v =~ s/(.):$/$1/; # remove trailing : only if at least one character precedes it $v =~ s/(.):$/$1/; # remove trailing : only if at least one character precedes it
next if $v =~ m/^[\W_]/; # special character prefix skipped for shell/code-factoids/etc next if $v =~ m/^[\W_]/; # special character prefix skipped for shell/code-factoids/etc
next if $v =~ m/^(nick|channel|randomnick|arglen|args|arg\[.+\]|[_0])$/i; # don't override special variables next if $v =~ m/^(nick|channel|randomnick|arglen|args|arg\[.+\]|[_0])$/i; # don't override special variables
@ -489,7 +490,7 @@ sub expand_factoid_vars {
} else { } else {
substr($action, $offset) =~ s/$a\$$v$modifier/$mylist[$line]/; substr($action, $offset) =~ s/$a\$$v$modifier/$mylist[$line]/;
} }
$offset = $+[0]; $offset = $-[0];
} }
} }
last if $matches == 0; last if $matches == 0;