diff --git a/backend/internal/ktmtrainbot/backgroundbookingjob.go b/backend/internal/ktmtrainbot/backgroundbookingjob.go index 8822d0c..2307ae3 100644 --- a/backend/internal/ktmtrainbot/backgroundbookingjob.go +++ b/backend/internal/ktmtrainbot/backgroundbookingjob.go @@ -318,9 +318,8 @@ func (env *Env) startBooking(job *Booking, username string, password string, cre // // Defer done with debug screenshot // defer cancelDebugScreenshot() - time.Sleep(600 * time.Second) + time.Sleep(10 * time.Second) _ = page - browser.MustClose() return true } @@ -435,6 +434,15 @@ func selectBookingSlot(ctx context.Context, page *rod.Page, timeCode string) *ro time.Sleep(1000 * time.Millisecond) } + // Repeat if there's no seats -- seats might be released later + if strings.Contains(bodyText, "Not enough seat for onward trip") { + completed = false + + closeModalButton := page.MustElement("#popupModalCloseButton") + closeModalButton.Eval(`this.click()`) + time.Sleep(1000 * time.Millisecond) + } + styleAttribute := selectButtonElement.MustAttribute("style") if styleAttribute == nil || !strings.Contains(*styleAttribute, "display: none") { completed = false