|
|
|
@ -8,6 +8,7 @@ import (
|
|
|
|
|
"context"
|
|
|
|
|
"fmt"
|
|
|
|
|
"log"
|
|
|
|
|
"runtime"
|
|
|
|
|
|
|
|
|
|
"github.com/beevik/etree" // BSD-2-clause
|
|
|
|
|
"github.com/mattn/go-xmpp" // BSD-3-Clause
|
|
|
|
@ -85,6 +86,31 @@ func rcvStanzas(client *xmpp.Client, iqc chan xmpp.IQ, msgc chan xmpp.Chat, ctx
|
|
|
|
|
identity.CreateAttr("name", "go-sendxmpp")
|
|
|
|
|
feat := replyQuery.CreateElement("feature")
|
|
|
|
|
feat.CreateAttr("var", nsDiscoInfo)
|
|
|
|
|
feat2 := replyQuery.CreateElement("feature")
|
|
|
|
|
feat2.CreateAttr("var", nsVersion)
|
|
|
|
|
xmlString, err := root.WriteToString()
|
|
|
|
|
if err == nil {
|
|
|
|
|
_, err = client.SendOrg(xmlString)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Println(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case nsVersion:
|
|
|
|
|
root := etree.NewDocument()
|
|
|
|
|
root.WriteSettings.AttrSingleQuote = true
|
|
|
|
|
reply := root.CreateElement("iq")
|
|
|
|
|
reply.CreateAttr("type", "result")
|
|
|
|
|
reply.CreateAttr("from", client.JID())
|
|
|
|
|
reply.CreateAttr("to", v.From)
|
|
|
|
|
reply.CreateAttr("id", v.ID)
|
|
|
|
|
replyQuery := reply.CreateElement("query")
|
|
|
|
|
replyQuery.CreateAttr("xmlns", nsVersion)
|
|
|
|
|
rqName := replyQuery.CreateElement("name")
|
|
|
|
|
rqName.CreateText("go-sendxmpp")
|
|
|
|
|
rqVersion := replyQuery.CreateElement("version")
|
|
|
|
|
rqVersion.CreateText(version)
|
|
|
|
|
rqOS := replyQuery.CreateElement("os")
|
|
|
|
|
rqOS.CreateText(runtime.GOOS)
|
|
|
|
|
xmlString, err := root.WriteToString()
|
|
|
|
|
if err == nil {
|
|
|
|
|
_, err = client.SendOrg(xmlString)
|
|
|
|
|