From 19be697f868a95cf0a48d44bd36a2365ea9e3d1a Mon Sep 17 00:00:00 2001 From: imnyang Date: Tue, 3 Feb 2026 14:03:50 +0900 Subject: [PATCH] fix: improve body truncation for Discord messages to respect character boundaries --- src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e2d42e0..eb392a3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -89,7 +89,11 @@ fn run_monitor(config: &Config) -> Result<(), Box> { // Truncate body if too long for Discord (limit is 2000 chars) let display_body = if body_content.len() > 1500 { - format!("{}...", &body_content[..1500]) + let mut end = 1500; + while !body_content.is_char_boundary(end) { + end -= 1; + } + format!("{}...", &body_content[..end]) } else { body_content };