From 478b40d0ff7122d79df54b25a3118cfd4640f6e5 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Sat, 22 May 2021 23:32:30 +0100 Subject: [PATCH] Telegram: Escape exclamation marks, remove for images ![alt](link) becomes [alt](link), telegram seems to pick up that they're images anyway. --- telegram.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/telegram.go b/telegram.go index 7897413..050086c 100644 --- a/telegram.go +++ b/telegram.go @@ -148,7 +148,10 @@ func (t *TelegramDaemon) Send(message *Message, ID ...int64) error { if message.Markdown == "" { msg = tg.NewMessage(id, message.Text) } else { - msg = tg.NewMessage(id, strings.ReplaceAll(message.Markdown, ".", "\\.")) + text := strings.ReplaceAll(message.Markdown, ".", "\\.") + text = strings.ReplaceAll(text, "![", "[") + text = strings.ReplaceAll(text, "!", "\\!") + msg = tg.NewMessage(id, text) msg.ParseMode = "MarkdownV2" } _, err := t.bot.Send(msg)