first idea of sendxmpp

This commit is contained in:
Martin/Geno
2019-07-17 00:31:33 +02:00
committed by Mickaël Rémond
parent c41d068c9f
commit 6aa942dd58
7 changed files with 237 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
package main
import (
"github.com/bdlm/log"
"gosrc.io/xmpp"
"gosrc.io/xmpp/stanza"
)
func send(c xmpp.Sender, receiver []string, msgText string) {
msg := stanza.Message{
Attrs: stanza.Attrs{Type: stanza.MessageTypeChat},
Body: msgText,
}
if receiverMUC {
msg.Type = stanza.MessageTypeGroupchat
}
for _, to := range receiver {
msg.To = to
if err := c.Send(msg); err != nil {
log.WithFields(map[string]interface{}{
"muc": receiverMUC,
"to": to,
"text": msgText,
}).Errorf("error on send message: %s", err)
} else {
log.WithFields(map[string]interface{}{
"muc": receiverMUC,
"to": to,
"text": msgText,
}).Info("send message")
}
}
}