kopia lustrzana https://github.com/tmsmr/xmpp-webhook
Handle alerts with mellium-xmpp
rodzic
e362a0ead8
commit
7e236f4973
12
main.go
12
main.go
|
@ -4,7 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"mellium.im/sasl"
|
"mellium.im/sasl"
|
||||||
|
@ -77,7 +76,7 @@ func main() {
|
||||||
_, forceStartTLS := os.LookupEnv("XMPP_FORCE_STARTTLS")
|
_, forceStartTLS := os.LookupEnv("XMPP_FORCE_STARTTLS")
|
||||||
|
|
||||||
// check if xmpp credentials and receiver list are supplied
|
// check if xmpp credentials and receiver list are supplied
|
||||||
if xi == "" || xp == "1" || xr == "" {
|
if xi == "" || xp == "" || xr == "" {
|
||||||
log.Fatal("XMPP_ID, XMPP_PASS or XMPP_RECEIVERS not set")
|
log.Fatal("XMPP_ID, XMPP_PASS or XMPP_RECEIVERS not set")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,10 +136,13 @@ func main() {
|
||||||
for _, r := range strings.Split(xr, ",") {
|
for _, r := range strings.Split(xr, ",") {
|
||||||
recipient, err := jid.Parse(r)
|
recipient, err := jid.Parse(r)
|
||||||
panicOnErr(err)
|
panicOnErr(err)
|
||||||
fmt.Println(m)
|
|
||||||
fmt.Println(recipient)
|
|
||||||
// try to send message, ignore errors
|
// try to send message, ignore errors
|
||||||
//_ = xmppSession.Send(context.TODO(), stanza.WrapMessage(recipient, stanza.NormalMessage))
|
_ = xmppSession.Encode(MessageBody{
|
||||||
|
Message: stanza.Message{
|
||||||
|
To: recipient,
|
||||||
|
},
|
||||||
|
Body: m,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
Ładowanie…
Reference in New Issue