From 369c64e7c63453216722ad019eb2acb6eabc4727 Mon Sep 17 00:00:00 2001 From: Luca Bernstein Date: Thu, 9 Dec 2021 16:11:29 +0100 Subject: [PATCH 1/2] Switch default compose tag to release --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9d564b5..d00dfca 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,7 @@ services: - POSTGRES_USER=$POSTGRES_USER - POSTGRES_PASSWORD=$POSTGRES_PASSWORD app: - image: ghcr.io/lucabernstein/beancount-bot-tg:main + image: ghcr.io/lucabernstein/beancount-bot-tg:release container_name: bc_tg_bot restart: unless-stopped networks: From 67ad8b18e0496c0bf247e65c8e631013bab3c053 Mon Sep 17 00:00:00 2001 From: Luca Bernstein Date: Fri, 10 Dec 2021 09:45:19 +0100 Subject: [PATCH 2/2] Escape markdown chars in version --- bot/config.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bot/config.go b/bot/config.go index 344ca9d..2186d7c 100644 --- a/bot/config.go +++ b/bot/config.go @@ -197,13 +197,20 @@ func (bc *BotController) configHandleAbout(m *tb.Message, params ...string) { if version == "" { version = "not specified" } - _, err := bc.Bot.Send(m.Sender, fmt.Sprintf(`Version information about [LucaBernstein/beancount\-bot\-tg](https://github.com/LucaBernstein/beancount\-bot\-tg) + _, err := bc.Bot.Send(m.Sender, escapeCharacters(fmt.Sprintf(`Version information about [LucaBernstein/beancount-bot-tg](https://github.com/LucaBernstein/beancount-bot-tg) Version: [%s](%s)`, version, - strings.ReplaceAll(versionLink, "-", "\\-"), - ), tb.ModeMarkdownV2) + versionLink, + ), ".", "-"), tb.ModeMarkdownV2) if err != nil { bc.Logf(ERROR, m, "Sending bot message failed: %s", err.Error()) } } + +func escapeCharacters(s string, c ...string) string { + for _, char := range c { + s = strings.ReplaceAll(s, char, "\\"+char) + } + return s +}