diff options
Diffstat (limited to 'xmpp/handlers.go')
-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) } |