mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-11 12:32:37 +01:00
Plugins/TypoSub: be more intelligent about replacing \1 and $1 thingies
This commit is contained in:
parent
4d0f477140
commit
0835342246
@ -74,15 +74,23 @@ sub on_public {
|
|||||||
else { $result = "$nick thinks $target meant to say: "; }
|
else { $result = "$nick thinks $target meant to say: "; }
|
||||||
my $text = $message->{msg};
|
my $text = $message->{msg};
|
||||||
if ($modifiers =~ m/g/) {
|
if ($modifiers =~ m/g/) {
|
||||||
$text =~ s/$rx/$replacement/g;
|
$text =~ s{$rx}
|
||||||
my @stuff = ($1, $2, $3, $4, $5, $6, $7, $8, $9);
|
{
|
||||||
my $i;
|
my @stuff = ($1, $2, $3, $4, $5, $6, $7, $8, $9);
|
||||||
map { ++$i; $text =~ s/[\$\\]$i/$_/g; } @stuff;
|
my $t = $replacement;
|
||||||
|
my $i = 0;
|
||||||
|
defined $_ // last, ++$i, $t =~ s|[\$\\]$i|$_|g for @stuff;
|
||||||
|
$t
|
||||||
|
}gxe;
|
||||||
} else {
|
} else {
|
||||||
$text =~ s/$rx/$replacement/;
|
$text =~ s{$rx}
|
||||||
my @stuff = ($1, $2, $3, $4, $5, $6, $7, $8, $9);
|
{
|
||||||
my $i;
|
my $i = 0;
|
||||||
map { ++$i; $text =~ s/[\$\\]$i/$_/g; } @stuff;
|
my @stuff = ($1, $2, $3, $4, $5, $6, $7, $8, $9);
|
||||||
|
my $t = $replacement;
|
||||||
|
defined $_ // last, ++$i, $t =~ s|[\$\\]$i|$_|g for @stuff;
|
||||||
|
$t
|
||||||
|
}xe;
|
||||||
}
|
}
|
||||||
$event->{conn}->privmsg($channel, "$result$text");
|
$event->{conn}->privmsg($channel, "$result$text");
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user