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

Fix captures in factchange regex

This commit is contained in:
Pragmatic Software 2017-09-29 12:40:40 -07:00
parent 492ee7b6a4
commit e1db291c35

View File

@ -1299,22 +1299,27 @@ sub factchange {
use re::engine::RE2 -strict => 1;
my $action = $factoids->{$channel}->{$trigger}->{action};
my $changed;
my ($a, $b, $c, $d, $e, $f, $g, $h, $i, $before, $after);
if ($modifier eq 'gi' or $modifier eq 'ig') {
$changed = $action =~ s|$tochange|$changeto|gi;
($a, $b, $c, $d, $e, $f, $g, $h, $i, $before, $after) = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $`, $');
} elsif ($modifier eq 'g') {
$changed = $action =~ s|$tochange|$changeto|g;
($a, $b, $c, $d, $e, $f, $g, $h, $i, $before, $after) = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $`, $');
} elsif ($modifier eq 'i') {
$changed = $action =~ s|$tochange|$changeto|i;
($a, $b, $c, $d, $e, $f, $g, $h, $i, $before, $after) = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $`, $');
} else {
$changed = $action =~ s|$tochange|$changeto|;
($a, $b, $c, $d, $e, $f, $g, $h, $i, $before, $after) = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $`, $');
}
if (not $changed) {
$self->{pbot}->{logger}->log("($from) $nick!$user\@$host: failed to change '$trigger' 's$delim$tochange$delim$changeto$delim\n");
return "Change $trigger failed.";
} else {
my ($a, $b, $c, $d, $e, $f, $g, $h, $i, $before, $after) = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $`, $');
$action =~ s/\$1/$a/g;
$action =~ s/\$2/$b/g;
$action =~ s/\$3/$c/g;