From c62a30fdf616bd59d4822b730298180ad67a475a Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Mon, 9 Dec 2024 06:59:55 +0800 Subject: CAP LS: Take version as integer --- cmd_cap.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'cmd_cap.go') 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)) } -- cgit v1.2.3