3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-23 12:29:27 +01: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; use re::engine::RE2 -strict => 1;
my $action = $factoids->{$channel}->{$trigger}->{action}; my $action = $factoids->{$channel}->{$trigger}->{action};
my $changed; my $changed;
my ($a, $b, $c, $d, $e, $f, $g, $h, $i, $before, $after);
if ($modifier eq 'gi' or $modifier eq 'ig') { if ($modifier eq 'gi' or $modifier eq 'ig') {
$changed = $action =~ s|$tochange|$changeto|gi; $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') { } elsif ($modifier eq 'g') {
$changed = $action =~ s|$tochange|$changeto|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') { } elsif ($modifier eq 'i') {
$changed = $action =~ s|$tochange|$changeto|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 { } else {
$changed = $action =~ s|$tochange|$changeto|; $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) { if (not $changed) {
$self->{pbot}->{logger}->log("($from) $nick!$user\@$host: failed to change '$trigger' 's$delim$tochange$delim$changeto$delim\n"); $self->{pbot}->{logger}->log("($from) $nick!$user\@$host: failed to change '$trigger' 's$delim$tochange$delim$changeto$delim\n");
return "Change $trigger failed."; return "Change $trigger failed.";
} else { } 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/\$1/$a/g;
$action =~ s/\$2/$b/g; $action =~ s/\$2/$b/g;
$action =~ s/\$3/$c/g; $action =~ s/\$3/$c/g;