diff --git a/src/projections/irc/mod.rs b/src/projections/irc/mod.rs index 6c36716..fc490fd 100644 --- a/src/projections/irc/mod.rs +++ b/src/projections/irc/mod.rs @@ -528,7 +528,17 @@ async fn handle_incoming_message( .await?; writer.flush().await?; } else { - // TODO send 502 (not 401) if the user is not the sender + ServerMessage { + tags: vec![], + sender: Some(config.server_name.clone()), + body: ServerMessageBody::N502UsersDontMatch { + client: user.nickname.clone(), + message: "Cant change mode for other users".into(), + }, + } + .write_async(writer) + .await?; + writer.flush().await?; } } Recipient::Chan(_) => { diff --git a/src/protos/irc/server.rs b/src/protos/irc/server.rs index 16b5804..b2efcd4 100644 --- a/src/protos/irc/server.rs +++ b/src/protos/irc/server.rs @@ -132,6 +132,10 @@ pub enum ServerMessageBody { chan: Chan, message: Str, }, + N502UsersDontMatch { + client: Str, + message: Str, + }, } impl ServerMessageBody { @@ -301,6 +305,13 @@ impl ServerMessageBody { writer.write_all(b" :").await?; writer.write_all(message.as_bytes()).await?; } + ServerMessageBody::N502UsersDontMatch { client, message } => { + writer.write_all(b"502 ").await?; + writer.write_all(client.as_bytes()).await?; + writer.write_all(b" ").await?; + writer.write_all(b" :").await?; + writer.write_all(message.as_bytes()).await?; + } } Ok(()) }