diff --git a/main.go b/main.go index d9c291e..6dffe88 100644 --- a/main.go +++ b/main.go @@ -128,6 +128,7 @@ func startClient(config *config) { var err error var client *xmpp.Client router := xmpp.NewRouter() + router.HandleFunc("message", answerMessage) errorHandler:= func(err error) { fmt.Println(err.Error()) @@ -181,6 +182,18 @@ func startClient(config *config) { } +func answerMessage(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) + keepMessage := msg.Body + fmt.Println("keep the message",keepMessage) + /*reply := stanza.Message{Attrs: stanza.Attrs{To: msg.From}, Body: msg.Body} + _ = s.Send(reply)*/ +} func startMessaging(client xmpp.Sender, config *config, notifications chan string) {