aboutsummaryrefslogtreecommitdiff
path: root/telegram/handlers.go
diff options
context:
space:
mode:
Diffstat (limited to 'telegram/handlers.go')
-rw-r--r--telegram/handlers.go31
1 files changed, 20 insertions, 11 deletions
diff --git a/telegram/handlers.go b/telegram/handlers.go
index 05c12ca..6266292 100644
--- a/telegram/handlers.go
+++ b/telegram/handlers.go
@@ -309,34 +309,43 @@ func (c *Client) updateMessageContent(update *client.UpdateMessageContent) {
}
}
- message, err := c.client.GetMessage(&client.GetMessageRequest{
+ message, messageErr := c.client.GetMessage(&client.GetMessageRequest{
ChatId: update.ChatId,
MessageId: update.MessageId,
})
- if err == nil {
+ var prefix string
+ if messageErr == nil {
isCarbon = c.isCarbonsEnabled() && message.IsOutgoing
+ // reply correction support in clients is suboptimal yet, so cut them out for now
+ prefix, _ = c.messageToPrefix(message, "", "", true)
} else {
log.Errorf("No message %v/%v found, cannot reliably determine if it's a carbon", update.ChatId, update.MessageId)
}
- text := formatter.Format(
- textContent.Text.Text,
- textContent.Text.Entities,
- markupFunction,
- )
+ var text strings.Builder
if replaceId == "" {
var editChar string
if c.Session.AsciiArrows {
- editChar = "e "
+ editChar = "e"
} else {
- editChar = "✎ "
+ editChar = "✎"
}
- text = editChar + fmt.Sprintf("%v | %s", update.MessageId, text)
+ text.WriteString(fmt.Sprintf("%s %v | ", editChar, update.MessageId))
+ } else if prefix != "" {
+ text.WriteString(prefix)
+ text.WriteString(c.getPrefixSeparator(update.ChatId))
}
+ text.WriteString(formatter.Format(
+ textContent.Text.Text,
+ textContent.Text.Entities,
+ markupFunction,
+ ))
+
+ sChatId := strconv.FormatInt(update.ChatId, 10)
for _, jid := range jids {
- gateway.SendMessage(jid, strconv.FormatInt(update.ChatId, 10), text, "e"+sId, c.xmpp, nil, replaceId, isCarbon, false)
+ gateway.SendMessage(jid, sChatId, text.String(), "e"+sId, c.xmpp, nil, replaceId, isCarbon, false)
}
}
}