only log once per message

This commit is contained in:
Yash Karandikar 2021-12-24 21:50:02 -06:00
parent 422f640c61
commit e5c8b122b3
Signed by: karx
GPG key ID: A794DA2529474BA5

View file

@ -10,9 +10,6 @@ use tokio::{
};
use uuid::Uuid;
// TODO:
// * track nicknames
#[derive(Clone, Debug)]
enum BroadcastMessage {
MSG(String, String, String),
@ -95,6 +92,8 @@ async fn connection_handler(
(prefix, parts)
};
tracing::info!("sender: {}, prefix: {}, arguments: {:#?}", nick, prefix, arguments.join(" "));
match prefix.as_str() {
"MSG" => {
if arguments.len() < 1 {
@ -146,13 +145,11 @@ async fn connection_handler(
match msg {
BroadcastMessage::MSG(nick, msg, sender) => {
if sender != id {
tracing::info!("{}: {:?}", nick, msg);
tx.write_all(format!("{} MSG {}\n", nick, msg).as_bytes()).await?;
}
},
BroadcastMessage::NICK(old_nick, new_nick, sender) => {
if sender != id {
tracing::info!("{} changed to {}", old_nick, new_nick);
tx.write_all(format!("{} NICK {}\n", old_nick, new_nick).as_bytes()).await?;
}
},
@ -178,7 +175,6 @@ async fn connection_handler(
ClientMessage::LIST(list) => {
let names = list.join(" ");
tracing::info!("LIST: {}", names);
tx.write_all(format!("LIST {}\n", names).as_bytes()).await?;
}
}