fix: ui ввода формата

This commit is contained in:
Artem Tsyrulnikov
2026-02-28 13:16:24 +03:00
parent c9d5f1e2ea
commit 751f3b657a

View File

@@ -402,16 +402,6 @@ func (s *PurchaseOptionalDetails) HandleCallback(b *bot.Bot, u *echotron.Update)
s.Enter(b, bot.EditMessage) s.Enter(b, bot.EditMessage)
return return
} }
if u.CallbackQuery.Data == "format_custom_top_input_mode" {
s.InputMode = "format_custom_top_input"
s.Enter(b, bot.EditMessage)
return
}
if u.CallbackQuery.Data == "format_custom_feed_input_mode" {
s.InputMode = "format_custom_feed_input"
s.Enter(b, bot.EditMessage)
return
}
if u.CallbackQuery.Data == "format_custom_back_to_select" { if u.CallbackQuery.Data == "format_custom_back_to_select" {
s.InputMode = "format_select" s.InputMode = "format_select"
s.Enter(b, bot.EditMessage) s.Enter(b, bot.EditMessage)
@@ -464,10 +454,9 @@ func (s *PurchaseOptionalDetails) HandleMessage(b *bot.Bot, u *echotron.Update)
} }
switch s.InputMode { switch s.InputMode {
case "format_custom_top_input": case "format_custom":
value, err := strconv.Atoi(text) value, err := strconv.Atoi(text)
if err != nil || value <= 0 { if err != nil || value <= 0 {
s.renderInputPrompt(b, bot.EditMessage)
return return
} }
// Конвертируем в минуты по текущей единице // Конвертируем в минуты по текущей единице
@@ -478,10 +467,9 @@ func (s *PurchaseOptionalDetails) HandleMessage(b *bot.Bot, u *echotron.Update)
s.InputMode = "format_custom_feed" s.InputMode = "format_custom_feed"
s.Enter(b, bot.NewMessage) s.Enter(b, bot.NewMessage)
return return
case "format_custom_feed_input": case "format_custom_feed":
value, err := strconv.Atoi(text) value, err := strconv.Atoi(text)
if err != nil || value <= 0 { if err != nil || value <= 0 {
s.renderInputPrompt(b, bot.EditMessage)
return return
} }
// Конвертируем в минуты по текущей единице // Конвертируем в минуты по текущей единице
@@ -861,23 +849,9 @@ func (s *PurchaseOptionalDetails) renderInputPrompt(b *bot.Bot, mode bot.RenderM
case "format_custom": case "format_custom":
s.renderCustomFormatTop(b, mode) s.renderCustomFormatTop(b, mode)
return return
case "format_custom_top_input":
text += "<b>Введите число для времени в топе</b>\n\n"
unit := "часах"
if s.CustomFormatTopUnit == "minutes" {
unit = "минутах"
}
text += fmt.Sprintf("Единица: <b>%s</b>", unit)
case "format_custom_feed": case "format_custom_feed":
s.renderCustomFormatFeed(b, mode) s.renderCustomFormatFeed(b, mode)
return return
case "format_custom_feed_input":
text += "<b>Введите число для времени в ленте</b>\n\n"
unit := "часах"
if s.CustomFormatFeedUnit == "days" {
unit = "днях"
}
text += fmt.Sprintf("Единица: <b>%s</b>", unit)
case "invite_link_type": case "invite_link_type":
text = "<i>Страница выбора типа ссылки</i>\n\n" text = "<i>Страница выбора типа ссылки</i>\n\n"
if s.CurrentChannel != "" { if s.CurrentChannel != "" {
@@ -938,8 +912,7 @@ func (s *PurchaseOptionalDetails) renderCustomFormatTop(b *bot.Bot, mode bot.Ren
var rows [][]echotron.InlineKeyboardButton var rows [][]echotron.InlineKeyboardButton
if s.CustomFormatTopUnit == "minutes" { if s.CustomFormatTopUnit == "minutes" {
text += "⏱ Единица: <b>минуты</b>\n\n" text += "Выберите или введите число (в минутах):"
text += "Выберите время в топе"
rows = append(rows, rows = append(rows,
Row( Row(
Button("10", "format_custom_top:10"), Button("10", "format_custom_top:10"),
@@ -953,14 +926,10 @@ func (s *PurchaseOptionalDetails) renderCustomFormatTop(b *bot.Bot, mode bot.Ren
Button("90", "format_custom_top:90"), Button("90", "format_custom_top:90"),
Button("120", "format_custom_top:120"), Button("120", "format_custom_top:120"),
), ),
Row( Row(Button("⏱ В часах", "format_custom_top_toggle_unit")),
Button("↔ Часы", "format_custom_top_toggle_unit"),
Button("Ввести число", "format_custom_top_input_mode"),
),
) )
} else { } else {
text += "⏱ Единица: <b>часы</b>\n\n" text += "Выберите или введите число (в часах):"
text += "Выберите время в топе"
rows = append(rows, rows = append(rows,
Row( Row(
Button("1", "format_custom_top:60"), Button("1", "format_custom_top:60"),
@@ -974,10 +943,7 @@ func (s *PurchaseOptionalDetails) renderCustomFormatTop(b *bot.Bot, mode bot.Ren
Button("8", "format_custom_top:480"), Button("8", "format_custom_top:480"),
Button("12", "format_custom_top:720"), Button("12", "format_custom_top:720"),
), ),
Row( Row(Button("⏱ В минутах", "format_custom_top_toggle_unit")),
Button("↔ Минуты", "format_custom_top_toggle_unit"),
Button("Ввести число", "format_custom_top_input_mode"),
),
) )
} }
@@ -999,8 +965,7 @@ func (s *PurchaseOptionalDetails) renderCustomFormatFeed(b *bot.Bot, mode bot.Re
var rows [][]echotron.InlineKeyboardButton var rows [][]echotron.InlineKeyboardButton
if s.CustomFormatFeedUnit == "days" { if s.CustomFormatFeedUnit == "days" {
text += "⏱ Единица: <b>дни</b>\n\n" text += "Выберите или введите число (в днях):"
text += "Выберите время в ленте"
rows = append(rows, rows = append(rows,
Row( Row(
Button("7", "format_custom_feed:10080"), Button("7", "format_custom_feed:10080"),
@@ -1015,13 +980,12 @@ func (s *PurchaseOptionalDetails) renderCustomFormatFeed(b *bot.Bot, mode bot.Re
Button("365", "format_custom_feed:525600"), Button("365", "format_custom_feed:525600"),
), ),
Row( Row(
Button("↔ Часы", "format_custom_feed_toggle_unit"), Button("В часах", "format_custom_feed_toggle_unit"),
Button("Без удаления", "format_custom_feed:0"), Button("Без удаления", "format_custom_feed:0"),
), ),
) )
} else { } else {
text += "⏱ Единица: <b>часы</b>\n\n" text += "Выберите или введите число (в часах):"
text += "Выберите время в ленте"
rows = append(rows, rows = append(rows,
Row( Row(
Button("24", "format_custom_feed:1440"), Button("24", "format_custom_feed:1440"),
@@ -1036,16 +1000,13 @@ func (s *PurchaseOptionalDetails) renderCustomFormatFeed(b *bot.Bot, mode bot.Re
Button("168", "format_custom_feed:10080"), Button("168", "format_custom_feed:10080"),
), ),
Row( Row(
Button("↔ Дни", "format_custom_feed_toggle_unit"), Button("В днях", "format_custom_feed_toggle_unit"),
Button("Без удаления", "format_custom_feed:0"), Button("Без удаления", "format_custom_feed:0"),
), ),
) )
} }
rows = append(rows, rows = append(rows, Row(Button("← Назад", "format_custom_back_to_top")))
Row(Button("Ввести число", "format_custom_feed_input_mode")),
Row(Button("← Назад", "format_custom_back_to_top")),
)
b.Render(text, Keyboard(rows...), mode) b.Render(text, Keyboard(rows...), mode)
} }