mirror of
https://github.com/IllusionMan1212/gorc.git
synced 2026-10-24 02:12:33 +00:00
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:
+3
-4
@@ -84,6 +84,9 @@ type Client struct {
|
|||||||
// Active channel index
|
// Active channel index
|
||||||
ActiveChannelIndex int
|
ActiveChannelIndex int
|
||||||
|
|
||||||
|
// The channel to join immediately after registration completes.
|
||||||
|
InitialChannel string
|
||||||
|
|
||||||
// Reference to the bubbletea program
|
// Reference to the bubbletea program
|
||||||
Tea *tea.Program
|
Tea *tea.Program
|
||||||
|
|
||||||
@@ -213,10 +216,6 @@ func (c *Client) Register(nick string, password string, channel string) {
|
|||||||
// set user-wanted nickname
|
// set user-wanted nickname
|
||||||
c.Nickname = nick
|
c.Nickname = nick
|
||||||
c.SendCommand(commands.USER, nick, "0", "*", nick)
|
c.SendCommand(commands.USER, nick, "0", "*", nick)
|
||||||
// joining a channel when registering is optional
|
|
||||||
if channel != "" {
|
|
||||||
c.SendCommand(commands.JOIN, channel)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) SetDay() {
|
func (c *Client) SetDay() {
|
||||||
|
|||||||
@@ -371,9 +371,15 @@ func handleWELCOME(msg irc.Message, client *irc.Client) {
|
|||||||
AsServerMsg: true,
|
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.Nickname = nick
|
||||||
client.Channels[0].AppendMsg(msg.Timestamp, welcomeMsg, msgOpts)
|
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) {
|
func handleYOURHOST(msg irc.Message, client *irc.Client) {
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ func (s State) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
tlsEnabled := s.UI.Login.TLS
|
tlsEnabled := s.UI.Login.TLS
|
||||||
|
|
||||||
s.UI.CurrentScreen = MainScreen
|
s.UI.CurrentScreen = MainScreen
|
||||||
|
s.Client.InitialChannel = channel
|
||||||
|
|
||||||
s.Client.Initialize(host, port, tlsEnabled)
|
s.Client.Initialize(host, port, tlsEnabled)
|
||||||
s.Client.Register(nickname, password, channel)
|
s.Client.Register(nickname, password, channel)
|
||||||
|
|||||||
Reference in New Issue
Block a user