api

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AppSaltK2 https://blog.starudream.cn/2023/11/09/miyoushe-salt-2.62.2/
	AppSaltK2 = "WGtruoQrwczmsjLOPXzJLnaAYycsLavx" // 2.73.1
	// AppSalt6X https://github.com/UIGF-org/mihoyo-api-collect/issues/1
	AppSalt6X = "t0qEgfub6cvueAPgR5m9aQWWVciEer7v"
)
View Source
const (
	AddrPassport     = "https://passport-api.mihoyo.com"
	AddrHK4E         = "https://hk4e-sdk.mihoyo.com"
	AddrTakumi       = "https://api-takumi.mihoyo.com"
	AddrTakumiRecord = "https://api-takumi-record.mihoyo.com"
	AddrActNap       = "https://act-nap-api.mihoyo.com"
	AddrBBS          = "https://bbs-api.miyoushe.com"

	RefererApp = "https://app.mihoyo.com"
	RefererAct = "https://act.mihoyo.com"

	AppVersion    = "2.73.1"
	AppIdMiyoushe = "bll8iq97cem8" // 米游社

	UserAgent = "Mozilla/5.0 (Linux; Android 13; 22011211C Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/104.0.5112.97 Mobile Safari/537.36 miHoYoBBS/" + AppVersion

	GameIdBH3 = "1" // 崩坏3
	GameIdYS  = "2" // 原神
	GameIdBH2 = "3" // 崩坏学园2
	GameIdWD  = "4" // 未定事件簿
	GameIdDBY = "5" // 大别野
	GameIdSR  = "6" // 崩坏:星穹铁道
	GameIdZZZ = "8" // 绝区零

	GameNameBH3 = "bh3"
	GameNameYS  = "hk4e"
	GameNameBH2 = "bh2"
	GameNameWD  = "nxx"
	GameNameSR  = "hkrpg"
	GameNameZZZ = "nap"

	GameBizBH3CN = GameNameBH3 + "_" + cn
	GameBizYSCN  = GameNameYS + "_" + cn
	GameBizBH2CN = GameNameBH2 + "_" + cn
	GameBizWDCN  = GameNameWD + "_" + cn
	GameBizSRCN  = GameNameSR + "_" + cn
	GameBizZZZCN = GameNameZZZ + "_" + cn

	ForumIdSR = "53"
)
View Source
const (
	RetCodeSendPhoneNeedGeetest = -3101 // 发送验证码需要验证码
	RetCodeGameHasSigned        = -5003 // 已签到
	RetCodeForumHasSigned       = 1008  // 打卡失败或重复打卡
	RetCodeForumNeedGeetest     = 1034  // 需要验证码
)

Variables

View Source
var (
	GameIdByName = map[string]string{
		GameNameBH3: GameIdBH3,
		GameNameYS:  GameIdYS,
		GameNameSR:  GameIdSR,
		GameNameZZZ: GameIdZZZ,
	}

	GameIdByBiz = map[string]string{
		GameBizBH3CN: GameIdBH3,
		GameBizYSCN:  GameIdYS,
		GameBizBH2CN: GameIdBH2,
		GameBizWDCN:  GameIdWD,
		GameBizSRCN:  GameIdSR,
		GameBizZZZCN: GameIdZZZ,
	}

	GameCNNameById = map[string]string{
		GameIdBH3: "崩坏3",
		GameIdYS:  "原神",
		GameIdSR:  "崩坏:星穹铁道",
		GameIdZZZ: "绝区零",
	}
)

Functions

func Exec

func Exec[T any](r *resty.Request, method, url string, args ...any) (t T, _ error)

func GetAigisData

func GetAigisData(err error) (string, *geetest.V3Param)

func IsRetCode

func IsRetCode(err error, rc int) bool

func RSAEncrypt

func RSAEncrypt(content string) string

Types

type Aigis

