From c84ef97b90f0a94dd85128701daa87bdbffb5bf2 Mon Sep 17 00:00:00 2001 From: Daniel Oaks Date: Sun, 28 Apr 2019 01:50:16 +1000 Subject: [PATCH] Make CAP version upgrading work as recommended by cap spec --- irc/handlers.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/irc/handlers.go b/irc/handlers.go index ac8821bc..7270fb04 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -535,8 +535,12 @@ func capHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Respo if !client.registered { rb.session.capState = caps.NegotiatingState } - if len(msg.Params) > 1 && msg.Params[1] == "302" { - rb.session.capVersion = 302 + if 1 < len(msg.Params) { + num, err := strconv.Atoi(msg.Params[1]) + newVersion := caps.Version(num) + if err == nil && rb.session.capVersion < newVersion { + rb.session.capVersion = newVersion + } } // weechat 1.4 has a bug here where it won't accept the CAP reply unless it contains // the server.name source... otherwise it doesn't respond to the CAP message with