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

Expand factoid variables sooner so argument processing occurs on expanded action

This commit is contained in:
Pragmatic Software 2015-09-14 09:06:00 -07:00
parent d3944d82d9
commit ecaa45b3dc

View File

@ -561,6 +561,8 @@ sub interpreter {
my $action = $self->{factoids}->hash->{$channel}->{$keyword}->{action};
$action = $self->expand_factoid_vars($from, $action);
if(length $arguments) {
if(exists $self->{factoids}->hash->{$channel}->{$keyword}->{action_with_args}) {
$action = $self->{factoids}->hash->{$channel}->{$keyword}->{action_with_args};
@ -634,17 +636,15 @@ sub interpreter {
return undef if $arguments =~ m/\$(?:nick|arg)/;
}
$action =~ s/\$nick/$nick/g;
$action =~ s/\$channel/$from/g;
$action =~ s/\$randomnick/my $random = $self->{pbot}->{nicklist}->random_nick($from); $random ? $random : $nick/ge;
$action = $self->expand_factoid_vars($from, $action);
if($self->{factoids}->hash->{$channel}->{$keyword}->{enabled} == 0) {
$self->{pbot}->{logger}->log("$keyword disabled.\n");
return "/msg $nick $ref_from$keyword is currently disabled.";
}
$action =~ s/\$nick/$nick/g;
$action =~ s/\$channel/$from/g;
$action =~ s/\$randomnick/my $random = $self->{pbot}->{nicklist}->random_nick($from); $random ? $random : $nick/ge;
if($self->{factoids}->hash->{$channel}->{$keyword}->{type} eq 'module') {
my $preserve_whitespace = $self->{factoids}->hash->{$channel}->{$keyword}->{preserve_whitespace};
$preserve_whitespace = 0 if not defined $preserve_whitespace;