From 85c2c0f4a08d55fc0fed07fae2a7af8a9b4c87fa Mon Sep 17 00:00:00 2001 From: Kevin Boos Date: Fri, 12 Apr 2024 11:19:00 -0700 Subject: [PATCH] Support `/html` and `/plain` commands to explicitly send HTML and plaintext messages --- src/home/room_screen.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/home/room_screen.rs b/src/home/room_screen.rs index 0d2fcf05..bf7321d0 100644 --- a/src/home/room_screen.rs +++ b/src/home/room_screen.rs @@ -564,9 +564,16 @@ impl Widget for RoomScreen { if !entered_text.is_empty() { let room_id = self.room_id.clone().unwrap(); log!("Sending message to room {}: {:?}", room_id, entered_text); + let message = if let Some(html_text) = entered_text.strip_prefix("/html") { + RoomMessageEventContent::text_html(html_text, html_text) + } else if let Some(plain_text) = entered_text.strip_prefix("/plain") { + RoomMessageEventContent::text_plain(plain_text) + } else { + RoomMessageEventContent::text_markdown(entered_text) + }; submit_async_request(MatrixRequest::SendMessage { room_id, - message: RoomMessageEventContent::text_markdown(entered_text), + message, // TODO: support replies to specific messages, attaching mentions, rich text (html), etc. }); }