This commit is contained in:
2026-01-25 06:10:05 +08:00
parent ccff201fde
commit c2aa9785cb
2 changed files with 47 additions and 16 deletions

View File

@@ -441,10 +441,40 @@ def api_register_flow(
return None
log_cb("[OK] OTP 验证成功")
# 创建账户(带重试)
log_status("API注册", "创建账户...")
if not reg.create_account(real_name, birthdate):
log_cb("[X] 创建账户失败")
create_success = reg.create_account(real_name, birthdate)
# 如果创建失败,重新获取验证码再试一次
if not create_success:
log_cb("[!] 创建账户失败,尝试重新验证...")
# 重新发送验证邮件
log_status("API注册", "重新发送验证邮件...")
if not reg.send_verification_email():
log_cb("[X] 重新发送验证邮件失败")
return None
log_cb("[OK] 验证邮件已重新发送")
# 重新获取验证码
time.sleep(2) # 等待新邮件
otp_code = get_verification_code_api(email, mail_api_base, mail_api_token)
if not otp_code:
log_cb("[X] 未能获取新验证码")
return None
log_status("API注册", f"重新验证 OTP: {otp_code}")
if not reg.validate_otp(otp_code):
log_cb("[X] OTP 重新验证失败")
return None
log_cb("[OK] OTP 重新验证成功")
# 再次尝试创建账户
log_status("API注册", "重新创建账户...")
if not reg.create_account(real_name, birthdate):
log_cb("[X] 创建账户仍然失败")
return None
log_cb("[OK] 账户创建成功")
# 验证 session 是否有效

View File

@@ -955,8 +955,8 @@ def run_payment_flow(page, email, step_callback=None):
time.sleep(1)
except Exception as e:
error_msg = str(e)
if _is_connection_lost(error_msg) or _is_shutdown_requested():
log_progress("[!] 检测到停止请求,中断支付流程")
if _is_connection_lost(error_msg):
log_progress("[!] 浏览器连接断开")
return {"stopped": True}
log_progress(f"[X] 邮箱填写失败: {e}")
log_progress(f"当前URL: {page.url}")
@@ -1141,9 +1141,9 @@ def run_payment_flow(page, email, step_callback=None):
except Exception as e:
error_msg = str(e)
# 检查是否是连接断开(由 /stop 命令导致)
if _is_connection_lost(error_msg) or _is_shutdown_requested():
log_status("停止", "[!] 检测到停止请求,支付流程已中断")
# 只有连接断开才认为是停止请求,普通异常按错误处理
if _is_connection_lost(error_msg):
log_status("停止", "[!] 浏览器连接断开,支付流程已中断")
return {"stopped": True}
log_status("错误", f"[X] 支付流程异常: {e}")
return None
@@ -2109,10 +2109,10 @@ def run_single_registration(progress_callback=None, step_callback=None) -> dict:
except Exception as e:
error_msg = str(e)
# 检查是否是连接断开(由 /stop 命令导致)
if _is_connection_lost(error_msg) or _is_shutdown_requested():
log_status("停止", "[!] 注册被用户停止")
return {"success": False, "error": "用户停止", "stopped": True, "account": email, "password": password}
# 只有连接断开才认为是停止请求
if _is_connection_lost(error_msg):
log_status("停止", "[!] 浏览器连接断开")
return {"success": False, "error": "浏览器连接断开", "stopped": True, "account": email, "password": password}
log_status("错误", f"注册异常: {e}")
return {"success": False, "error": str(e), "account": email, "password": password}
finally:
@@ -2281,9 +2281,10 @@ def run_single_registration_api(progress_callback=None, step_callback=None, prox
except Exception as e:
error_msg = str(e)
if _is_connection_lost(error_msg) or _is_shutdown_requested():
log_status("停止", "[!] 注册被用户停止")
return {"success": False, "error": "用户停止", "stopped": True, "account": email, "password": password}
# 只有连接断开才认为是停止请求
if _is_connection_lost(error_msg):
log_status("停止", "[!] 浏览器连接断开")
return {"success": False, "error": "浏览器连接断开", "stopped": True, "account": email, "password": password}
log_status("错误", f"注册异常: {e}")
return {"success": False, "error": str(e), "account": email, "password": password}
finally: