完善自动注册代理和状态恢复

This commit is contained in:
yml2213
2026-07-06 02:58:17 +08:00
parent db4ca78280
commit 72e7947a39
7 changed files with 223 additions and 19 deletions
+5 -1
View File
@@ -4,6 +4,7 @@ from __future__ import annotations
import threading
import time
from collections.abc import Mapping
from dataclasses import dataclass
from datetime import datetime
@@ -55,6 +56,7 @@ def register_huya_with_sms_line(
change_password: bool = True,
password_prefix: str = "hy",
fixed_password: str = "",
proxies: Mapping[str, str] | None = None,
stop_event: threading.Event | None = None,
) -> HuyaAutoRegisterResult:
"""使用固定手机号和接码地址完成虎牙短信注册/登录。"""
@@ -76,7 +78,7 @@ def register_huya_with_sms_line(
sent_at = datetime.now()
try:
code_result = send_huya_sms_code(phone=phone)
code_result = send_huya_sms_code(phone=phone, proxies=proxies)
except HuyaLoginError as exc:
return HuyaAutoRegisterResult(
phone=phone,
@@ -138,6 +140,7 @@ def register_huya_with_sms_line(
authcode=poll_result.code,
state=code_result.state,
phone=phone,
proxies=proxies,
)
except HuyaLoginError as exc:
return HuyaAutoRegisterResult(
@@ -213,6 +216,7 @@ def register_huya_with_sms_line(
wait_seconds=wait_seconds,
poll_interval=poll_interval,
ignore_codes={poll_result.code},
proxies=proxies,
stop_event=stop_event,
)
if not change_result.success:
+2 -1
View File
@@ -458,10 +458,11 @@ def change_huya_password_with_sms_line(
wait_seconds: float = 180,
poll_interval: float = 5,
ignore_codes: set[str] | None = None,
proxies: Mapping[str, str] | None = None,
stop_event: threading.Event | None = None,
) -> HuyaChangePasswordResult:
"""使用同一手机号接码链接完成改密短信验证。"""
changer = HuyaPasswordChanger(uid=uid, cookie=cookie)
changer = HuyaPasswordChanger(uid=uid, cookie=cookie, proxies=proxies)
sent_at = datetime.now()
code_result = changer.send_code()
if not code_result.success or not code_result.session_data: