From 74fb430697cd3987d9ef3db2c3cbf76b4f73da43 Mon Sep 17 00:00:00 2001 From: luginbash <725033+luginbash@users.noreply.github.com> Date: Sat, 21 May 2022 20:58:45 +0800 Subject: [PATCH] Adding comment button to telegram message if there's any --- integration/telegrambot/telegrambot.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/integration/telegrambot/telegrambot.go b/integration/telegrambot/telegrambot.go index 70377a6f..b24974bc 100644 --- a/integration/telegrambot/telegrambot.go +++ b/integration/telegrambot/telegrambot.go @@ -35,6 +35,14 @@ func PushEntry(entry *model.Entry, botToken, chatID string) error { msg := tgbotapi.NewMessage(chatIDInt, result.String()) msg.ParseMode = tgbotapi.ModeHTML msg.DisableWebPagePreview = false + + if entry.CommentsURL != "" { + msg.ReplyMarkup = tgbotapi.NewInlineKeyboardMarkup( + tgbotapi.NewInlineKeyboardRow( + tgbotapi.NewInlineKeyboardButtonURL("Comments", entry.CommentsURL), + )) + } + if _, err := bot.Send(msg); err != nil { return fmt.Errorf("telegrambot: sending message failed: %w", err) }