3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-01 17:16:39 +02:00

Interpreter: simplify dehighlight_nicks() a bit

This commit is contained in:
Pragmatic Software 2020-03-24 15:53:21 -07:00
parent b915b7c489
commit 5f741ba69d

View File

@ -875,20 +875,15 @@ sub handle_result {
sub dehighlight_nicks {
my ($self, $line, $channel) = @_;
return $line if $self->{pbot}->{registry}->get_value('general', 'no_dehighlight_nicks');
my @nicks = $self->{pbot}->{nicklist}->get_nicks($channel);
return $line if not @nicks;
my %nick_table = map { $_ => 1 } @nicks;
my @tokens = split / /, $line;
foreach my $token (@tokens) {
my $potential_nick = $token;
$potential_nick =~ s/^[^\w\[\]\<\>\-\\\^\{\}]+//;
$potential_nick =~ s/[^\w\[\]\<\>\-\\\^\{\}]+$//;
next if length $potential_nick == 1;
next if not $nick_table{$potential_nick};
next if not $self->{pbot}->{nicklist}->is_present($channel, $potential_nick);
my $dehighlighted_nick = $potential_nick;
$dehighlighted_nick =~ s/(.)/$1\x{200b}/;