diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2023-03-15 00:16:02 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2023-03-15 00:16:02 +0300 |
commit | 90807b2d9e0565629a913d3b28b09c5fc9d746e6 (patch) | |
tree | 80c56bc83a926d2e0573f58a5786cd964b91775f /telegram/utils.go | |
parent | 7bd165a738d6c39d2f9e530c67118f8c639ffb0b (diff) |
Convert XEP-0461 replies to Telegram
Diffstat (limited to 'telegram/utils.go')
-rw-r--r-- | telegram/utils.go | 14 |
1 files changed, 9 insertions, 5 deletions
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:] |