From c4e4a0deca3b733fa790fb99c125fc6e2548e9e3 Mon Sep 17 00:00:00 2001 From: Kananek Thongkam Date: Fri, 9 Jun 2023 14:30:20 +0700 Subject: [PATCH] fix: Challenge captcha alert --- act/api.go | 9 +++++---- main.go | 22 ++++++++++------------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/act/api.go b/act/api.go index 573e5b5..0eae536 100644 --- a/act/api.go +++ b/act/api.go @@ -203,10 +203,11 @@ func (e *DailyHoyolab) DailySignIn(hoyo *Hoyolab) (bool, error) { log.Printf("%s::%+v\n", e.Label, res) } - risk := res["gt_result"].(map[string]any) - if risk["risk_code"].(float64) > 0 { - return true, nil + if res["gt_result"] != nil { + risk := res["gt_result"].(map[string]any) + if risk["risk_code"].(float64) > 0 { + return true, nil + } } - return false, nil } diff --git a/main.go b/main.go index 1094913..ebfba81 100644 --- a/main.go +++ b/main.go @@ -133,15 +133,6 @@ func main() { 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 } @@ -150,11 +141,18 @@ func main() { log.Printf("%s::GetMonthAward : Today's received %s x%d", act.Label, award.Name, award.Count) if hoyo.Notify.Mini { - getAward = append(getAward, fmt.Sprintf("*%s x%d* (%s)", award.Name, award.Count, act.Label)) + if isRisk { + getAward = append(getAward, fmt.Sprintf("Challenge captcha (%s)", act.Label)) + } else { + getAward = append(getAward, fmt.Sprintf("*%s x%d* (%s)", award.Name, award.Count, act.Label)) + } } else { - getAward = append(getAward, fmt.Sprintf("*[%s]* at day %d received %s x%d", act.Label, resInfo.TotalSignDay+1, award.Name, award.Count)) + if isRisk { + getAward = append(getAward, fmt.Sprintf("*[%s]* at day %d challenge captcha", act.Label, resInfo.TotalSignDay+1)) + } else { + getAward = append(getAward, fmt.Sprintf("*[%s]* at day %d received %s x%d", act.Label, resInfo.TotalSignDay+1, award.Name, award.Count)) + } } - } if len(getAward) > 0 { if len(hoyo.Browser) > 1 {