diff --git a/feed-to-muc.go b/feed-to-muc.go index f2795b0..10fdd83 100644 --- a/feed-to-muc.go +++ b/feed-to-muc.go @@ -174,22 +174,44 @@ func pingMUC(client *xmpp.Client, botJid string, Muc string, MucNick string) { // Check for result IQ as long as there was no reply yet. for (time.Since(pingSent).Seconds() < 10.0) && (pingReceived == false) { - // Receive Stanzas. + // Receive stanzas. ToDo: Receive stanzas continiously without 30s delay. stanza, err := client.Recv() if err != nil { log.Fatal(err) } - // Check IQs for type result and UID. + // Check IQs for ping results and disco#info queries. switch v := stanza.(type) { case xmpp.IQ: if (v.Type == "error") && (v.ID == id) { log.Fatal("MUC not available.") } + if (v.Type == "result") && (v.ID == id) { pingReceived = true } - break + + if v.Type == "get" { + // Reply to disco#info requests according to https://xmpp.org/extensions/xep-0030.html. + if strings.Contains(string(v.Query), + "") == true { + _, err := client.RawInformation(client.JID(), v.From, v.ID, + "result", ""+ + ""+ + "") + if err != nil { + log.Fatal(err) + } + } else { + // Send error replies for all other IQs. + _, err := client.RawInformation(client.JID(), v.From, v.ID, "error", + string(v.Query)) + if err != nil { + log.Fatal(err) + } + } + } + default: break }