mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2026-01-09 18:19:20 -08:00
fix naming from fluxxmpp to fluuxmpp
This commit is contained in:
committed by
Mickaël Rémond
parent
76f59be5ed
commit
6e65ba2a0b
36
cmd/fluuxmpp/xmppsend.go
Normal file
36
cmd/fluuxmpp/xmppsend.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/bdlm/log"
|
||||
|
||||
"gosrc.io/xmpp"
|
||||
"gosrc.io/xmpp/stanza"
|
||||
)
|
||||
|
||||
func send(c xmpp.Sender, recipient []string, msgText string) {
|
||||
msg := stanza.Message{
|
||||
Attrs: stanza.Attrs{Type: stanza.MessageTypeChat},
|
||||
Body: msgText,
|
||||
}
|
||||
|
||||
if isMUCRecipient {
|
||||
msg.Type = stanza.MessageTypeGroupchat
|
||||
}
|
||||
|
||||
for _, to := range recipient {
|
||||
msg.To = to
|
||||
if err := c.Send(msg); err != nil {
|
||||
log.WithFields(map[string]interface{}{
|
||||
"muc": isMUCRecipient,
|
||||
"to": to,
|
||||
"text": msgText,
|
||||
}).Errorf("error on send message: %s", err)
|
||||
} else {
|
||||
log.WithFields(map[string]interface{}{
|
||||
"muc": isMUCRecipient,
|
||||
"to": to,
|
||||
"text": msgText,
|
||||
}).Info("send message")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user