mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
feat(telegrambot): Replace Telegram bot button
Added a button to the Telegram bot integration that directs users to the specific Miniflux entry.
This commit is contained in:
parent
c45b51d1f8
commit
0024558e56
1 changed files with 14 additions and 2 deletions
|
@ -5,8 +5,12 @@ package telegrambot // import "miniflux.app/v2/internal/integration/telegrambot"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log/slog"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"miniflux.app/v2/internal/config"
|
||||||
"miniflux.app/v2/internal/model"
|
"miniflux.app/v2/internal/model"
|
||||||
|
"miniflux.app/v2/internal/urllib"
|
||||||
)
|
)
|
||||||
|
|
||||||
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 {
|
||||||
|
@ -32,8 +36,16 @@ func PushEntry(feed *model.Feed, entry *model.Entry, botToken, chatID string, to
|
||||||
if !disableButtons {
|
if !disableButtons {
|
||||||
var markupRow []*InlineKeyboardButton
|
var markupRow []*InlineKeyboardButton
|
||||||
|
|
||||||
websiteURLButton := InlineKeyboardButton{Text: "Go to website", URL: feed.SiteURL}
|
baseURL := config.Opts.BaseURL()
|
||||||
markupRow = append(markupRow, &websiteURLButton)
|
entryPath := "/unread/entry/" + strconv.FormatInt(entry.ID, 10)
|
||||||
|
|
||||||
|
minifluxEntryURL, err := urllib.JoinBaseURLAndPath(baseURL, entryPath)
|
||||||
|
if err != nil {
|
||||||
|
slog.Error("Unable to create Miniflux entry URL", slog.Any("error", err))
|
||||||
|
} else {
|
||||||
|
minifluxEntryURLButton := InlineKeyboardButton{Text: "Go to Miniflux", URL: minifluxEntryURL}
|
||||||
|
markupRow = append(markupRow, &minifluxEntryURLButton)
|
||||||
|
}
|
||||||
|
|
||||||
articleURLButton := InlineKeyboardButton{Text: "Go to article", URL: entry.URL}
|
articleURLButton := InlineKeyboardButton{Text: "Go to article", URL: entry.URL}
|
||||||
markupRow = append(markupRow, &articleURLButton)
|
markupRow = append(markupRow, &articleURLButton)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue