From b609b86f9784977f24e572d25d2d01fe776c2247 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 14 Jun 2021 21:44:38 +0200 Subject: [PATCH] Add support for account-tag --- downstream.go | 6 ++++++ upstream.go | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/downstream.go b/downstream.go index 7d4c370..965749e 100644 --- a/downstream.go +++ b/downstream.go @@ -131,6 +131,7 @@ var permanentDownstreamCaps = map[string]string{ // needAllDownstreamCaps is the list of downstream capabilities that // require support from all upstreams to be enabled var needAllDownstreamCaps = map[string]string{ + "account-tag": "", "away-notify": "", "extended-join": "", "multi-prefix": "", @@ -375,6 +376,8 @@ func (dc *downstreamConn) SendMessage(msg *irc.Message) { switch name { case "time": supported = dc.caps["server-time"] + case "account": + supported = dc.caps["account"] } if !supported { delete(msg.Tags, name) @@ -1950,6 +1953,9 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error { echoTags := tags.Copy() echoTags["time"] = irc.TagValue(time.Now().UTC().Format(serverTimeLayout)) + if uc.account != "" { + echoTags["account"] = irc.TagValue(uc.account) + } echoMsg := &irc.Message{ Tags: echoTags, Prefix: &irc.Prefix{ diff --git a/upstream.go b/upstream.go index fb64b20..76d6599 100644 --- a/upstream.go +++ b/upstream.go @@ -21,6 +21,7 @@ import ( // permanentUpstreamCaps is the static list of upstream capabilities always // requested when supported. var permanentUpstreamCaps = map[string]bool{ + "account-tag": true, "away-notify": true, "batch": true, "extended-join": true, @@ -94,6 +95,7 @@ type upstreamConn struct { caps map[string]bool batches map[string]batch away bool + account string nextLabelID uint64 saslClient sasl.Client @@ -534,12 +536,12 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error { Params: []string{respStr}, }) case irc.RPL_LOGGEDIN: - var account string - if err := parseMessageParams(msg, nil, nil, &account); err != nil { + if err := parseMessageParams(msg, nil, nil, &uc.account); err != nil { return err } - uc.logger.Printf("logged in with account %q", account) + uc.logger.Printf("logged in with account %q", uc.account) case irc.RPL_LOGGEDOUT: + uc.account = "" uc.logger.Printf("logged out") case irc.ERR_NICKLOCKED, irc.RPL_SASLSUCCESS, irc.ERR_SASLFAIL, irc.ERR_SASLTOOLONG, irc.ERR_SASLABORTED: var info string