type Aigis struct {
	SessionId string `json:"session_id"`
	MmtType   int    `json:"mmt_type"`
	Data      string `json:"data"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(account config.Account) *Client

func (*Client) CollectPost

func (c *Client) CollectPost(postId string, cancel bool) error

func (*Client) CreateVerification

func (c *Client) CreateVerification() (*geetest.V3Param, error)

func (*Client) GetBusinesses

func (c *Client) GetBusinesses() (*GetBusinessesData, error)

func (*Client) GetHome

func (c *Client) GetHome(gameId string) (*GetHomeData, error)

func (*Client) GetPost

func (c *Client) GetPost(postId string) (*GetPostData, error)

func (*Client) GetSignForum

func (c *Client) GetSignForum(gameId string) (*GetSignForumData, error)

func (*Client) GetSignGame

func (c *Client) GetSignGame(gameName, actId, region, uid string) (*GetSignGameData, error)

func (*Client) GetUser

func (c *Client) GetUser(uid string) (*GetUserData, error)

func (*Client) ListFeedPost

func (c *Client) ListFeedPost(gameId string) (*ListPostData, error)

func (*Client) ListGameRole

func (c *Client) ListGameRole(gameBiz string) (*ListGameRoleData, error)

func (*Client) ListPost

func (c *Client) ListPost(forumId, lastId string) (*ListPostData, error)

func (*Client) ListSignGame

func (c *Client) ListSignGame(gameName, actId string) (*ListSignGameData, error)

func (*Client) ListSignGameAward

func (c *Client) ListSignGameAward(gameName, actId, region, uid string) (list SignGameAwards, _ error)

func (*Client) ListSignGameAwardPage

func (c *Client) ListSignGameAwardPage(gameName, actId, region, uid string, page, pageSize int) (list SignGameAwards, _ error)

func (*Client) LoginByPhoneCode

func (c *Client) LoginByPhoneCode(code string) (*LoginByPhoneCodeData, error)

func (*Client) R

func (c *Client) R() *resty.Request

func (*Client) SendPhoneCode

func (c *Client) SendPhoneCode(aigis string) (*SendPhoneCodeData, error)

func (*Client) SharePost

func (c *Client) SharePost(postId string) (*SharePostData, error)

func (*Client) SignForum

func (c *Client) SignForum(gameId string, gt *geetest.V3Data) (*SignForumData, error)

func (*Client) SignGame

func (c *Client) SignGame(gameName, actId, region, uid string, gt *geetest.V3Data) (*SignGameData, error)

func (*Client) UpvotePost

func (c *Client) UpvotePost(postId string, cancel bool) error

func (*Client) VerifyVerification

func (c *Client) VerifyVerification(challenge, validate string) (*VerifyVerificationData, error)

type GameRole

type GameRole struct {
	GameBiz    string `json:"game_biz"`
	Region     string `json:"region"`
	GameUid    string `json:"game_uid"`
	Nickname   string `json:"nickname"`
	Level      int    `json:"level"`
	IsChosen   bool   `json:"is_chosen"`
	RegionName string `json:"region_name"`
	IsOfficial bool   `json:"is_official"`
}

type GetBusinessesData

type GetBusinessesData struct {
	Businesses []string `json:"businesses"`
}

type GetCTokenBySTokenData

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

type GetHomeData

type GetHomeData struct {
	Navigator []*HomeNav `json:"navigator"`
}

func (*GetHomeData) GetSignActId

func (t *GetHomeData) GetSignActId() string

type GetLTokenBySTokenData

type GetLTokenBySTokenData struct {
	LToken string `json:"ltoken"`
}

type GetPostData

type GetPostData struct {
	Post *PostData `json:"post"`
}

type GetSignForumData

type GetSignForumData struct {
	IsSigned bool `json:"is_signed"`
}

type GetSignGameData

type GetSignGameData struct {
	TotalSignDay  int    `json:"total_sign_day"`
	Today         string `json:"today"`
	IsSign        bool   `json:"is_sign"`
	IsSub         bool   `json:"is_sub"`
	Region        string `json:"region"`
	SignCntMissed int    `json:"sign_cnt_missed"`
	ShortSignDay  int    `json:"short_sign_day"`
}

type GetUserData

type GetUserData struct {
	UserInfo *UserInfo `json:"user_info"`
}

type HomeNav

type HomeNav struct {
	Id      int    `json:"id"`
	Name    string `json:"name"`
	AppPath string `json:"app_path"`
}

type ListGameRoleData

type ListGameRoleData struct {
	List []*GameRole `json:"list"`
}

type ListPostData

type ListPostData struct {
	IsLast   bool        `json:"is_last"`
	IsOrigin bool        `json:"is_origin"`
	LastId   string      `json:"last_id"`
	List     []*PostData `json:"list"`
}

type ListSignGameAwardData

type ListSignGameAwardData struct {
	Total int            `json:"total"`
	List  SignGameAwards `json:"list"`
}

func (*ListSignGameAwardData) GetList

type ListSignGameData

type ListSignGameData struct {
	Month      int                 `json:"month"`
	Biz        string              `json:"biz"`
	Resign     bool                `json:"resign"`
	Awards     []*SignGameAward    `json:"awards"`
	ExtraAward *SignGameExtraAward `json:"short_extra_award"`
}

type LoginByPhoneCodeData

type LoginByPhoneCodeData struct {
	Token    *TokenInfo     `json:"token"`
	UserInfo *LoginUserInfo `json:"user_info"`
}

type LoginUserInfo

type LoginUserInfo struct {
	Aid string `json:"aid"` // uid
	Mid string `json:"mid"`
}

type PostData

type PostData struct {
	Post          *PostInfo          `json:"post"`
	Stat          *PostStat          `json:"stat"`
	User          *PostUser          `json:"user"`
	SelfOperation *PostSelfOperation `json:"self_operation"`
}

func (*PostData) IsCollected

func (p *PostData) IsCollected() bool

func (*PostData) IsUpvote

func (p *PostData) IsUpvote() bool

type PostInfo

type PostInfo struct {
	PostId    string `json:"post_id"`
	Subject   string `json:"subject"`
	Content   string `json:"content"`
	MaxFloor  int    `json:"max_floor"`
	ReplyTime string `json:"reply_time"`
	CreatedAt int    `json:"created_at"`
	UpdatedAt int    `json:"updated_at"`
}

type PostSelfOperation

type PostSelfOperation struct {
	Attitude    int  `json:"attitude"`
	IsCollected bool `json:"is_collected"`
	UpvoteType  int  `json:"upvote_type"`
}

type PostStat

type PostStat struct {
	BookmarkNum int `json:"bookmark_num"`
	ForwardNum  int `json:"forward_num"`
	LikeNum     int `json:"like_num"`
	ReplyNum    int `json:"reply_num"`
	ViewNum     int `json:"view_num"`
}

type PostUser

type PostUser struct {
	Uid      string `json:"uid"`
	Nickname string `json:"nickname"`
}

type SendPhoneCodeData

type SendPhoneCodeData struct {
	SentNew    bool   `json:"sent_new"`
	Countdown  int    `json:"countdown"`
	ActionType string `json:"action_type"`
}

type SharePostData

type SharePostData struct {
	Title   string `json:"title"`
	Content string `json:"content"`
	Icon    string `json:"icon"`
	Url     string `json:"url"`
}

type SignDS

type SignDS int
const (
	SignDS1 SignDS = iota
	SignDS2
)

type SignForumData

type SignForumData struct {
	Points int `json:"points"`
}

type SignGameAward

type SignGameAward struct {
	Name      string `json:"name"`
	Cnt       int    `json:"cnt"`
	CreatedAt string `json:"created_at,omitempty"`
}

type SignGameAwards

type SignGameAwards []*SignGameAward

func (SignGameAwards) ShortString

func (v1 SignGameAwards) ShortString() string

func (SignGameAwards) Today

func (v1 SignGameAwards) Today() (v2 SignGameAwards)

type SignGameData

type SignGameData struct {
	Code      string `json:"code"`
	Success   int    `json:"success"`
	IsRisk    bool   `json:"is_risk"`
	RiskCode  int    `json:"risk_code"`
	Gt        string `json:"gt"`
	Challenge string `json:"challenge"`
}

func (*SignGameData) IsRisky

func (t *SignGameData) IsRisky() bool

type SignGameExtraAward

type SignGameExtraAward struct {
	HasExtraAward  bool   `json:"has_extra_award"`
	StartTime      string `json:"start_time"`
	EndTime        string `json:"end_time"`
	List           []any  `json:"list"`
	StartTimestamp string `json:"start_timestamp"`
	EndTimestamp   string `json:"end_timestamp"`
}

type TokenInfo

type TokenInfo struct {
	TokenType int    `json:"token_type"` // 1
	Token     string `json:"token"`      // stoken_v2
}

type UserInfo

type UserInfo struct {
	Uid      string `json:"uid"`
	Nickname string `json:"nickname"`
}

type VerifyVerificationData

type VerifyVerificationData struct {
	Challenge string `json:"challenge"`
}

Jump to

Keyboard shortcuts

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