telegabber/xmpp/handlers.go

22 lines
423 B
Go
Raw Normal View History

2019-10-22 16:36:54 +00:00
package xmpp
import (
"fmt"
"os"
"gosrc.io/xmpp"
"gosrc.io/xmpp/stanza"
)
func HandleMessage(s xmpp.Sender, p stanza.Packet) {
msg, ok := p.(stanza.Message)
if !ok {
_, _ = fmt.Fprintf(os.Stdout, "Ignoring packet: %T\n", p)
return
}
_, _ = fmt.Fprintf(os.Stdout, "Body = %s - from = %s\n", msg.Body, msg.From)
reply := stanza.Message{Attrs: stanza.Attrs{To: msg.From}, Body: msg.Body}
_ = s.Send(reply)
}