api

package
v0.0.0-...-914f9a4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LabUA       = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) miHoYoBBS/" + XRpcVersion
	LabMobileUA = "Mozilla/5.0 (Linux; Android 12) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/106.0.5249.126 Mobile Safari/537.36 miHoYoBBS/" + XRpcVersion //nolint:lll
	OkHTTPUA    = "okhttp/4.8.0"
)
View Source
const (
	XRpcVersion = "2.44.1"
)

Variables

View Source
var (
	ErrInvalidPayload     = errors.New("invalid payload")
	ErrRequestBodyInvalid = errors.New("request body invalid")
)
View Source
var ErrQrcodeLoginNotConfirmed = errors.New("QR code login not confirmed")

Functions

func GenerateDS

func GenerateDS(s string, payload any, query string) string

func GenerateLabHeaders

func GenerateLabHeaders(cookie string, query string) map[string]string

func SendRequest

func SendRequest(r RequestInterface, payload any, v ResponseInterface) error

Types

type CookieToken

type CookieToken struct {
	UID         string `json:"uid"`
	CookieToken string `json:"cookie_token"`
}

type CookieTokenRequest

type CookieTokenRequest struct {
	Request
	AccountID string `json:"account_id"`
	GameToken string `json:"game_token"`
}

func NewCookieTokenReq

func NewCookieTokenReq(id, token string) *CookieTokenRequest

func (*CookieTokenRequest) Do

func (r *CookieTokenRequest) Do() (*CookieToken, error)

type CookieTokenResponse

type CookieTokenResponse struct {
	Response
	Data CookieToken `json:"data"`
}

type GameRecord

type GameRecord struct {
	GameID     int              `json:"game_id"`
	Level      int              `json:"level"`
	RegionName string           `json:"region_name"`
	Region     string           `json:"region"`
	GameRoleID string           `json:"game_role_id"`
	NickName   string           `json:"nickname"`
	Data       []GameRecordData `json:"data"`
}

type GameRecordData

type GameRecordData struct {
	Name  string `json:"name"`
	Type  int    `json:"type"`
	Value string `json:"value"`
}

type GameRecordRequest

type GameRecordRequest struct {
	Request
	AccountID   string `json:"account_id"`
	CookieToken string `json:"cookie_token"`
}

func NewGameRecordReq

func NewGameRecordReq(id, cookieToken string) *GameRecordRequest

func (*GameRecordRequest) Do

type GameRecordResponse

type GameRecordResponse struct {
	Response
	Data GameRecordResponseData `json:"data"`
}

type GameRecordResponseData

type GameRecordResponseData struct {
	GameRecords []GameRecord `json:"list"`
}

type GameToken

type GameToken struct {
	UID   string `json:"uid"`
	Token string `json:"token"`
}

type QrcodeCheckPool

type QrcodeCheckPool struct {
	Tasks chan QrcodeCheckTask
	// contains filtered or unexported fields
}

func NewQrcodeCheckPool

func NewQrcodeCheckPool() *QrcodeCheckPool

func (*QrcodeCheckPool) Add

func (p *QrcodeCheckPool) Add(ctx telebot.Context, userID int64, r *QrcodeQueryRequest)

func (*QrcodeCheckPool) IsRunning

func (p *QrcodeCheckPool) IsRunning(userID int64) bool

func (*QrcodeCheckPool) Worker

func (p *QrcodeCheckPool) Worker()

type QrcodeCheckTask

type QrcodeCheckTask struct {
	Context     telebot.Context
	UserID      int64
	QrcodeQuery *QrcodeQueryRequest
}

func (*QrcodeCheckTask) ProcessingToken

func (t *QrcodeCheckTask) ProcessingToken(raw string)

type QrcodeFetchPayload

type QrcodeFetchPayload struct {
	AppID  int    `json:"app_id"`
	Device string `json:"device"`
}

type QrcodeFetchRequest

type QrcodeFetchRequest struct {
	Request
}

func NewQrcodeFetch

func NewQrcodeFetch() *QrcodeFetchRequest

func (*QrcodeFetchRequest) Do

func (*QrcodeFetchRequest) ToImage

func (r *QrcodeFetchRequest) ToImage(url string) ([]byte, error)

type QrcodeFetchResponse

type QrcodeFetchResponse struct {
	Response
	Data QrcodeFetchResponseData `json:"data"`
}

type QrcodeFetchResponseData

type QrcodeFetchResponseData struct {
	URL    string `json:"url"`
	AppID  int    `json:"app_id"`
	Device string `json:"device"`
	Ticket string `json:"ticket"`
}

type QrcodeQueryPayload

type QrcodeQueryPayload struct {
	AppID  int    `json:"app_id"`
	Device string `json:"device"`
	Ticket string `json:"ticket"`
}

type QrcodeQueryRequest

type QrcodeQueryRequest struct {
	Request
	QrcodeQueryPayload
}

func NewQrcodeQuery

func NewQrcodeQuery(appID int, device string, ticket string) *QrcodeQueryRequest

func (*QrcodeQueryRequest) Do

func (*QrcodeQueryRequest) ParseGameToken

func (r *QrcodeQueryRequest) ParseGameToken(raw string) (*GameToken, error)

type QrcodeQueryResponse

type QrcodeQueryResponse struct {
	Response
	Data QrcodeQueryResponseData `json:"data"`
}

type QrcodeQueryResponseData

type QrcodeQueryResponseData struct {
	Stat    string                         `json:"stat"`
	Payload QrcodeQueryResponseDataPayload `json:"payload"`
}

type QrcodeQueryResponseDataPayload

type QrcodeQueryResponseDataPayload struct {
	Proto string `json:"proto"`
	Raw   string `json:"raw"`
	Ext   string `json:"ext"`
}

type Request

type Request struct {
	URL     string            `json:"url"`
	Method  string            `json:"method"`
	Headers map[string]string `json:"headers"`
}

func (*Request) GetHeaders

func (r *Request) GetHeaders() map[string]string

func (*Request) GetMethod

func (r *Request) GetMethod() string

func (*Request) GetURL

func (r *Request) GetURL() string

type RequestInterface

type RequestInterface interface {
	GetURL() string
	GetMethod() string
	GetHeaders() map[string]string
}

type Response

type Response struct {
	RetCode int    `json:"retcode"`
	Message string `json:"message"`
}

func (*Response) GetRetCode

func (r *Response) GetRetCode() int

type ResponseInterface

type ResponseInterface interface {
	GetRetCode() int
}

type SToken

type SToken struct {
	TokenType int    `json:"token_type"`
	Token     string `json:"token"`
}

type STokenPayload

type STokenPayload struct {
	AccountID int64  `json:"account_id"`
	GameToken string `json:"game_token"`
}

type STokenRequest

type STokenRequest struct {
	Request
	STokenPayload
}

func NewSTokenReq

func NewSTokenReq(id int64, token string) *STokenRequest

func (*STokenRequest) Do

type STokenResponse

type STokenResponse struct {
	Response
	Data STokenResponseData `json:"data"`
}

type STokenResponseData

type STokenResponseData struct {
	Token    SToken   `json:"token"`
	UserInfo UserInfo `json:"user_info"`
}

type UserInfo

type UserInfo struct {
	AccountName string `json:"account_name"`
	MID         string `json:"mid"`
	AID         string `json:"aid"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL