mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-30 07:59:42 +01:00
Don't expand $1, $2, etc, as adlibs
This commit is contained in:
parent
7cd174506f
commit
433f381bc9
@ -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");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user