mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-29 23:39:24 +01:00
code-factiod symbol name exclusion now more robust
This commit is contained in:
parent
3e2ffe7d61
commit
770e678170
@ -380,8 +380,9 @@ sub expand_factoid_vars {
|
|||||||
my $const_action = $action;
|
my $const_action = $action;
|
||||||
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);
|
||||||
next if $v =~ m/^(nick|channel|randomnick|args|arg\[.+\]):?$/i; # don't override special variables
|
$v =~ s/(.):$/$1/;
|
||||||
next if @exclude && grep { $v =~ m/^$_$/i } @exclude;
|
next if $v =~ m/^(nick|channel|randomnick|args|arg\[.+\])$/i; # don't override special variables
|
||||||
|
next if @exclude && grep { $v =~ m/^\Q$_\E$/i } @exclude;
|
||||||
|
|
||||||
$matches++;
|
$matches++;
|
||||||
|
|
||||||
@ -637,6 +638,8 @@ sub interpreter {
|
|||||||
my $ppi = PPI::Document->new(\$code, readonly => 1);
|
my $ppi = PPI::Document->new(\$code, readonly => 1);
|
||||||
my $vars = $ppi->find(sub { $_[1]->isa('PPI::Token::Symbol') });
|
my $vars = $ppi->find(sub { $_[1]->isa('PPI::Token::Symbol') });
|
||||||
my @names = map { $_->symbol =~ /^[\%\@\$]+(.*)/; $1 } @$vars if $vars;
|
my @names = map { $_->symbol =~ /^[\%\@\$]+(.*)/; $1 } @$vars if $vars;
|
||||||
|
my %uniq = map { $_, 1 } @names;
|
||||||
|
@names = keys %uniq;
|
||||||
|
|
||||||
$code = $self->expand_factoid_vars($from, $code, @names);
|
$code = $self->expand_factoid_vars($from, $code, @names);
|
||||||
$code =~ s/"\$0"/$root_keyword/g;
|
$code =~ s/"\$0"/$root_keyword/g;
|
||||||
|
Loading…
Reference in New Issue
Block a user