Allow CAP command when registered

This commit is contained in:
Simon Ser 2020-03-16 15:11:08 +01:00
parent bdfb8634e9
commit 9b777922ae
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -339,7 +339,6 @@ func (dc *downstreamConn) handleMessageUnregistered(msg *irc.Message) error {
if err := parseMessageParams(msg, &subCmd); err != nil { if err := parseMessageParams(msg, &subCmd); err != nil {
return err return err
} }
subCmd = strings.ToUpper(subCmd)
if err := dc.handleCapCommand(subCmd, msg.Params[1:]); err != nil { if err := dc.handleCapCommand(subCmd, msg.Params[1:]); err != nil {
return err return err
} }
@ -354,6 +353,8 @@ func (dc *downstreamConn) handleMessageUnregistered(msg *irc.Message) error {
} }
func (dc *downstreamConn) handleCapCommand(cmd string, args []string) error { func (dc *downstreamConn) handleCapCommand(cmd string, args []string) error {
cmd = strings.ToUpper(cmd)
replyTo := dc.nick replyTo := dc.nick
if !dc.registered { if !dc.registered {
replyTo = "*" replyTo = "*"
@ -620,6 +621,14 @@ func (dc *downstreamConn) runUntilRegistered() error {
func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error { func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
switch msg.Command { switch msg.Command {
case "CAP":
var subCmd string
if err := parseMessageParams(msg, &subCmd); err != nil {
return err
}
if err := dc.handleCapCommand(subCmd, msg.Params[1:]); err != nil {
return err
}
case "PING": case "PING":
dc.SendMessage(&irc.Message{ dc.SendMessage(&irc.Message{
Prefix: dc.srv.prefix(), Prefix: dc.srv.prefix(),