Skip to content

Commit

Permalink
Support /html and /plain commands to explicitly send HTML and pla…
Browse files Browse the repository at this point in the history
…intext messages (#67)
  • Loading branch information
kevinaboos authored Apr 12, 2024
1 parent 67f932b commit 91be1c5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/home/room_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
});
}
Expand Down

0 comments on commit 91be1c5

Please sign in to comment.