From f340b0c622119a91d9465b2d74a688ea5a35a01c Mon Sep 17 00:00:00 2001 From: thftgr Date: Tue, 10 Sep 2024 22:47:01 +0900 Subject: [PATCH] fix login bug --- banchoCrawler/osuApi.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/banchoCrawler/osuApi.go b/banchoCrawler/osuApi.go index 291bb7c..ca34f71 100644 --- a/banchoCrawler/osuApi.go +++ b/banchoCrawler/osuApi.go @@ -3,8 +3,10 @@ package banchoCrawler import ( "bytes" "encoding/base64" + "fmt" "github.com/Nerinyan/Nerinyan-APIV2/config" "github.com/goccy/go-json" + "github.com/pkg/errors" "github.com/pterm/pterm" "io/ioutil" "mime/multipart" @@ -64,7 +66,7 @@ func parseTokenExpiraton() (t int64) { func tryLogin() (err error) { spinner, _ := pterm.DefaultSpinner.Start("Trying Login Bancho...") if err = login(true); err != nil { - spinner.Fail("fail refresh Bancho Token") + spinner.Fail("fail refresh Bancho Token: ", err) if err = login(false); err != nil { return } @@ -145,5 +147,8 @@ func login(refresh bool) (err error) { return } + if res.StatusCode != 200 { + return errors.New(fmt.Sprint(res.StatusCode, string(body))) + } return json.Unmarshal(body, &config.Config.Osu.Token) }