1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

Telegram: add the possibility to disable buttons

Closes #2093
This commit is contained in:
Jany 2023-09-28 03:02:22 +00:00 committed by GitHub
parent c0e954f19d
commit e0e8a99abe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 85 additions and 44 deletions

View file

@ -9,7 +9,7 @@ import (
"miniflux.app/v2/internal/model"
)
func PushEntry(feed *model.Feed, entry *model.Entry, botToken, chatID string, topicID *int64, disableWebPagePreview, disableNotification 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(
textTemplate,
@ -31,19 +31,21 @@ func PushEntry(feed *model.Feed, entry *model.Entry, botToken, chatID string, to
message.MessageThreadID = *topicID
}
var markupRow []*InlineKeyboardButton
if !disableButtons {
var markupRow []*InlineKeyboardButton
minifluxURLButton := InlineKeyboardButton{Text: "Go to article", URL: entry.URL}
markupRow = append(markupRow, &minifluxURLButton)
minifluxURLButton := InlineKeyboardButton{Text: "Go to article", URL: entry.URL}
markupRow = append(markupRow, &minifluxURLButton)
if entry.CommentsURL != "" {
commentButton := InlineKeyboardButton{Text: "Comments", URL: entry.CommentsURL}
markupRow = append(markupRow, &commentButton)
if entry.CommentsURL != "" {
commentButton := InlineKeyboardButton{Text: "Comments", URL: entry.CommentsURL}
markupRow = append(markupRow, &commentButton)
}
message.ReplyMarkup = &InlineKeyboard{}
message.ReplyMarkup.InlineKeyboard = append(message.ReplyMarkup.InlineKeyboard, markupRow)
}
message.ReplyMarkup = &InlineKeyboard{}
message.ReplyMarkup.InlineKeyboard = append(message.ReplyMarkup.InlineKeyboard, markupRow)
client := NewClient(botToken, chatID)
_, err := client.SendMessage(message)
return err