diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-02-14 04:45:11 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-02-14 04:45:11 +0300 |
commit | 72b336a5f5641adcfa535270862191d9072dba3c (patch) | |
tree | e65f5568ac7480b12bced13dee680b9d76890fbb | |
parent | 915c40f1eed6ba139323c0fa15eed4ed3792f34b (diff) |
Support ! prefix for commands in addition to /
-rw-r--r-- | telegram/commands.go | 1 | ||||
-rw-r--r-- | telegram/utils.go | 2 | ||||
-rw-r--r-- | xmpp/handlers.go | 2 |
3 files changed, 3 insertions, 2 deletions
diff --git a/telegram/commands.go b/telegram/commands.go index 61cd2f9..d7318d0 100644 --- a/telegram/commands.go +++ b/telegram/commands.go @@ -138,6 +138,7 @@ func helpString(ht helpType) string { str.WriteString("\n") } } + str.WriteString("\nYou may use ! instead of / if it conflicts with internal commands of a client") return str.String() } diff --git a/telegram/utils.go b/telegram/utils.go index 7e93e57..d9773c0 100644 --- a/telegram/utils.go +++ b/telegram/utils.go @@ -666,7 +666,7 @@ func (c *Client) ProcessOutgoingMessage(chatID int64, text string, returnJid str return nil } - if returnJid != "" && strings.HasPrefix(text, "/") { + if returnJid != "" && (strings.HasPrefix(text, "/") || strings.HasPrefix(text, "!")) { // try to execute commands response, isCommand := c.ProcessChatCommand(chatID, text) if response != "" { diff --git a/xmpp/handlers.go b/xmpp/handlers.go index eeb9628..b4440a0 100644 --- a/xmpp/handlers.go +++ b/xmpp/handlers.go @@ -89,7 +89,7 @@ func HandleMessage(s xmpp.Sender, p stanza.Packet) { session.ProcessOutgoingMessage(toID, msg.Body, msg.From) return } else if msg.To == gatewayJid { - if strings.HasPrefix(msg.Body, "/") { + if strings.HasPrefix(msg.Body, "/") || strings.HasPrefix(msg.Body, "!") { response := session.ProcessTransportCommand(msg.Body, resource) if response != "" { gateway.SendMessage(msg.From, "", response, component) |