Support ! prefix for commands in addition to /

This commit is contained in:
Bohdan Horbeshko 2022-02-13 20:45:11 -05:00
parent 915c40f1ee
commit 72b336a5f5
3 changed files with 3 additions and 2 deletions

View file

@ -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()
}

View file

@ -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 != "" {

View file

@ -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)