3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-25 04:02:37 +01:00

Correct $tonick/$nick behavior in factiod interpolation

This commit is contained in:
Pragmatic Software 2017-09-05 17:22:47 -07:00
parent 9a082ede38
commit 8f9875cf18

View File

@ -566,7 +566,7 @@ sub execute_code_factoid {
@names = keys %uniq; @names = keys %uniq;
unless ($self->{factoids}->hash->{$chan}->{$keyword}->{interpolate} eq '0') { unless ($self->{factoids}->hash->{$chan}->{$keyword}->{interpolate} eq '0') {
$code = $self->expand_factoid_vars($from, $tonick ? $tonick : $nick, $root_keyword, $code, @names); $code = $self->expand_factoid_vars($from, $nick, $root_keyword, $code, @names);
} }
my %signals = %SIG; my %signals = %SIG;
@ -596,7 +596,7 @@ sub execute_code_factoid {
} }
local our @args = $self->{pbot}->{commands}->parse_arguments($arguments); local our @args = $self->{pbot}->{commands}->parse_arguments($arguments);
local our $nick = defined $tonick ? $tonick : $nick; local our $nick = $nick;
local our $channel = $from; local our $channel = $from;
@args = ($nick) if not @args; @args = ($nick) if not @args;
@ -631,8 +631,8 @@ sub execute_code_factoid {
alarm 1; alarm 1;
unless ($self->{factoids}->hash->{$chan}->{$keyword}->{interpolate} eq '0') { unless ($self->{factoids}->hash->{$chan}->{$keyword}->{interpolate} eq '0') {
$action = $self->expand_factoid_vars($from, $tonick ? $tonick : $nick, $root_keyword, $action); $action = $self->expand_factoid_vars($from, $nick, $root_keyword, $action);
$action = $self->expand_action_arguments($action, $arguments, $tonick ? $tonick : $nick); $action = $self->expand_action_arguments($action, $arguments, $nick);
} else { } else {
$action = validate_string($action); $action = validate_string($action);
} }
@ -763,13 +763,13 @@ sub interpreter {
return "" if not length $action; return "" if not length $action;
unless ($self->{factoids}->hash->{$channel}->{$keyword}->{interpolate} eq '0') { unless ($self->{factoids}->hash->{$channel}->{$keyword}->{interpolate} eq '0') {
$action = $self->expand_factoid_vars($from, $tonick ? $tonick : $nick, $root_keyword, $action); $action = $self->expand_factoid_vars($from, $nick, $root_keyword, $action);
} }
if (length $arguments) { if (length $arguments) {
if ($action =~ m/\$args/ or $action =~ m/\$arg\[/) { if ($action =~ m/\$args/ or $action =~ m/\$arg\[/) {
unless ($self->{factoids}->hash->{$channel}->{$keyword}->{interpolate} eq '0') { unless ($self->{factoids}->hash->{$channel}->{$keyword}->{interpolate} eq '0') {
$action = $self->expand_action_arguments($action, $arguments, defined $tonick ? $tonick : $nick); $action = $self->expand_action_arguments($action, $arguments, $nick);
} }
$arguments = ""; $arguments = "";
} else { } else {
@ -792,21 +792,17 @@ sub interpreter {
$action =~ s/^\/say /\/say $target: /; $action =~ s/^\/say /\/say $target: /;
} }
} }
} else {
if ($action !~ m/^\/.+ /) {
$action =~ s/^/\/say $keyword is / unless defined $tonick;
}
} }
} }
} }
} else { } else {
# no arguments supplied, replace $args with $nick/$tonick, etc # no arguments supplied, replace $args with $nick/$tonick, etc
$action = $self->expand_action_arguments($action, undef, $tonick ? $tonick : $nick); $action = $self->expand_action_arguments($action, undef, $nick);
} }
# Check if it's an alias # Check if it's an alias
if($action =~ /^\/call\s+(.*)$/) { if($action =~ /^\/call\s+(.*)$/) {
my $command = $self->expand_factoid_vars($from, $tonick ? $tonick : $nick, $root_keyword, $1); my $command = $self->expand_factoid_vars($from, $nick, $root_keyword, $1);
if(length $arguments) { if(length $arguments) {
$command .= " $arguments"; $command .= " $arguments";
} }
@ -842,8 +838,8 @@ sub interpreter {
} }
unless ($self->{factoids}->hash->{$channel}->{$keyword}->{interpolate} eq '0') { unless ($self->{factoids}->hash->{$channel}->{$keyword}->{interpolate} eq '0') {
$action = $self->expand_factoid_vars($from, $tonick ? $tonick : $nick, $root_keyword, $action); $action = $self->expand_factoid_vars($from, $nick, $root_keyword, $action);
$action = $self->expand_action_arguments($action, $arguments, $tonick ? $tonick : $nick); $action = $self->expand_action_arguments($action, $arguments, $nick);
} }
if($self->{factoids}->hash->{$channel}->{$keyword}->{type} eq 'module') { if($self->{factoids}->hash->{$channel}->{$keyword}->{type} eq 'module') {