]> git.giacomolli.uk - onechat/blobdiff - telegram.go
Escape tags in the Markdown of rich replies
[onechat] / telegram.go
index 13196d4a547781602d63e4b0460117f0f55d8366..13c200c8481a1c47c6cb1497a7e9f84a4a869a62 100644 (file)
@@ -311,8 +311,9 @@ func (b *TelegramBot) typing(ctx context.Context) {
 }
 
 // post sends event to the chat. A reply goes as rich messages of its Markdown,
 }
 
 // post sends event to the chat. A reply goes as rich messages of its Markdown,
-// split with telegramSplitRich. Every other event goes as plain text, split
-// with telegramSplitMessage.
+// with each < outside code escaped by telegramEscapeTags and then split with
+// telegramSplitRich, so that the length limit counts the escaped text. Every
+// other event goes as plain text, split with telegramSplitMessage.
 func (b *TelegramBot) post(ctx context.Context, event Event) {
        if event.Kind != "reply" {
                for _, text := range telegramSplitMessage(telegramText(event), telegramMessageUnits) {
 func (b *TelegramBot) post(ctx context.Context, event Event) {
        if event.Kind != "reply" {
                for _, text := range telegramSplitMessage(telegramText(event), telegramMessageUnits) {
@@ -324,7 +325,7 @@ func (b *TelegramBot) post(ctx context.Context, event Event) {
                return
        }
 
                return
        }
 
-       for _, markdown := range telegramSplitRich(event.Text, telegramRichBytes) {
+       for _, markdown := range telegramSplitRich(telegramEscapeTags(event.Text), telegramRichBytes) {
                b.deliverRich(ctx, markdown)
        }
 }
                b.deliverRich(ctx, markdown)
        }
 }