diff --git a/Makefile b/Makefile index 4704236..8a3b062 100644 --- a/Makefile +++ b/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: diff --git a/telegabber.go b/telegabber.go index e5940ff..1f0f3e0 100644 --- a/telegabber.go +++ b/telegabber.go @@ -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 diff --git a/telegram/commands.go b/telegram/commands.go index df9f5ff..ec1db89 100644 --- a/telegram/commands.go +++ b/telegram/commands.go @@ -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) diff --git a/xmpp/handlers.go b/xmpp/handlers.go index 49c41fb..c5560ec 100644 --- a/xmpp/handlers.go +++ b/xmpp/handlers.go @@ -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 {