From 81de8addf1e05de380f0e1200e8bebf4feba2541 Mon Sep 17 00:00:00 2001 From: NoahK <30934296+stnokott@users.noreply.github.com> Date: Wed, 5 Oct 2022 14:35:01 +0200 Subject: [PATCH] feat: MarkdownV2 for Telegram announcer (#3435) Set MarkdownV2 as parse mode for Telegram announcer. This allows for additional formatting in the announcement, such as `code` or _italic_ sections. For details, see the official [Telegram Bot API](https://core.telegram.org/bots/api#markdownv2-style). If someone has the time (not added in this PR), I think it would be great to add a field to the Telegram config for the parse mode. This would allow setting a different parse mode than MarkdownV2, such as HTML. This fixes #3431. --- internal/pipe/telegram/telegram.go | 1 + www/docs/customization/announce/telegram.md | 2 ++ 2 files changed, 3 insertions(+) diff --git a/internal/pipe/telegram/telegram.go b/internal/pipe/telegram/telegram.go index 7ef62bdc775..160979cfe9e 100644 --- a/internal/pipe/telegram/telegram.go +++ b/internal/pipe/telegram/telegram.go @@ -46,6 +46,7 @@ func (Pipe) Announce(ctx *context.Context) error { } tm := api.NewMessage(ctx.Config.Announce.Telegram.ChatID, msg) + tm.ParseMode = "MarkdownV2" _, err = bot.Send(tm) if err != nil { return fmt.Errorf("announce: failed to announce to telegram: %w", err) diff --git a/www/docs/customization/announce/telegram.md b/www/docs/customization/announce/telegram.md index d5c9e6b8a86..08555cc022d 100644 --- a/www/docs/customization/announce/telegram.md +++ b/www/docs/customization/announce/telegram.md @@ -25,5 +25,7 @@ announce: message_template: 'Awesome project {{.Tag}} is out!' ``` +You can format your message using MarkdownV2, for reference, see the [Telegram Bot API](https://core.telegram.org/bots/api#markdownv2-style). + !!! tip Learn more about the [name template engine](/customization/templates/).