143 lines
2.6 KiB
Go
143 lines
2.6 KiB
Go
package sati
|
|
|
|
import (
|
|
"encoding/base64"
|
|
)
|
|
|
|
type AnyTask interface {
|
|
serialize() task
|
|
Result() any
|
|
}
|
|
|
|
type task struct {
|
|
Type string `json:"type"`
|
|
Data any `json:"data"`
|
|
}
|
|
|
|
type TurnstileTask struct {
|
|
SiteKey string `json:"siteKey"`
|
|
PageUrl string `json:"pageUrl"`
|
|
CData *string `json:"cData,omitempty"`
|
|
Action *string `json:"action,omitempty"`
|
|
Proxy *string `json:"proxy,omitempty"`
|
|
}
|
|
|
|
func (t *TurnstileTask) serialize() task {
|
|
return task{
|
|
Type: "Turnstile",
|
|
Data: t,
|
|
}
|
|
}
|
|
|
|
func (t *TurnstileTask) Result() any {
|
|
return &TurnstileResult{}
|
|
}
|
|
|
|
type TurnstileResult struct {
|
|
Token string `json:"token"`
|
|
}
|
|
|
|
type ReCaptcha2Task struct {
|
|
SiteKey string `json:"siteKey"`
|
|
PageUrl string `json:"pageUrl"`
|
|
Proxy *string `json:"proxy,omitempty"`
|
|
}
|
|
|
|
func (t *ReCaptcha2Task) serialize() task {
|
|
return task{
|
|
Type: "ReCaptcha2",
|
|
Data: t,
|
|
}
|
|
}
|
|
|
|
func (t *ReCaptcha2Task) Result() any {
|
|
return &ReCaptcha2Result{}
|
|
}
|
|
|
|
type ReCaptcha2Result struct {
|
|
Token string `json:"token"`
|
|
}
|
|
|
|
type FunCaptchaTask struct {
|
|
SiteKey string `json:"siteKey"`
|
|
PageUrl string `json:"pageUrl"`
|
|
Data map[string]string `json:"data,omitempty"`
|
|
ServiceUrl *string `json:"serviceUrl,omitempty"`
|
|
Proxy *string `json:"proxy,omitempty"`
|
|
}
|
|
|
|
func (t *FunCaptchaTask) serialize() task {
|
|
return task{
|
|
Type: "FunCaptcha",
|
|
Data: t,
|
|
}
|
|
}
|
|
|
|
func (t *FunCaptchaTask) Result() any {
|
|
return &FunCaptchaResult{}
|
|
}
|
|
|
|
type FunCaptchaResult struct {
|
|
Token string `json:"token"`
|
|
}
|
|
|
|
type GeeTest3Task struct {
|
|
SiteKey string `json:"siteKey"`
|
|
PageUrl string `json:"pageUrl"`
|
|
Challenge string `json:"challenge"`
|
|
ApiServer *string `json:"apiServer,omitempty"`
|
|
Proxy *string `json:"proxy,omitempty"`
|
|
}
|
|
|
|
func (t *GeeTest3Task) serialize() task {
|
|
return task{
|
|
Type: "GeeTest3",
|
|
Data: t,
|
|
}
|
|
}
|
|
|
|
func (t *GeeTest3Task) Result() any {
|
|
return &GeeTest3Result{}
|
|
}
|
|
|
|
type GeeTest3Result struct {
|
|
Challenge string `json:"challenge"`
|
|
Validate string `json:"validate"`
|
|
Seccode string `json:"seccode"`
|
|
}
|
|
|
|
type ImageToTextTask struct {
|
|
Image []byte `json:"-"`
|
|
Type *string `json:"type"`
|
|
}
|
|
|
|
func (t *ImageToTextTask) serialize() task {
|
|
return task{
|
|
Type: "ImageToText",
|
|
Data: map[string]any{
|
|
"image": base64.RawStdEncoding.EncodeToString(t.Image),
|
|
"type": t.Type,
|
|
},
|
|
}
|
|
}
|
|
|
|
func (t *ImageToTextTask) Result() any {
|
|
return &ImageToTextResult{}
|
|
}
|
|
|
|
type ImageToTextResult struct {
|
|
Result string `json:"result"`
|
|
}
|
|
|
|
type RawTask task
|
|
|
|
func (t *RawTask) serialize() task {
|
|
return task(*t)
|
|
}
|
|
|
|
type RawTaskResult map[string]any
|
|
|
|
func (t *RawTask) Result() any {
|
|
return RawTaskResult{}
|
|
}
|