Telegram: Use markdown for custom emails/announcements

Had no idea telegram supported this, pretty cool.
This commit is contained in:
Harvey Tindall
2021-05-07 16:33:44 +01:00
parent 716d6a931a
commit 36edd4ab0d
2 changed files with 62 additions and 23 deletions
+8 -2
View File
@@ -193,10 +193,16 @@ func (t *TelegramDaemon) QuoteReply(upd *tg.Update, content string) error {
return err
}
// Send will send a telegram message to a list of chat IDs. message.text is used.
// Send will send a telegram message to a list of chat IDs. message.text is used if no markdown is given.
func (t *TelegramDaemon) Send(message *Message, ID ...int64) error {
for _, id := range ID {
msg := tg.NewMessage(id, message.Text)
var msg tg.MessageConfig
if message.Markdown == "" {
msg = tg.NewMessage(id, message.Text)
} else {
msg = tg.NewMessage(id, strings.ReplaceAll(message.Markdown, ".", "\\."))
msg.ParseMode = "MarkdownV2"
}
_, err := t.bot.Send(msg)
if err != nil {
return err