diff options
author | Runxi Yu <me@runxiyu.org> | 2024-12-09 06:59:55 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2024-12-09 06:59:55 +0800 |
commit | c62a30fdf616bd59d4822b730298180ad67a475a (patch) | |
tree | bbeb43882acc8cd2450f0a488a55ab538dcb70e0 /cmd_cap.go | |
parent | CAP LS: Distinguish 302 (diff) | |
download | meseircd-c62a30fdf616bd59d4822b730298180ad67a475a.tar.gz meseircd-c62a30fdf616bd59d4822b730298180ad67a475a.tar.zst meseircd-c62a30fdf616bd59d4822b730298180ad67a475a.zip |
CAP LS: Take version as integer
Diffstat (limited to 'cmd_cap.go')
-rw-r--r-- | cmd_cap.go | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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)) } |