mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-11 12:32:37 +01:00
Interpreter: clean up nick-dehighlighter
This commit is contained in:
parent
d9aa585949
commit
d4bd248f9d
@ -919,17 +919,16 @@ sub handle_result {
|
|||||||
|
|
||||||
sub dehighlight_nicks {
|
sub dehighlight_nicks {
|
||||||
my ($self, $line, $channel) = @_;
|
my ($self, $line, $channel) = @_;
|
||||||
$channel = lc $channel;
|
return $line if $self->{pbot}->{registry}->get_value('general', 'no_dehighlight_nicks');
|
||||||
my $nicklist = $self->{pbot}->{nicklist}->{nicklist};
|
my @nicks = $self->{pbot}->{nicklist}->get_nicks($channel);
|
||||||
return $line if not exists $nicklist->{$channel};
|
return $line if not @nicks;
|
||||||
my $zwsp = "\x{200b}";
|
foreach my $nick (@nicks) {
|
||||||
foreach my $nick (keys %{$nicklist->{$channel}}) {
|
$nick = quotemeta $nick;
|
||||||
my $n = quotemeta $nicklist->{$channel}->{$nick}->{nick};
|
|
||||||
my $const_line = $line;
|
my $const_line = $line;
|
||||||
while ($const_line =~ m/($n)/gi) {
|
while ($const_line =~ m/(?<![^\W_])($nick)(?![^\W_])/gi) {
|
||||||
my $match = $1;
|
my $match = $1;
|
||||||
$match =~ s/^(.)/$1$zwsp/;
|
$match =~ s/^(.)/$1\x{200b}/;
|
||||||
$line =~ s/$n/$match/i;
|
$line =~ s/$nick/$match/i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $line;
|
return $line;
|
||||||
|
Loading…
Reference in New Issue
Block a user