Add /raw command to bypass bot commands

This commit is contained in:
Bohdan Horbeshko 2025-04-30 19:55:34 -04:00
parent 4414c147d8
commit 9378fa4991
4 changed files with 20 additions and 4 deletions

View file

@ -2,7 +2,7 @@
COMMIT := $(shell git rev-parse --short HEAD)
TD_COMMIT := "5bbfc1cf5dab94f82e02f3430ded7241d4653551"
VERSION := "v1.11.0"
VERSION := "v1.12.0"
MAKEOPTS := "-j4"
all:

View file

@ -16,7 +16,7 @@ import (
goxmpp "gosrc.io/xmpp"
)
var version string = "1.11.0"
var version string = "1.12.0"
var commit string
var sm *goxmpp.StreamManager

View file

@ -80,6 +80,7 @@ var chatCommands = map[string]command{
"s": command{1, []string{"edited message"}, "edit your last message", true, nil},
"silent": command{1, []string{"message"}, "send a message without sound", true, nil},
"schedule": command{2, []string{"{online | 2006-01-02T15:04:05 | 15:04:05}", "message"}, "schedules a message either to timestamp or to whenever the user goes online", true, nil},
"raw": command{1, []string{"message"}, "send a raw message not interpeted as a transport command (e.g. a bot command)", true, nil},
"forward": command{2, []string{"message_id", "target_chat"}, "forwards a message", true, nil},
"vcard": command{0, []string{}, "print vCard as text", true, nil},
"add": command{1, []string{"@username"}, "add @username to your chat list", true, nil},
@ -725,6 +726,21 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool,
} else {
return "Message processing error", true, false
}
// sends a raw non-interpreted message
case "raw":
content := c.PrepareOutgoingMessageContent(rawCmdArguments(cmdline, 0))
if content != nil {
_, err := c.client.SendMessage(&client.SendMessageRequest{
ChatId: chatID,
InputMessageContent: content,
})
if err != nil {
return err.Error(), true, false
}
} else {
return "Message processing error", true, false
}
// forward a message to chat
case "forward":
messageId, err := strconv.ParseInt(args[0], 10, 64)