From 9aac073eb159af8ced705a335d64aebb3eaa24dd Mon Sep 17 00:00:00 2001 From: AnisB Date: Mon, 9 Aug 2021 19:00:32 +0100 Subject: [PATCH] bot keep message Former-commit-id: 64647e8c9882c8d48f13109c25bdbb41bad72183 --- main.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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) {