get events for start buttons from database instead of hardcoded ones
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
This commit is contained in:
parent
0949b1c812
commit
2abb18cb49
@ -227,11 +227,24 @@ func handleChannelPost(bc BotController, update tgbotapi.Update) {
|
|||||||
func handleStartCommand(bc BotController, update tgbotapi.Update, user User) {
|
func handleStartCommand(bc BotController, update tgbotapi.Update, user User) {
|
||||||
bc.db.Model(&user).Update("state", "start")
|
bc.db.Model(&user).Update("state", "start")
|
||||||
rows := [][]tgbotapi.InlineKeyboardButton{}
|
rows := [][]tgbotapi.InlineKeyboardButton{}
|
||||||
for _, d := range nearestDates {
|
events, _ := bc.GetAllEvents()
|
||||||
k, v := getDateButton(d)
|
for _, event := range events {
|
||||||
|
if event.Date.Sub(time.Now()) < 2*time.Hour {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
k, _ := getDateButton(*event.Date)
|
||||||
|
taken, _ := bc.CountReservationsByEventID(event.ID)
|
||||||
|
k = strings.Join([]string{
|
||||||
|
k,
|
||||||
|
"(" + strconv.FormatInt(taken, 10) + "/" + strconv.Itoa(seatscnt) + ")",
|
||||||
|
}, " ")
|
||||||
|
if taken == seatscnt {
|
||||||
|
k += " (Распродано)"
|
||||||
|
}
|
||||||
|
token := "reservedate:" + strconv.FormatInt(event.ID, 10)
|
||||||
rows = append(rows,
|
rows = append(rows,
|
||||||
tgbotapi.NewInlineKeyboardRow(
|
tgbotapi.NewInlineKeyboardRow(
|
||||||
tgbotapi.NewInlineKeyboardButtonData(k, v),
|
tgbotapi.NewInlineKeyboardButtonData(k, token),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user