From 72b336a5f5641adcfa535270862191d9072dba3c Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Sun, 13 Feb 2022 20:45:11 -0500 Subject: [PATCH] Support ! prefix for commands in addition to / --- telegram/commands.go | 1 + telegram/utils.go | 2 +- 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)