Broadcast, and FIFO are currently functional.

This commit is contained in:
Micheal Smith
2025-11-14 05:06:57 -06:00
parent 8ec4f2860c
commit 70de039610
8 changed files with 642 additions and 131 deletions

View File

@@ -1,14 +1,32 @@
use irc::proto::{Command, Message};
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize)]
pub struct Event {
from: String,
message: String,
}
impl Event {
pub fn new(msg: impl Into<String>) -> Self {
pub fn new(from: impl Into<String>, msg: impl Into<String>) -> Self {
Self {
from: from.into(),
message: msg.into(),
}
}
}
impl TryFrom<&Message> for Event {
type Error = &'static str;
fn try_from(value: &Message) -> Result<Self, Self::Error> {
let from = value.response_target().unwrap_or("unknown").to_string();
match &value.command {
Command::PRIVMSG(_channel, message) => Ok(Event {
from,
message: message.clone(),
}),
_ => Err("Not a PRIVMSG"),
}
}
}