实现虎牙积分查询执行器

This commit is contained in:
yml2213
2026-07-04 17:07:29 +08:00
parent e1d47a85be
commit 56ffaf531c
6 changed files with 525 additions and 13 deletions
+26
View File
@@ -162,6 +162,16 @@ class HuyaHttpClient:
"input_1": str(item_count),
}
@staticmethod
def _build_activity_user(uid: int, cookie: str):
"""构造活动组件 UserId,与当前积分兑换组件保持一致。"""
from .activity_structs import ActivityUserId
user = ActivityUserId()
user.lUid = uid
user.sHuYaUA = "web&1.0&huya"
user.sCookie = cookie or ""
return user
def call_rpc(self, service: str, method: str,
req_struct: TafStruct, rsp_class=None,
uid: int = 0, guid: str = "", cookie: str = "",
@@ -233,6 +243,22 @@ class HuyaHttpClient:
# ---------- 业务便捷方法 ----------
def query_user_score(self, uid: int, cookie: str, sid: int, timeout: float = 15.0):
"""查询活动可用积分。"""
from .activity_structs import GetUserScoreReq, GetUserScoreResp
req = GetUserScoreReq()
req.userId = self._build_activity_user(uid, cookie)
req.sid = sid
return self.call_rpc(
"webActUI",
"getUserScore",
req,
GetUserScoreResp,
uid=uid,
cookie=cookie,
timeout=timeout,
)
def get_goods_info(self, uid, guid, cookie, pid, spu_id, sku_id=0, game_id="",
source_id="yellowcarlist", scene=7):
from .shop_structs import GetGoodsInfoReqV5, GoodsInfoRsp