1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-12-23 01:20:11 +00:00

Telegram: Escape exclamation marks, remove for images

![alt](link) becomes [alt](link), telegram seems to pick up that they're
images anyway.
This commit is contained in:
Harvey Tindall 2021-05-22 23:32:30 +01:00
parent 8b816dc725
commit 478b40d0ff
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2

View File

@ -148,7 +148,10 @@ func (t *TelegramDaemon) Send(message *Message, ID ...int64) error {
if message.Markdown == "" { if message.Markdown == "" {
msg = tg.NewMessage(id, message.Text) msg = tg.NewMessage(id, message.Text)
} else { } 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" msg.ParseMode = "MarkdownV2"
} }
_, err := t.bot.Send(msg) _, err := t.bot.Send(msg)