package bot import ( "fmt" "telegramvpn/internal/config" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" ) const ( cbUserConfig = "user:config" cbUserHome = "user:home" cbAdminMenu = "admin:menu" cbAdminUser = "admin:user" cbAdminSquads = "admin:squads" cbAdminCheck = "admin:check" cbAdminConfig = "admin:config" ) func trialDays(cfg *config.Config) int { d := cfg.TrialUserDays if d <= 0 { return 1 } return d } func userConfigLabel(cfg *config.Config) string { return fmt.Sprintf("🔐 Подключить VPN · %d дн.", trialDays(cfg)) } func userHomeLabel() string { return "🏠 Главная" } func adminPanelLabel() string { return "🛠 Админ-панель" } // userMenuKeyboard — главное меню пользователя (и выход из админки). func userMenuKeyboard(cfg *config.Config, userID, adminID int64) tgbotapi.InlineKeyboardMarkup { rows := [][]tgbotapi.InlineKeyboardButton{ tgbotapi.NewInlineKeyboardRow( tgbotapi.NewInlineKeyboardButtonData(userConfigLabel(cfg), cbUserConfig), ), } if userID == adminID { rows = append(rows, tgbotapi.NewInlineKeyboardRow( tgbotapi.NewInlineKeyboardButtonData(adminPanelLabel(), cbAdminMenu), )) } return tgbotapi.NewInlineKeyboardMarkup(rows...) } // configResultKeyboard — после выдачи конфига: ссылка + возврат в меню. func configResultKeyboard(cfg *config.Config, userID, adminID int64, subscriptionURL string) tgbotapi.InlineKeyboardMarkup { var rows [][]tgbotapi.InlineKeyboardButton if subscriptionURL != "" { rows = append(rows, tgbotapi.NewInlineKeyboardRow( tgbotapi.NewInlineKeyboardButtonURL("🔗 Открыть подписку", subscriptionURL), )) } rows = append(rows, tgbotapi.NewInlineKeyboardRow( tgbotapi.NewInlineKeyboardButtonData(userConfigLabel(cfg), cbUserConfig), ), tgbotapi.NewInlineKeyboardRow( tgbotapi.NewInlineKeyboardButtonData(userHomeLabel(), cbUserHome), ), ) if userID == adminID { rows = append(rows, tgbotapi.NewInlineKeyboardRow( tgbotapi.NewInlineKeyboardButtonData(adminPanelLabel(), cbAdminMenu), )) } return tgbotapi.NewInlineKeyboardMarkup(rows...) } // adminMenuKeyboard — панель администратора. func adminMenuKeyboard() tgbotapi.InlineKeyboardMarkup { return tgbotapi.NewInlineKeyboardMarkup( tgbotapi.NewInlineKeyboardRow( tgbotapi.NewInlineKeyboardButtonData("👤 Новый пользователь", cbAdminUser), tgbotapi.NewInlineKeyboardButtonData("📡 Сквады", cbAdminSquads), ), tgbotapi.NewInlineKeyboardRow( tgbotapi.NewInlineKeyboardButtonData("🔌 Проверка API", cbAdminCheck), tgbotapi.NewInlineKeyboardButtonData("⚙️ Настройки", cbAdminConfig), ), tgbotapi.NewInlineKeyboardRow( tgbotapi.NewInlineKeyboardButtonURL("📖 Remnawave Docs", docsURL), ), tgbotapi.NewInlineKeyboardRow( tgbotapi.NewInlineKeyboardButtonData(userHomeLabel(), cbUserHome), ), ) } // adminContextKeyboard — под ответами админки (проверка, конфиг и т.д.). func adminContextKeyboard() tgbotapi.InlineKeyboardMarkup { return tgbotapi.NewInlineKeyboardMarkup( tgbotapi.NewInlineKeyboardRow( tgbotapi.NewInlineKeyboardButtonData("🛠 В админ-панель", cbAdminMenu), tgbotapi.NewInlineKeyboardButtonData(userHomeLabel(), cbUserHome), ), ) }