fix: improve body truncation for Discord messages to respect character boundaries
This commit is contained in:
parent
76d77d897c
commit
19be697f86
1 changed files with 5 additions and 1 deletions
|
|
@ -89,7 +89,11 @@ fn run_monitor(config: &Config) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|
||||||
// Truncate body if too long for Discord (limit is 2000 chars)
|
// Truncate body if too long for Discord (limit is 2000 chars)
|
||||||
let display_body = if body_content.len() > 1500 {
|
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 {
|
} else {
|
||||||
body_content
|
body_content
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue