diff --git a/README.md b/README.md index 76c7842..679fd95 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ ![example.png](./docs/example-logs.jpg) +![checkin.png](./docs/checkin.png) + ## Features - [x] Line Notify support after checkin. diff --git a/act/api.go b/act/api.go index c7dc649..573e5b5 100644 --- a/act/api.go +++ b/act/api.go @@ -182,23 +182,31 @@ func (e *DailyHoyolab) GetCheckInInfo(hoyo *Hoyolab) (*ActInfo, error) { return &res, nil } -func (e *DailyHoyolab) DailySignIn(hoyo *Hoyolab) (*ActSign, error) { +type ActSignRisk map[string]any + +func (e *DailyHoyolab) DailySignIn(hoyo *Hoyolab) (bool, error) { time.Sleep(1 * time.Second) raw, err := hoyo.ActRequest(e).SetBody(map[string]string{"act_id": e.ActID}).Post(fmt.Sprintf("%s%s", e.API.Endpoint, e.API.Sign)) if err != nil { - return nil, fmt.Errorf("api::%+v", err) + return false, fmt.Errorf("api::%+v", err) } if raw.StatusCode() != 200 { - return nil, fmt.Errorf("api::%s", raw.Status()) + return false, fmt.Errorf("api::%s", raw.Status()) } var res ActSign if err := actResponse(raw, &res); err != nil { - return nil, fmt.Errorf("api::%+v", err) + return false, fmt.Errorf("api::%+v", err) } if IsDebug { log.Printf("%s::%+v\n", e.Label, res) } - return &res, nil + + risk := res["gt_result"].(map[string]any) + if risk["risk_code"].(float64) > 0 { + return true, nil + } + + return false, nil } diff --git a/docs/checkin.png b/docs/checkin.png new file mode 100644 index 0000000..ac19272 Binary files /dev/null and b/docs/checkin.png differ diff --git a/main.go b/main.go index 14a6a8c..1094913 100644 --- a/main.go +++ b/main.go @@ -128,11 +128,19 @@ func main() { continue } - _, err = act.DailySignIn(hoyo) + isRisk, err := act.DailySignIn(hoyo) if err != nil { log.Printf("%s::DailySignIn : %v", act.Label, err) continue } + if isRisk { + if hoyo.Notify.Mini { + getAward = append(getAward, fmt.Sprintf("Challenge captcha (%s)", act.Label)) + } else { + getAward = append(getAward, fmt.Sprintf("*[%s]* at day %d challenge captcha", act.Label, resInfo.TotalSignDay+1)) + } + continue + } if getDaySign < 0 { getDaySign = resInfo.TotalSignDay + 1