aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cap.go6
-rw-r--r--cmd_cap.go10
2 files changed, 12 insertions, 4 deletions
diff --git a/cap.go b/cap.go
index 06e1f00..2beb771 100644
--- a/cap.go
+++ b/cap.go
@@ -6,8 +6,10 @@ import (
var Caps = map[string]string{}
-var capls string
-var capls302 string
+var (
+ capls string
+ capls302 string
+)
// Can't be in init() because Caps will be registered with init in the future
// and init()s are executed by filename alphabetical order
diff --git a/cmd_cap.go b/cmd_cap.go
index c76bd57..ce70abc 100644
--- a/cmd_cap.go
+++ b/cmd_cap.go
@@ -1,6 +1,7 @@
package main
import (
+ "strconv"
"strings"
)
@@ -25,8 +26,13 @@ func handleClientCap(msg RMsg, client *Client) error {
client.State = ClientStateCapabilities
}
var err error
- if len(msg.Params) >= 2 && msg.Params[1] == "302" {
- err = client.Send(MakeMsg(self, "CAP", client.Nick, "LS", capls302))
+ if len(msg.Params) >= 2 {
+ capVersion, err := strconv.ParseUint(msg.Params[1], 10, 64)
+ if err == nil && capVersion >= 302 {
+ err = client.Send(MakeMsg(self, "CAP", client.Nick, "LS", capls302))
+ } else {
+ err = client.Send(MakeMsg(self, "CAP", client.Nick, "LS", capls))
+ }
} else {
err = client.Send(MakeMsg(self, "CAP", client.Nick, "LS", capls))
}