aboutsummaryrefslogtreecommitdiff
path: root/xmpp/handlers.go
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp/handlers.go')
-rw-r--r--xmpp/handlers.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/xmpp/handlers.go b/xmpp/handlers.go
new file mode 100644
index 0000000..38bbe7a
--- /dev/null
+++ b/xmpp/handlers.go
@@ -0,0 +1,21 @@
+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)
+}