move cap requests before name registration; fixes #6

This commit is contained in:
Liam Stanley 2017-10-20 19:17:52 -04:00
parent 4a1445ad80
commit 7756aef6ff

12
conn.go
View File

@ -288,6 +288,14 @@ func (c *Client) internalConnect(mock net.Conn, dialer Dialer) error {
c.write(&Event{Command: PASS, Params: []string{c.Config.ServerPass}, Sensitive: true})
}
// List the IRCv3 capabilities, specifically with the max protocol we
// support. The IRCv3 specification doesn't directly state if this should
// be called directly before registration, or if it should be called
// after NICK/USER requests. It looks like non-supporting networks
// should ignore this, and some IRCv3 capable networks require this to
// occur before NICK/USER registration.
c.listCAP()
// Then nickname.
c.write(&Event{Command: NICK, Params: []string{c.Config.Nick}})
@ -298,10 +306,6 @@ func (c *Client) internalConnect(mock net.Conn, dialer Dialer) error {
c.write(&Event{Command: USER, Params: []string{c.Config.User, "*", "*"}, Trailing: c.Config.Name})
// List the IRCv3 capabilities, specifically with the max protocol we
// support.
c.listCAP()
// Send a virtual event allowing hooks for successful socket connection.
c.RunHandlers(&Event{Command: INITIALIZED, Trailing: c.Server()})