From 559d6443e5a1d3654b5542ccaadf6b33537f752d Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Mon, 16 Jan 2023 08:02:41 -0500 Subject: [PATCH] Make OOB compatible with RawMessages --- telegram/utils.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/telegram/utils.go b/telegram/utils.go index 1545939..6878fc6 100644 --- a/telegram/utils.go +++ b/telegram/utils.go @@ -764,34 +764,34 @@ func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message) { text = c.messageToText(message, false) // OTR support (I do not know why would you need it, seriously) - if !(strings.HasPrefix(text, "?OTR") || c.Session.RawMessages) { + if !(strings.HasPrefix(text, "?OTR") || (c.Session.RawMessages && !c.Session.OOBMode)) { file, preview := c.contentToFile(content) // download file and preview (if present) file = c.ensureDownloadFile(file) preview = c.ensureDownloadFile(preview) - var prefix strings.Builder previewName, _ := c.formatFile(preview, true) fileName, link := c.formatFile(file, false) - prefix.WriteString(c.messageToPrefix(message, previewName, fileName)) + oob = link - if text != "" { - // \n if it is groupchat and message is not empty - if chatId < 0 { - prefix.WriteString("\n") - } else if chatId > 0 { - prefix.WriteString(" | ") + if c.Session.OOBMode && oob != "" { + text = oob + } else if !c.Session.RawMessages { + var prefix strings.Builder + prefix.WriteString(c.messageToPrefix(message, previewName, fileName)) + if text != "" { + // \n if it is groupchat and message is not empty + if chatId < 0 { + prefix.WriteString("\n") + } else if chatId > 0 { + prefix.WriteString(" | ") + } + + prefix.WriteString(text) } - - prefix.WriteString(text) + text = prefix.String() } - - text = prefix.String() - } - - if c.Session.OOBMode && oob != "" { - text = oob } }