diff --git a/src/irc_message.rs b/src/irc_message.rs index 2414322..c4cbf1e 100644 --- a/src/irc_message.rs +++ b/src/irc_message.rs @@ -18,4 +18,7 @@ pub enum IrcMessage { nickname: String, message: String, }, + Other { + message: String, + }, } diff --git a/src/main.rs b/src/main.rs index 2fa4acd..2f6e9f6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -160,7 +160,7 @@ impl Application for Cri { .on_privmsg(channel, &source_nickname, content); } - _ => (), + _ => self.message_log.on_other(&message.to_string()), } } UiMessage::InputChanged(text) => self.input_value = text, diff --git a/src/message_log.rs b/src/message_log.rs index 56d3323..bbd7738 100644 --- a/src/message_log.rs +++ b/src/message_log.rs @@ -68,6 +68,12 @@ impl<'a> MessageLog { }) } + pub(crate) fn on_other(&mut self, message: &str) { + self.get_mut(None).push(IrcMessage::Other { + message: message.trim().to_string(), + }) + } + pub fn view(&self, active_channel: &Option) -> Container<'_, crate::UiMessage> { let lighter_grey = Color::new(0.93, 0.94, 0.95, 1.0); let dark_grey = Color::new(0.58, 0.65, 0.65, 1.0); @@ -188,6 +194,7 @@ impl<'a> MessageLog { .into(), ) } + IrcMessage::Other { message } => Some(text(message).into()), } }) .map(|element| element.into())