Request server-time cap
If the server didn't populate the time tag, do it ourselves.
This commit is contained in:
parent
29a42203b6
commit
2053e62162
3
irc.go
3
irc.go
@ -201,3 +201,6 @@ type batch struct {
|
|||||||
Outer *batch // if not-nil, this batch is nested in Outer
|
Outer *batch // if not-nil, this batch is nested in Outer
|
||||||
Label string
|
Label string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The server-time layout, as defined in the IRCv3 spec.
|
||||||
|
const serverTimeLayout = "2006-01-02T15:04:05.000Z"
|
||||||
|
10
upstream.go
10
upstream.go
@ -365,7 +365,7 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
requestCaps := make([]string, 0, 16)
|
requestCaps := make([]string, 0, 16)
|
||||||
for _, c := range []string{"message-tags", "batch", "labeled-response"} {
|
for _, c := range []string{"message-tags", "batch", "labeled-response", "server-time"} {
|
||||||
if _, ok := uc.caps[c]; ok {
|
if _, ok := uc.caps[c]; ok {
|
||||||
requestCaps = append(requestCaps, c)
|
requestCaps = append(requestCaps, c)
|
||||||
}
|
}
|
||||||
@ -1207,6 +1207,10 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, ok := msg.Tags["time"]; !ok {
|
||||||
|
msg.Tags["time"] = irc.TagValue(time.Now().Format(serverTimeLayout))
|
||||||
|
}
|
||||||
|
|
||||||
target := nick
|
target := nick
|
||||||
if nick == uc.nick {
|
if nick == uc.nick {
|
||||||
target = msg.Prefix.Name
|
target = msg.Prefix.Name
|
||||||
@ -1373,6 +1377,10 @@ func (uc *upstreamConn) handleCapAck(name string, ok bool) error {
|
|||||||
uc.tagsSupported = ok
|
uc.tagsSupported = ok
|
||||||
case "labeled-response":
|
case "labeled-response":
|
||||||
uc.labelsSupported = ok
|
uc.labelsSupported = ok
|
||||||
|
case "batch", "server-time":
|
||||||
|
// Nothing to do
|
||||||
|
default:
|
||||||
|
uc.logger.Printf("received CAP ACK/NAK for a cap we don't support: %v", name)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user