From db805c0aa49c902e02355f9c7184dc881c8adcfd Mon Sep 17 00:00:00 2001 From: Aykhan Shahsuvarov Date: Fri, 23 Aug 2024 14:20:41 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Handle=20warnings=20when=20no=20?= =?UTF-8?q?flights=20are=20available=20for=20a=20given=20day?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index 5aafac2..9fb4481 100644 --- a/main.go +++ b/main.go @@ -88,6 +88,7 @@ func (responseTime *ResponseTime) UnmarshalJSON(b []byte) error { } type SuccessResponse struct { + Warnings []any `json:"warnings"` Search struct { OptionSets []struct { Options []struct { @@ -461,6 +462,10 @@ func startBot(botConfig *BotConfig, ifAvailable func(avialableFlights AvialableF continue } + if len(data.Warnings) > 0 { + log.Println(Colored(Colors.Yellow, "No flights available for ", day)) + continue + } for _, option := range data.Search.OptionSets[0].Options { departureDate := option.Route.DepartureDate if (departureDate.After(botConfig.FirstDate) || departureDate.Equal(botConfig.FirstDate)) &&