切换虎牙宝典活动任务到WSS会话

This commit is contained in:
yml2213
2026-09-01 12:23:43 +08:00
parent 17e72d40a5
commit 2fca1210bb
3 changed files with 26 additions and 20 deletions
+6 -17
View File
@@ -8,8 +8,6 @@ from typing import TYPE_CHECKING, Any
from sqlalchemy.orm import Session
from core.huya import HuyaHttpClient
from ..models import HuyaAccount, HuyaGoodsSnapshot, HuyaTask
@@ -27,6 +25,7 @@ class GoodsMixin:
def _resolve_uid(self, account_info: dict) -> int: ...
def _push_log(self, level: str, message: str) -> None: ...
def _activity_client(self, uid: int, cookie: str): ...
def _mark_task(self, *args: Any, **kwargs: Any) -> None: ...
def _wait_until(self, when: datetime, uid: int) -> bool: ...
def _parse_scheduled_time(self, value: Any) -> datetime | None: ...
@@ -49,9 +48,7 @@ class GoodsMixin:
if not act_id:
self._mark_task(worker_db, task, "failed", "精英宝典活动 ID 无效")
return
client: Any = HuyaHttpClient(
logger=lambda msg: self._push_log("info", f"[{uid}] {msg}")
)
client: Any = self._activity_client(uid, cookie)
response = client.get_act_task_detail(uid=uid, cookie=cookie, act_id=act_id)
if response is None:
self._mark_task(worker_db, task, "error", "虎牙活动任务接口无响应")
@@ -111,9 +108,7 @@ class GoodsMixin:
self._mark_task(worker_db, task, "failed", "账号 Cookie 为空")
return
client: Any = HuyaHttpClient(
logger=lambda msg: self._push_log("info", f"[{uid}] {msg}")
)
client: Any = self._activity_client(uid, cookie)
response = client.query_user_score(uid=uid, cookie=cookie, sid=sid_int)
if response is None:
self._mark_task(worker_db, task, "error", "虎牙积分接口无响应")
@@ -165,9 +160,7 @@ class GoodsMixin:
self._mark_task(worker_db, task, "failed", "账号 Cookie 为空")
return
client: Any = HuyaHttpClient(
logger=lambda msg: self._push_log("info", f"[{uid}] {msg}")
)
client: Any = self._activity_client(uid, cookie)
response = client.get_user_prize_records(uid=uid, cookie=cookie, sid=sid_int)
if response is None:
self._mark_task(worker_db, task, "error", "虎牙兑换记录接口无响应")
@@ -228,9 +221,7 @@ class GoodsMixin:
self._mark_task(worker_db, task, "failed", "账号 Cookie 为空")
return
client: Any = HuyaHttpClient(
logger=lambda msg: self._push_log("info", f"[{uid}] {msg}")
)
client: Any = self._activity_client(uid, cookie)
response = client.get_act_prize_list(uid=uid, cookie=cookie, sid=sid_int)
if response is None:
self._mark_task(worker_db, task, "error", "虎牙商品列表接口无响应")
@@ -327,9 +318,7 @@ class GoodsMixin:
self._mark_task(worker_db, task, "stopped", "兑换任务已停止")
return
client: Any = HuyaHttpClient(
logger=lambda msg: self._push_log("info", f"[{uid}] {msg}")
)
client: Any = self._activity_client(uid, cookie)
detail = client.get_act_prize_detail(
uid=uid, cookie=cookie, sid=sid_int, pid=product_id
)