add draft/msgid ircv3 support
This commit is contained in:
parent
bf5241d4ff
commit
88956d2424
40
cap.go
40
cap.go
@ -16,17 +16,19 @@ import (
|
|||||||
// Something not in the list? Depending on the type of capability, you can
|
// Something not in the list? Depending on the type of capability, you can
|
||||||
// enable it using Config.SupportedCaps.
|
// enable it using Config.SupportedCaps.
|
||||||
var possibleCap = map[string][]string{
|
var possibleCap = map[string][]string{
|
||||||
"account-notify": nil,
|
"account-notify": nil,
|
||||||
"account-tag": nil,
|
"account-tag": nil,
|
||||||
"away-notify": nil,
|
"away-notify": nil,
|
||||||
"batch": nil,
|
"batch": nil,
|
||||||
"cap-notify": nil,
|
"cap-notify": nil,
|
||||||
"chghost": nil,
|
"chghost": nil,
|
||||||
"extended-join": nil,
|
"extended-join": nil,
|
||||||
"invite-notify": nil,
|
"invite-notify": nil,
|
||||||
|
"multi-prefix": nil,
|
||||||
|
"userhost-in-names": nil,
|
||||||
|
|
||||||
"draft/message-tags-0.2": nil,
|
"draft/message-tags-0.2": nil,
|
||||||
"multi-prefix": nil,
|
"draft/msgid": nil,
|
||||||
"userhost-in-names": nil,
|
|
||||||
|
|
||||||
// "echo-message" is supported, but it's not enabled by default. This is
|
// "echo-message" is supported, but it's not enabled by default. This is
|
||||||
// to prevent unwanted confusion and utilize less traffic if it's not needed.
|
// to prevent unwanted confusion and utilize less traffic if it's not needed.
|
||||||
@ -450,17 +452,15 @@ func (t Tags) Len() (length int) {
|
|||||||
return len(t.Bytes())
|
return len(t.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Equals compares two Tags for equality.
|
// Equals compares two Tags for equality. With the msgid IRCv3 spec +\
|
||||||
|
// echo-message (amongst others), we may receive events that have msgid's,
|
||||||
|
// whereas our local events will not have the msgid. As such, don't compare
|
||||||
|
// all tags, only the necessary/important tags.
|
||||||
func (t Tags) Equals(tt Tags) bool {
|
func (t Tags) Equals(tt Tags) bool {
|
||||||
if t.Count() != tt.Count() {
|
// The only tag which is important at this time.
|
||||||
return false
|
taccount, _ := t.Get("account")
|
||||||
}
|
ttaccount, _ := tt.Get("account")
|
||||||
for k, v := range t {
|
return taccount == ttaccount
|
||||||
if vv, ok := tt[k]; !ok || v != vv {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keys returns a slice of (unsorted) tag keys.
|
// Keys returns a slice of (unsorted) tag keys.
|
||||||
|
@ -219,11 +219,16 @@ func TestEventSourceTagEquals(t *testing.T) {
|
|||||||
{
|
{
|
||||||
before: "@aaa=bbb;ccc;example.com/ddd=eee :nick!user@host PRIVMSG #test :This is a test",
|
before: "@aaa=bbb;ccc;example.com/ddd=eee :nick!user@host PRIVMSG #test :This is a test",
|
||||||
after: "@aaa=bbb;ccc :nick!user@host PRIVMSG #test :This is a test",
|
after: "@aaa=bbb;ccc :nick!user@host PRIVMSG #test :This is a test",
|
||||||
equals: false,
|
equals: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
before: ":nick!user@host PRIVMSG #test :This is a test",
|
before: ":nick!user@host PRIVMSG #test :This is a test",
|
||||||
after: "@aaa=bbb;ccc :nick!user@host PRIVMSG #test :This is a test",
|
after: "@aaa=bbb;ccc :nick!user@host PRIVMSG #test :This is a test",
|
||||||
|
equals: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
before: "@account=bbb;ccc :nick!user@host PRIVMSG #test :This is a test",
|
||||||
|
after: "@aaa=bbb;ccc :nick!user@host PRIVMSG #test :This is a test",
|
||||||
equals: false,
|
equals: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user