From e1dadab9b9438ef3bd57e4c3164d3c6e01d78928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20H=C3=A4cker?= Date: Fri, 3 Nov 2023 21:57:27 +0100 Subject: [PATCH] news: Properly take care of unicode string splitting --- .gitignore | 1 + src/bot.rs | 1 - src/news.rs | 10 +++++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 59b0bd9..95302a1 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ de.haeckerfelix.Hebbot.json /project_template.md ./section_template.md /section_template.md +.flatpak-builder \ No newline at end of file diff --git a/src/bot.rs b/src/bot.rs index 4402364..1e456f4 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -586,7 +586,6 @@ impl Bot { let message = { let is_editor = self.is_editor(member).await; let mut news_store = self.news_store.lock().unwrap(); - let redacted_event_id = redacted_event_id; let link = self.message_link(redacted_event_id); // Redaction / deletion of the news entry itself diff --git a/src/news.rs b/src/news.rs index 3b81671..df475b1 100644 --- a/src/news.rs +++ b/src/news.rs @@ -47,7 +47,15 @@ impl News { pub fn message_summary(&self) -> String { if self.message.borrow().len() > 60 { - format!("{} …", self.message.borrow().clone().split_at(50).0) + format!( + "{} …", + self.message + .borrow() + .clone() + .chars() + .take(50) + .collect::() + ) } else { self.message.borrow().clone() }