Skip to content

Commit

Permalink
simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
alaingilbert committed Aug 7, 2022
1 parent cdb6104 commit 28c2a35
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions ogame.go
Original file line number Diff line number Diff line change
Expand Up @@ -1113,27 +1113,23 @@ func postSessions(b *OGame, gameEnvironmentID, platformGameID, username, passwor
parts := strings.Split(gfChallengeIDValue, ";")
challengeID = parts[0]

if tried {
if tried || b.captchaCallback == nil {
return out, errors.New("captcha required, " + challengeID)
}
tried = true

if b.captchaCallback != nil {
questionRaw, iconsRaw, err := startCaptchaChallenge(b.Client, challengeID)
if err != nil {
return out, errors.New("failed to start captcha challenge: " + err.Error())
}
answer, err := b.captchaCallback(questionRaw, iconsRaw)
if err != nil {
return out, errors.New("failed to get answer for captcha challenge: " + err.Error())
}
if err := solveChallenge(b.Client, challengeID, answer); err != nil {
return out, errors.New("failed to solve captcha challenge: " + err.Error())
}
continue
questionRaw, iconsRaw, err := startCaptchaChallenge(b.Client, challengeID)
if err != nil {
return out, errors.New("failed to start captcha challenge: " + err.Error())
}

return out, errors.New("captcha required, " + challengeID)
answer, err := b.captchaCallback(questionRaw, iconsRaw)
if err != nil {
return out, errors.New("failed to get answer for captcha challenge: " + err.Error())
}
if err := solveChallenge(b.Client, challengeID, answer); err != nil {
return out, errors.New("failed to solve captcha challenge: " + err.Error())
}
continue
}
}

Expand Down

0 comments on commit 28c2a35

Please sign in to comment.