虎牙精英宝典

This commit is contained in:
yml2213
2026-08-31 19:34:59 +08:00
parent d391e2ce3e
commit 955ba45488
16 changed files with 743 additions and 5 deletions
+20
View File
@@ -14,6 +14,7 @@ from ..huya_defaults import HUYA_CONFIG_DEFAULTS, HUYA_CONFIG_FIELDS
from ..models import HuyaAccount, HuyaConfig, HuyaTask
SUPPORTED_TASK_TYPES = {
"query_act_tasks": "查询精英宝典任务",
"get_bind_qr": "获取绑定二维码",
"query_points": "一键查询积分",
"query_game_name": "一键查询游戏名",
@@ -25,6 +26,19 @@ SUPPORTED_TASK_TYPES = {
"create_recharge_order": "生成支付二维码",
}
HUYA_HANDBOOK_TASK_TYPES = {
"query_act_tasks",
"get_bind_qr",
"confirm_bind",
"query_points",
"query_game_name",
"refresh_goods",
"exchange_goods",
"query_exchange_records",
"refresh_recharge_goods",
"create_recharge_order",
}
def huya_config_value(field: str, value: str | None) -> str:
"""读取配置值;空值自动回退到当前活动默认配置。"""
@@ -371,10 +385,15 @@ def create_planned_tasks(
task_type: str,
created_by: int,
payload: dict | None = None,
handbook_scope: str = "legacy",
) -> tuple[str, int]:
"""创建虎牙任务记录,等待后台执行器消费。"""
if task_type not in SUPPORTED_TASK_TYPES:
raise ValueError("不支持的任务类型")
if handbook_scope not in {"legacy", "elite"}:
raise ValueError("无效的工作台")
if handbook_scope == "elite" and task_type not in HUYA_HANDBOOK_TASK_TYPES:
raise ValueError("该任务不属于精英宝典工作台")
batch_id = uuid.uuid4().hex[:12]
payload = payload or {}
@@ -392,6 +411,7 @@ def create_planned_tasks(
batch_id=batch_id,
account_id=account.id,
task_type=task_type,
handbook_scope=handbook_scope,
status="planned",
message="任务已创建,等待执行",
result={"payload": payload} if payload else None,