All checks were successful
CI / build (push) Successful in 54s
- Remove playlist handler, keyboard, and all related callback routing - Strip playlist parameter from YouTube Music radio URLs, reject pure playlists - Send media preview before format selection prompt (correct ordering) - Remove DetectPlaylist/GetPlaylistInfo methods (no longer needed) - Remove IsPlaylist, PlaylistCount, PlaylistEntries from MediaInfo - Remove PlaylistState struct, keep PlaylistEntry for search results - Update README to reflect removal of playlist feature
94 lines
2.8 KiB
Go
94 lines
2.8 KiB
Go
package handler
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/go-telegram/bot/models"
|
|
)
|
|
|
|
func mainKeyboard() models.InlineKeyboardMarkup {
|
|
return models.InlineKeyboardMarkup{
|
|
InlineKeyboard: [][]models.InlineKeyboardButton{
|
|
{
|
|
{Text: "Download", CallbackData: "download"},
|
|
{Text: "Search", CallbackData: "search"},
|
|
{Text: "Settings", CallbackData: "settings"},
|
|
},
|
|
{
|
|
{Text: "History", CallbackData: "history"},
|
|
{Text: "Help", CallbackData: "help"},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func backKeyboard() models.InlineKeyboardMarkup {
|
|
return models.InlineKeyboardMarkup{
|
|
InlineKeyboard: [][]models.InlineKeyboardButton{
|
|
{{Text: "Back to Menu", CallbackData: "back_menu"}},
|
|
},
|
|
}
|
|
}
|
|
|
|
func settingsBackKeyboard() models.InlineKeyboardMarkup {
|
|
return models.InlineKeyboardMarkup{
|
|
InlineKeyboard: [][]models.InlineKeyboardButton{
|
|
{{Text: "Back to Settings", CallbackData: "back_settings"}},
|
|
},
|
|
}
|
|
}
|
|
|
|
// formatKeyboard builds a 2-column inline keyboard from labels with corresponding callback data values.
|
|
// The prefix is prepended to each data value to form the full callback data.
|
|
func formatKeyboard(prefix string, labels, data []string) models.InlineKeyboardMarkup {
|
|
rows := [][]models.InlineKeyboardButton{}
|
|
row := []models.InlineKeyboardButton{}
|
|
for i, label := range labels {
|
|
cb := prefix + data[i]
|
|
row = append(row, models.InlineKeyboardButton{Text: label, CallbackData: cb})
|
|
if len(row) == 2 || i == len(labels)-1 {
|
|
rows = append(rows, row)
|
|
row = nil
|
|
}
|
|
}
|
|
rows = append(rows, []models.InlineKeyboardButton{
|
|
{Text: "Back", CallbackData: "back_step"},
|
|
{Text: "Cancel", CallbackData: "cancel_dl"},
|
|
})
|
|
return models.InlineKeyboardMarkup{InlineKeyboard: rows}
|
|
}
|
|
|
|
// languageKeyboard builds a keyboard from available languages.
|
|
func languageKeyboard(languages []string) models.InlineKeyboardMarkup {
|
|
return formatKeyboard("lang_", languages, languages)
|
|
}
|
|
|
|
// progressKeyboard builds the progress display with a dummy button and cancel.
|
|
func progressKeyboard(pct float64, speed, eta string) models.InlineKeyboardMarkup {
|
|
progressText := fmt.Sprintf("%.1f%%", pct)
|
|
if speed != "" {
|
|
progressText += fmt.Sprintf(" | %s", speed)
|
|
}
|
|
if eta != "" {
|
|
progressText += fmt.Sprintf(" | ETA %s", eta)
|
|
}
|
|
return models.InlineKeyboardMarkup{
|
|
InlineKeyboard: [][]models.InlineKeyboardButton{
|
|
{{Text: progressText, CallbackData: "noop"}},
|
|
{{Text: "Cancel", CallbackData: "cancel_dl"}},
|
|
},
|
|
}
|
|
}
|
|
|
|
// deleteConfirmKeyboard builds the confirmation prompt for account deletion.
|
|
func deleteConfirmKeyboard(userID int64) models.InlineKeyboardMarkup {
|
|
return models.InlineKeyboardMarkup{
|
|
InlineKeyboard: [][]models.InlineKeyboardButton{
|
|
{
|
|
{Text: "Yes, delete everything", CallbackData: fmt.Sprintf("delaccount_%d", userID), Style: "danger"},
|
|
{Text: "Cancel", CallbackData: "back_settings"},
|
|
},
|
|
},
|
|
}
|
|
}
|