From 0a00f433355f49a48bc098e622a75b5fb2e30d7c Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Wed, 15 Oct 2025 13:52:36 -0700 Subject: [PATCH] Interpreter: insert reset code in truncation text before URL --- lib/PBot/Core/Interpreter.pm | 9 +++++---- lib/PBot/VERSION.pm | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/PBot/Core/Interpreter.pm b/lib/PBot/Core/Interpreter.pm index 1bab941c..d64251f6 100644 --- a/lib/PBot/Core/Interpreter.pm +++ b/lib/PBot/Core/Interpreter.pm @@ -870,11 +870,12 @@ sub truncate_result($self, $context, $text, $paste_text) { $paste_result //= 'not pasted'; $self->{pbot}->{logger}->log("Message truncated -- $paste_result\n"); - # make room to append the truncation text to the message text + # make room to append the truncation text to the message text and + # append a reset code if formatting was used anywhere in the message # (third argument to truncate_egc is '' to prevent appending its own ellipsis) - my $trunc_len = $text_len < $max_msg_len ? $text_len : $max_msg_len; - - $text = truncate_egc $text, $trunc_len - length $trunc, ''; + my $has_formatting = $text =~ /[\x02\x03\x11\x16\x1D\x1E\x1F]/; + $text = truncate_egc $text, $max_msg_len - $has_formatting - length $trunc, ''; + $text .= "\x0F" if $has_formatting; # append the truncation text $text .= $trunc; diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index 77d35da3..7b1c3b40 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,8 +25,8 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4905, - BUILD_DATE => "2025-10-11", + BUILD_REVISION => 4906, + BUILD_DATE => "2025-10-15", }; sub initialize {}