mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-25 21:39:27 +01:00
Interpreter: fix truncated text with multiple nicks
dehighlight_nicks() was being invoked after truncate_result(), therefore inserting \x200b zero-width space Unicode characters AFTER the message was truncated. Solution: moved dehighlight_nicks() to immediately preceding truncate_result().
This commit is contained in:
parent
b7ce503a8d
commit
d9a9ef0cc0
@ -730,6 +730,11 @@ sub handle_result {
|
||||
last;
|
||||
}
|
||||
|
||||
# insert null-width spaces into nicknames to prevent IRC clients
|
||||
# from unncessarily highlighting people
|
||||
$line = $self->dehighlight_nicks($line, $context->{from});
|
||||
|
||||
# truncate if necessary, pasting original result to a web paste site
|
||||
$line = $self->truncate_result($context, $line, $original_result);
|
||||
|
||||
if ($use_output_queue) {
|
||||
@ -806,7 +811,9 @@ sub truncate_result {
|
||||
|
||||
# make room to append the truncation text to the message text
|
||||
# (third argument to truncate_egc is '' to prevent appending its own ellipsis)
|
||||
my $trunc_len = length $text < $max_msg_len ? length $text : $max_msg_len;
|
||||
my $text_len = length $text;
|
||||
my $trunc_len = $text_len < $max_msg_len ? $text_len : $max_msg_len;
|
||||
|
||||
$text = truncate_egc $text, $trunc_len - length $trunc, '';
|
||||
|
||||
# append the truncation text
|
||||
@ -862,12 +869,6 @@ sub output_result {
|
||||
# nothing more to do here if the command came from STDIN
|
||||
return if $context->{from} eq 'stdin@pbot';
|
||||
|
||||
# insert null-width spaces into nicknames to prevent IRC clients
|
||||
# from unncessarily highlighting people
|
||||
if ($context->{from} =~ /^#/ and $output !~ /^\/msg\s+/i) {
|
||||
$output = $self->dehighlight_nicks($output, $context->{from});
|
||||
}
|
||||
|
||||
my $botnick = $self->{pbot}->{registry}->get_value('irc', 'botnick');
|
||||
my $to = $context->{from};
|
||||
|
||||
|
@ -25,8 +25,8 @@ use PBot::Imports;
|
||||
# These are set by the /misc/update_version script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 4365,
|
||||
BUILD_DATE => "2021-08-23",
|
||||
BUILD_REVISION => 4366,
|
||||
BUILD_DATE => "2021-08-24",
|
||||
};
|
||||
|
||||
sub initialize {}
|
||||
|
Loading…
Reference in New Issue
Block a user