fix(huya): 区分当前绑定与待确认角色
This commit is contained in:
@@ -74,8 +74,17 @@ class EliteMixin:
|
||||
def _bind_role_result(bind_status) -> dict: ...
|
||||
@staticmethod
|
||||
def _bind_change_state(bind_status) -> dict: ...
|
||||
def _bind_query_roles(
|
||||
self, bind_status: Any, bind_query_result: dict[str, Any]
|
||||
) -> tuple[dict, dict | None, dict | None]: ...
|
||||
@staticmethod
|
||||
def _bind_change_state_from_role(role_info: dict | None) -> dict: ...
|
||||
@staticmethod
|
||||
def _role_channel(bind_status) -> str: ...
|
||||
@staticmethod
|
||||
def _apply_role_info_to_account(
|
||||
account: HuyaAccount, role_info: dict | None, status: str
|
||||
) -> None: ...
|
||||
def _resolve_bind_status(
|
||||
self, client: Any, uid: int, cookie: str, b_act_id_int: int
|
||||
): ...
|
||||
@@ -363,7 +372,8 @@ class EliteMixin:
|
||||
result: dict[str, Any] = {"uid": uid}
|
||||
failures: list[str] = []
|
||||
message_parts: list[str] = []
|
||||
role_name = ""
|
||||
current_role_name = ""
|
||||
pending_role_name = ""
|
||||
|
||||
# ---- 角色绑定 / CK 有效性(先做,失效就不空跑后面两个接口) ----
|
||||
protocol = self._bind_protocol(config_info, self.payload)
|
||||
@@ -411,21 +421,55 @@ class EliteMixin:
|
||||
bind_status.msg or f"角色信息查询失败: {bind_status.status}"
|
||||
)
|
||||
else:
|
||||
role_info = self._bind_role_result(bind_status)
|
||||
role_name = role_info.get("role_name") or ""
|
||||
selected_info, current_info, pending_info = self._bind_query_roles(
|
||||
bind_status, bind_query_result
|
||||
)
|
||||
role_info = current_info or pending_info or selected_info
|
||||
current_role_name = str((current_info or {}).get("role_name") or "")
|
||||
pending_role_name = str((pending_info or {}).get("role_name") or "")
|
||||
has_role_split = (
|
||||
"current_role" in bind_query_result
|
||||
or "pending_role" in bind_query_result
|
||||
)
|
||||
change_state = (
|
||||
self._bind_change_state_from_role(current_info)
|
||||
if has_role_split and current_info
|
||||
else self._bind_change_state(bind_status)
|
||||
)
|
||||
result.update(
|
||||
{
|
||||
**role_info,
|
||||
**self._bind_change_state(bind_status),
|
||||
**change_state,
|
||||
**bind_query_result,
|
||||
"role_name": current_role_name or pending_role_name,
|
||||
"current_role_name": current_role_name,
|
||||
"current_game_role": (current_info or {}).get("game_role"),
|
||||
"current_game_channel": (current_info or {}).get("channel", ""),
|
||||
"pending_role_name": pending_role_name,
|
||||
"pending_game_role": (pending_info or {}).get("game_role"),
|
||||
"pending_game_channel": (pending_info or {}).get("channel", ""),
|
||||
"bind_ready_for_confirm": bool(pending_role_name),
|
||||
"bind_confirmed": bool(current_role_name),
|
||||
}
|
||||
)
|
||||
if role_name:
|
||||
account.game_name = role_name
|
||||
if current_info and has_role_split:
|
||||
self._apply_role_info_to_account(
|
||||
account, current_info, account.status or "all_queried"
|
||||
)
|
||||
elif selected_info.get("role_name") and not has_role_split:
|
||||
account.game_name = str(selected_info.get("role_name") or "")
|
||||
account.game_channel = (
|
||||
self._role_channel(bind_status) or account.game_channel
|
||||
)
|
||||
message_parts.append(f"角色 {role_name}")
|
||||
|
||||
if current_role_name and pending_role_name:
|
||||
message_parts.append(
|
||||
f"角色 {current_role_name},待确认 {pending_role_name}"
|
||||
)
|
||||
elif current_role_name:
|
||||
message_parts.append(f"角色 {current_role_name}")
|
||||
elif pending_role_name:
|
||||
message_parts.append(f"待确认角色 {pending_role_name}")
|
||||
else:
|
||||
message_parts.append("未绑定角色")
|
||||
|
||||
@@ -524,7 +568,11 @@ class EliteMixin:
|
||||
account.points = points if points is not None else account.points
|
||||
result["failures"] = failures
|
||||
|
||||
fetched_anything = points is not None or role_name or opened is not None
|
||||
fetched_anything = (
|
||||
points is not None
|
||||
or bool(current_role_name or pending_role_name)
|
||||
or opened is not None
|
||||
)
|
||||
if not fetched_anything:
|
||||
self._mark_task(
|
||||
worker_db,
|
||||
|
||||
Reference in New Issue
Block a user