mirror of
https://dev.narayana.im/narayana/telegabber.git
synced 2026-08-04 19:57:07 +00:00
Add /raw command to bypass bot commands
This commit is contained in:
parent
4414c147d8
commit
9378fa4991
4 changed files with 20 additions and 4 deletions
2
Makefile
2
Makefile
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -989,10 +989,10 @@ func handleSetQueryCommand(s xmpp.Sender, iq *stanza.IQ, command *stanza.Command
|
|||
answer.Payload = payload
|
||||
|
||||
if len(form.Fields) == 1 && form.Fields[0] != nil &&
|
||||
form.Fields[0].Var == "command" && len(form.Fields[0].ValuesList) == 1 {
|
||||
form.Fields[0].Var == "command" && len(form.Fields[0].ValuesList) == 1 {
|
||||
session, ok := sessions[bare]
|
||||
if ok {
|
||||
msgText := "/"+form.Fields[0].ValuesList[0]
|
||||
msgText := "/" + form.Fields[0].ValuesList[0]
|
||||
session.LastBotCmdString = msgText
|
||||
tgMessageId := session.ProcessOutgoingMessage(toId, msgText, iq.From, 0, 0, true)
|
||||
if tgMessageId != 0 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue