fix: only join the initial channel after registration is complete

During registration, only a subset of commands are allowed.
Servers MUST send a RPL_WELCOME (001) after registration is complete so
we join the channel in response to that numeric reply.

https://modern.ircdocs.horse/#connection-registration
This commit is contained in:
2025-08-15 22:18:55 +02:00
parent 1d10198d37
commit 026021c118
3 changed files with 11 additions and 5 deletions
+7 -1
View File
@@ -371,9 +371,15 @@ func handleWELCOME(msg irc.Message, client *irc.Client) {
AsServerMsg: true,
}
// set server-registered nickname
// set server-registered nickname because the server MAY return a different nickname than
// the one the user chose because of length restrictions or otherwise.
client.Nickname = nick
client.Channels[0].AppendMsg(msg.Timestamp, welcomeMsg, msgOpts)
// Only join the user-requested channel AFTER registration is complete.
if client.InitialChannel != "" {
client.SendCommand(commands.JOIN, client.InitialChannel)
}
}
func handleYOURHOST(msg irc.Message, client *irc.Client) {