Telegram: replace feed HTML link with a button to avoid page preview issues

This commit is contained in:
Frédéric Guillot 2023-09-27 20:20:09 -07:00
parent a7e08054da
commit 39d752ca85

View file

@ -10,11 +10,8 @@ import (
) )
func PushEntry(feed *model.Feed, entry *model.Entry, botToken, chatID string, topicID *int64, disableWebPagePreview, disableNotification bool, disableButtons bool) error { func PushEntry(feed *model.Feed, entry *model.Entry, botToken, chatID string, topicID *int64, disableWebPagePreview, disableNotification bool, disableButtons bool) error {
textTemplate := `<b><a href=%q>%s</a></b> - <a href=%q>%s</a>`
formattedText := fmt.Sprintf( formattedText := fmt.Sprintf(
textTemplate, `<a href=%q>%s</a>`,
feed.SiteURL,
feed.Title,
entry.URL, entry.URL,
entry.Title, entry.Title,
) )
@ -34,12 +31,15 @@ func PushEntry(feed *model.Feed, entry *model.Entry, botToken, chatID string, to
if !disableButtons { if !disableButtons {
var markupRow []*InlineKeyboardButton var markupRow []*InlineKeyboardButton
minifluxURLButton := InlineKeyboardButton{Text: "Go to article", URL: entry.URL} websiteURLButton := InlineKeyboardButton{Text: "Go to website", URL: feed.SiteURL}
markupRow = append(markupRow, &minifluxURLButton) markupRow = append(markupRow, &websiteURLButton)
articleURLButton := InlineKeyboardButton{Text: "Go to article", URL: entry.URL}
markupRow = append(markupRow, &articleURLButton)
if entry.CommentsURL != "" { if entry.CommentsURL != "" {
commentButton := InlineKeyboardButton{Text: "Comments", URL: entry.CommentsURL} commentURLButton := InlineKeyboardButton{Text: "Comments", URL: entry.CommentsURL}
markupRow = append(markupRow, &commentButton) markupRow = append(markupRow, &commentURLButton)
} }
message.ReplyMarkup = &InlineKeyboard{} message.ReplyMarkup = &InlineKeyboard{}