3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-06 11:28:43 +02:00

Don't expand $1, $2, etc, as adlibs

This commit is contained in:
Pragmatic Software 2015-04-03 10:40:48 -07:00
parent 7cd174506f
commit 433f381bc9

View File

@ -479,26 +479,22 @@ sub interpreter {
$action =~ s/\$channel/$from/g; $action =~ s/\$channel/$from/g;
while ($action =~ /[^\\]\$([a-zA-Z0-9_\-]+)/g) { while ($action =~ /[^\\]\$([a-zA-Z0-9_\-]+)/g) {
#$self->{pbot}->{logger}->log("adlib: looking for [$1]\n"); my $v = $1;
#$self->{pbot}->{logger}->log("calling find_factoid in Factoids.pm, interpreter() to look for adlib"); next if $v =~ m/^[0-9]+$/;
my ($var_chan, $var) = $self->find_factoid($from, $1, undef, 0, 1); my ($var_chan, $var) = $self->find_factoid($from, $v, undef, 0, 1);
if(defined $var && $self->{factoids}->hash->{$var_chan}->{$var}->{type} eq 'text') { if(defined $var && $self->{factoids}->hash->{$var_chan}->{$var}->{type} eq 'text') {
my $change = $self->{factoids}->hash->{$var_chan}->{$var}->{action}; my $change = $self->{factoids}->hash->{$var_chan}->{$var}->{action};
my @list = split(/\s|(".*?")/, $change); my @list = split(/\s|(".*?")/, $change);
my @mylist; my @mylist;
#$self->{pbot}->{logger}->log("adlib: list [". join(':', @mylist) ."]\n");
for(my $i = 0; $i <= $#list; $i++) { for(my $i = 0; $i <= $#list; $i++) {
#$self->{pbot}->{logger}->log("adlib: pushing $i $list[$i]\n");
push @mylist, $list[$i] if $list[$i]; push @mylist, $list[$i] if $list[$i];
} }
my $line = int(rand($#mylist + 1)); my $line = int(rand($#mylist + 1));
$mylist[$line] =~ s/"//g; $mylist[$line] =~ s/"//g;
$action =~ s/\$$var/$mylist[$line]/; $action =~ s/\$$var/$mylist[$line]/;
#$self->{pbot}->{logger}->log("adlib: found: change: $action\n");
} else { } else {
$action =~ s/\$$var/$var/g; $action =~ s/\$$var/$var/g;
#$self->{pbot}->{logger}->log("adlib: not found: change: $action\n");
} }
} }