Files
huya-go/README.md
T
2026-07-06 18:47:10 +08:00

99 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# huya-go
虎牙活动积分兑换/抢购的 Go 复刻版。当前支持两种传输层:
- `http`:走 `https://cdnws.api.huya.com/`,兼容原有命令。
- `wss`:实验实现。已按浏览器 HAR 改为 TAF `WebSocketCommand` 外层和 WSS 初始化流程,仍建议先用真实 Cookie 小流量验证。
## 构建
CLI:
```bash
go test ./...
go build -o huya-go ./cmd/huya-go
```
GUI:
```bash
cd frontend
npm install
npm run typecheck
cd ..
wails build -debug -nopackage
```
GUI 二进制输出到 `build/bin/huya-gui`。开发时可以使用 `wails dev` 启动 Wails + React + Ant Design 界面。
## Cookie
推荐把账号 Cookie 放到本地文件,一行一个账号:
```text
yyuid=...; udb_uid=...; guid=...; ...
```
不要把 Cookie、token、JWT 提交到仓库或写进文档。
## 常用命令
GUI 界面提供账号预览、奖品列表、积分查询、兑换记录、直接兑换、监控抢购、实时日志。
CLI 示例:
查询奖品列表:
```bash
./huya-go -cmd list -sid 2203 -cookie-file cookie.txt
```
查询积分:
```bash
./huya-go -cmd score -sid 2203 -cookie-file cookie.txt
```
直接兑换指定 PID:
```bash
./huya-go -cmd exchange -sid 2203 -pid 12889 -cookie-file cookie.txt -transport http
```
按奖品名轮询并抢购:
```bash
./huya-go -cmd monitor -sid 2203 -name 小黄鸭 -cookie-file cookie.txt -transport http -loops 20 -delay 120 -concurrency 5
```
定时开始:
```bash
./huya-go -cmd monitor -sid 2203 -pid 12889 -cookie-file cookie.txt -transport http -at "2026-07-06 20:00:00"
```
## 参数说明
- `-cmd`:`list`、`score`、`records`、`exchange`、`monitor`。
- `-sid`:活动 SID,必填。
- `-pid`:奖品 PID。`exchange` 必填,`monitor` 可用 `-pid` 或 `-name`。
- `-cookie`:单账号 Cookie。
- `-cookie-file`:多账号 Cookie 文件。
- `-transport`:`http` 或 `wss`,默认 `http`;WSS 仍为实验通道。
- `-wss-host`:WebSocket host。默认值来自 2026-07-06 手动抓包,失效时应从浏览器抓包或 `launch.queryHttpDns` 结果更新。
- `-timeout`:单次调用超时秒数。
- `-loops`、`-delay`、`-concurrency`:轮询次数、轮询间隔、并发账号数。
- `-stop-after-success`:`monitor` 中任一账号成功后是否停止。
- `-v`:输出调试日志。
## 已确认的小黄鸭参数
2026-07-06 浏览器手动抢购抓包确认:
- `sid=2203`
- `pid=12889`
- 奖品名:`套装-潮萌小黄鸭`
- 消耗积分:`988`
远端配置里的子奖品代码不能直接当兑换 PID,实际兑换以 `scoreExchangePrize` 请求里的 `pid` 为准。