Skip to content

Commit

Permalink
fixed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaph committed May 15, 2023
1 parent 1afc765 commit b82ba77
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
13 changes: 11 additions & 2 deletions acmethods.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func antiCaptchaMethods(solver *Solver, preferredDomain string) *solveMethods {
return r
}

createTask := func(task map[string]interface{}) (int, error) {
createTask := func(task map[string]interface{}) (any, error) {
d := domain()

payload := map[string]interface{}{
Expand Down Expand Up @@ -57,6 +57,11 @@ func antiCaptchaMethods(solver *Solver, preferredDomain string) *solveMethods {
return 0, errors.New("no taskId")
}

taskStr, ok := taskId.(string)
if ok {
return taskStr, nil
}

return int(taskId.(float64)), nil
}

Expand Down Expand Up @@ -126,7 +131,7 @@ func antiCaptchaMethods(solver *Solver, preferredDomain string) *solveMethods {
}

// keeps retrying until it has returned error or solved
getResponse := func(taskId int) (*Solution, error) {
getResponse := func(taskId any) (*Solution, error) {
for {
time.Sleep(solver.UpdateDelay)

Expand Down Expand Up @@ -251,6 +256,10 @@ func antiCaptchaMethods(solver *Solver, preferredDomain string) *solveMethods {
taskData["userAgent"] = o.UserAgent
}

if o.APIDomain != "" {
taskData["apiDomain"] = o.APIDomain
}

if o.Cookies != nil && len(o.Cookies) > 0 {
taskData["cookies"] = cookiesToString(o.Cookies)
}
Expand Down
8 changes: 6 additions & 2 deletions captchas.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,15 @@ type RecaptchaV2Options struct {
Invisible bool
// Enterprise only works on some captcha services (optional)
Enterprise map[string]interface{}
// APIDomain is the domain of the recaptcha (optional)
APIDomain string
}

type Solution struct {
Text string
TaskId int
Text string

// TaskId is normally a int, but can be a string depending on the service
TaskId any

// RawSolution not supported on 2captcha methods
RawSolution map[string]interface{}
Expand Down
8 changes: 8 additions & 0 deletions tcmethods.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ func twoCaptchaMethods(solver *Solver, preferredDomain string) *solveMethods {
payload["data-s"] = o.DataS
}

if o.APIDomain != "" {
payload["domain"] = o.APIDomain
}

if o.Enterprise != nil {
payload["enterprise"] = 1
}

if o.Cookies != nil && len(o.Cookies) > 0 {
payload["cookies"] = cookiesToString(o.Cookies)
}
Expand Down

0 comments on commit b82ba77

Please sign in to comment.