Add support for account-tag
This commit is contained in:
parent
cacbd48949
commit
b609b86f97
@ -131,6 +131,7 @@ var permanentDownstreamCaps = map[string]string{
|
|||||||
// needAllDownstreamCaps is the list of downstream capabilities that
|
// needAllDownstreamCaps is the list of downstream capabilities that
|
||||||
// require support from all upstreams to be enabled
|
// require support from all upstreams to be enabled
|
||||||
var needAllDownstreamCaps = map[string]string{
|
var needAllDownstreamCaps = map[string]string{
|
||||||
|
"account-tag": "",
|
||||||
"away-notify": "",
|
"away-notify": "",
|
||||||
"extended-join": "",
|
"extended-join": "",
|
||||||
"multi-prefix": "",
|
"multi-prefix": "",
|
||||||
@ -375,6 +376,8 @@ func (dc *downstreamConn) SendMessage(msg *irc.Message) {
|
|||||||
switch name {
|
switch name {
|
||||||
case "time":
|
case "time":
|
||||||
supported = dc.caps["server-time"]
|
supported = dc.caps["server-time"]
|
||||||
|
case "account":
|
||||||
|
supported = dc.caps["account"]
|
||||||
}
|
}
|
||||||
if !supported {
|
if !supported {
|
||||||
delete(msg.Tags, name)
|
delete(msg.Tags, name)
|
||||||
@ -1950,6 +1953,9 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
|
|||||||
|
|
||||||
echoTags := tags.Copy()
|
echoTags := tags.Copy()
|
||||||
echoTags["time"] = irc.TagValue(time.Now().UTC().Format(serverTimeLayout))
|
echoTags["time"] = irc.TagValue(time.Now().UTC().Format(serverTimeLayout))
|
||||||
|
if uc.account != "" {
|
||||||
|
echoTags["account"] = irc.TagValue(uc.account)
|
||||||
|
}
|
||||||
echoMsg := &irc.Message{
|
echoMsg := &irc.Message{
|
||||||
Tags: echoTags,
|
Tags: echoTags,
|
||||||
Prefix: &irc.Prefix{
|
Prefix: &irc.Prefix{
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
// permanentUpstreamCaps is the static list of upstream capabilities always
|
// permanentUpstreamCaps is the static list of upstream capabilities always
|
||||||
// requested when supported.
|
// requested when supported.
|
||||||
var permanentUpstreamCaps = map[string]bool{
|
var permanentUpstreamCaps = map[string]bool{
|
||||||
|
"account-tag": true,
|
||||||
"away-notify": true,
|
"away-notify": true,
|
||||||
"batch": true,
|
"batch": true,
|
||||||
"extended-join": true,
|
"extended-join": true,
|
||||||
@ -94,6 +95,7 @@ type upstreamConn struct {
|
|||||||
caps map[string]bool
|
caps map[string]bool
|
||||||
batches map[string]batch
|
batches map[string]batch
|
||||||
away bool
|
away bool
|
||||||
|
account string
|
||||||
nextLabelID uint64
|
nextLabelID uint64
|
||||||
|
|
||||||
saslClient sasl.Client
|
saslClient sasl.Client
|
||||||
@ -534,12 +536,12 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
|
|||||||
Params: []string{respStr},
|
Params: []string{respStr},
|
||||||
})
|
})
|
||||||
case irc.RPL_LOGGEDIN:
|
case irc.RPL_LOGGEDIN:
|
||||||
var account string
|
if err := parseMessageParams(msg, nil, nil, &uc.account); err != nil {
|
||||||
if err := parseMessageParams(msg, nil, nil, &account); err != nil {
|
|
||||||
return err
|
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:
|
case irc.RPL_LOGGEDOUT:
|
||||||
|
uc.account = ""
|
||||||
uc.logger.Printf("logged out")
|
uc.logger.Printf("logged out")
|
||||||
case irc.ERR_NICKLOCKED, irc.RPL_SASLSUCCESS, irc.ERR_SASLFAIL, irc.ERR_SASLTOOLONG, irc.ERR_SASLABORTED:
|
case irc.ERR_NICKLOCKED, irc.RPL_SASLSUCCESS, irc.ERR_SASLFAIL, irc.ERR_SASLTOOLONG, irc.ERR_SASLABORTED:
|
||||||
var info string
|
var info string
|
||||||
|
Loading…
Reference in New Issue
Block a user