Adding comment button to telegram message if there's any

This commit is contained in:
luginbash 2022-05-21 20:58:45 +08:00 committed by Frédéric Guillot
parent d118aa8649
commit 74fb430697
1 changed files with 8 additions and 0 deletions

View File

@ -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)
}