summaryrefslogtreecommitdiff
path: root/irc/states.go
diff options
context:
space:
mode:
authorHubert Hirtz <hubert@hirtzfr.eu>2020-08-17 20:30:36 +0200
committerHubert Hirtz <hubert@hirtzfr.eu>2020-08-17 20:30:36 +0200
commitef46f825b6bbffa2ed403545f73e38a01ad0c850 (patch)
tree2b2d6e4d2e9803b974151e7c6b393ebc6cd47bf3 /irc/states.go
parentAdd /names command (diff)
irc: Send NAMES when multi-prefix is negociated
Diffstat (limited to 'irc/states.go')
-rw-r--r--irc/states.go33
1 files changed, 21 insertions, 12 deletions
diff --git a/irc/states.go b/irc/states.go
index b09a562..edc9e56 100644
--- a/irc/states.go
+++ b/irc/states.go
@@ -469,18 +469,6 @@ func (s *Session) handleStart(msg Message) (err error) {
return
}
}
- case "ACK":
- for _, c := range strings.Split(msg.Params[2], " ") {
- s.enabledCaps[c] = struct{}{}
-
- if s.auth != nil && c == "sasl" {
- h := s.auth.Handshake()
- err = s.send("AUTHENTICATE %s\r\n", h)
- if err != nil {
- return
- }
- }
- }
default:
s.handle(msg)
}
@@ -535,6 +523,27 @@ func (s *Session) handle(msg Message) (err error) {
case "ACK":
for _, c := range strings.Split(msg.Params[2], " ") {
s.enabledCaps[c] = struct{}{}
+
+ if s.auth != nil && c == "sasl" {
+ h := s.auth.Handshake()
+ err = s.send("AUTHENTICATE %s\r\n", h)
+ if err != nil {
+ return
+ }
+ } else if len(s.channels) != 0 && c == "multi-prefix" {
+ // TODO merge NAMES commands
+ var sb strings.Builder
+ sb.Grow(512)
+ for _, c := range s.channels {
+ sb.WriteString("NAMES ")
+ sb.WriteString(c.Name)
+ sb.WriteString("\r\n")
+ }
+ err = s.send(sb.String())
+ if err != nil {
+ return
+ }
+ }
}
case "NAK":
for _, c := range strings.Split(msg.Params[2], " ") {