lrstanley / girc

:bomb: girc is a flexible IRC library for Go :ok_hand:

Home Page:https://pkg.go.dev/github.com/lrstanley/girc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ability to not send nick in the login process

ArsenArsen opened this issue · comments

hey!

I wrote some custom handlers for handling NICK messages and it's related errors, but the internal conflict handlers interfere (resulting in silly things like the name being reset back), and due to the nature of this handler, there is state involved with figuring out a nick conflict (specifically, a number is incremented), meaning it cannot be easily translated to HandleNickCollide.

for this reason I propose that NICK initialnick optionally removed from the initial setup process, letting the user do it after a CONNECTED event, but still keep the internal nick tracking

Registration is done here:

girc/conn.go

Lines 310 to 336 in 771323f

// Passwords first.
if c.Config.WebIRC.Password != "" {
c.write(&Event{Command: WEBIRC, Params: c.Config.WebIRC.Params(), Sensitive: true})
}
if c.Config.ServerPass != "" {
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}})
// Then username and realname.
if c.Config.Name == "" {
c.Config.Name = c.Config.User
}
c.write(&Event{Command: USER, Params: []string{c.Config.User, "*", "*", c.Config.Name}})

Specifically, NICK has to be provided during the registration process (before CONNECTED, capability negotiation, etc) otherwise servers will disconnect with invalid registration.

Furthermore, as seen here, the order is:

The recommended order of commands during registration is as follows:

  1. CAP LS 302
  2. PASS
  3. NICK and USER
  4. Capability Negotiation
  5. SASL (if negotiated)
  6. CAP END

147f0ff adds support for disabling my nickname collision logic, though.