Skip to content

Commit

Permalink
fix: Challenge captcha
Browse files Browse the repository at this point in the history
  • Loading branch information
dvgamerr committed Jun 6, 2023
1 parent efbbd4a commit f1a0bfc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

![example.png](./docs/example-logs.jpg)

![checkin.png](./docs/checkin.png)

## Features
- [x] Line Notify support after checkin.

Expand Down
18 changes: 13 additions & 5 deletions act/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Binary file added docs/checkin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f1a0bfc

Please sign in to comment.