diff options
Diffstat (limited to 'telegram')
-rw-r--r-- | telegram/commands.go | 6 | ||||
-rw-r--r-- | telegram/utils.go | 14 |
2 files changed, 12 insertions, 8 deletions
diff --git a/telegram/commands.go b/telegram/commands.go index 943d071..160e486 100644 --- a/telegram/commands.go +++ b/telegram/commands.go @@ -488,7 +488,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool) return "Last message is empty", true } - content := c.ProcessOutgoingMessage(0, rawCmdArguments(cmdline, 0), "") + content := c.ProcessOutgoingMessage(0, rawCmdArguments(cmdline, 0), "", 0) if content != nil { c.client.EditMessageText(&client.EditMessageTextRequest{ @@ -505,7 +505,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool) return "Not enough arguments", true } - content := c.ProcessOutgoingMessage(0, rawCmdArguments(cmdline, 0), "") + content := c.ProcessOutgoingMessage(0, rawCmdArguments(cmdline, 0), "", 0) if content != nil { _, err := c.client.SendMessage(&client.SendMessageRequest{ @@ -584,7 +584,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool) } } - content := c.ProcessOutgoingMessage(0, rawCmdArguments(cmdline, 1), "") + content := c.ProcessOutgoingMessage(0, rawCmdArguments(cmdline, 1), "", 0) if content != nil { _, err := c.client.SendMessage(&client.SendMessageRequest{ diff --git a/telegram/utils.go b/telegram/utils.go index fe6ca14..68dd524 100644 --- a/telegram/utils.go +++ b/telegram/utils.go @@ -857,7 +857,7 @@ func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message) { } // ProcessOutgoingMessage executes commands or sends messages to mapped chats -func (c *Client) ProcessOutgoingMessage(chatID int64, text string, returnJid string) client.InputMessageContent { +func (c *Client) ProcessOutgoingMessage(chatID int64, text string, returnJid string, replyId int64) client.InputMessageContent { if !c.Online() { // we're offline return nil @@ -879,9 +879,13 @@ func (c *Client) ProcessOutgoingMessage(chatID int64, text string, returnJid str // quotations var reply int64 - replySlice := replyRegex.FindStringSubmatch(text) - if len(replySlice) > 1 { - reply, _ = strconv.ParseInt(replySlice[1], 10, 64) + if replyId == 0 { + replySlice := replyRegex.FindStringSubmatch(text) + if len(replySlice) > 1 { + reply, _ = strconv.ParseInt(replySlice[1], 10, 64) + } + } else { + reply = replyId } // attach a file @@ -949,7 +953,7 @@ func (c *Client) ProcessOutgoingMessage(chatID int64, text string, returnJid str } // remove first line from text - if file != nil || reply != 0 { + if file != nil || (reply != 0 && replyId == 0) { newlinePos := strings.Index(text, newlineChar) if newlinePos != -1 { text = text[newlinePos+1:] |