Add experimental hats support

This commit is contained in:
2026-01-31 15:08:54 +00:00
parent 3962f1f17d
commit 2ef3cf3a06
6 changed files with 135 additions and 2 deletions

31
xmpp-hats.go Normal file
View File

@@ -0,0 +1,31 @@
package main
import (
"encoding/xml"
"gosrc.io/xmpp/stanza"
)
// Implementation of XEP-0317: Hats
// https://xmpp.org/extensions/xep-0317.html
type Hats struct {
XMLName xml.Name `xml:"urn:xmpp:hats:0 hats"`
Hats []Hat `xml:"hat"`
}
type Hat struct {
Title string `xml:"title,attr"`
URI string `xml:"uri,attr"`
Hue string `xml:"hue,attr"`
Lang string `xml:"xml:lang,attr"`
Badge Badge `xml:"badge"`
}
type Badge struct {
XMLName xml.Name `xml:"urn:example:badges badge"`
Level int `xml:"level,attr"`
}
func init() {
stanza.TypeRegistry.MapExtension(stanza.PKTPresence, xml.Name{Space: "urn:xmpp:hats:0", Local: "hats"}, Hats{})
}