diff options
author | bodqhrohro <bodqhrohro@gmail.com> | 2019-12-03 03:32:53 +0300 |
---|---|---|
committer | bodqhrohro <bodqhrohro@gmail.com> | 2019-12-03 03:32:53 +0300 |
commit | 90f0490e1626f3e0cd753caa5a4aac7787cb6dfc (patch) | |
tree | 08127d54f25c1e18b5dacc2f4ca3f011f224c5d1 /xmpp | |
parent | 40b3c6a76884576dc4e3b81891c9c693c7882bab (diff) |
Support commands in mapped chats
Diffstat (limited to 'xmpp')
-rw-r--r-- | xmpp/handlers.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/xmpp/handlers.go b/xmpp/handlers.go index d3abeab..861ecea 100644 --- a/xmpp/handlers.go +++ b/xmpp/handlers.go @@ -65,15 +65,16 @@ func HandleMessage(s xmpp.Sender, p stanza.Packet) { toID := toParts[0] if len(toParts) > 1 { toIDInt, err := strconv.Atoi(toID) - if err != nil { - session.ProcessOutgoingMessage(toIDInt, msg.Body, 0) + if err == nil { + session.ProcessOutgoingMessage(toIDInt, msg.Body, 0, msg.From) return } + log.WithFields(log.Fields{ + "toID": toID, + }).Error(errors.Wrap(err, "Invalid to JID!")) } else if toID == gateway.Jid.Bare() { - bodyFields := strings.Fields(msg.Body) - cmd := bodyFields[0] - if strings.HasPrefix(cmd, "/") { - response := session.ProcessTransportCommand(cmd[1:], bodyFields[1:]) + if strings.HasPrefix(msg.Body, "/") { + response := session.ProcessTransportCommand(msg.Body) if response != "" { gateway.SendMessage(msg.From, "", response, component) } |