2
This commit is contained in:
@@ -441,10 +441,40 @@ def api_register_flow(
|
|||||||
return None
|
return None
|
||||||
log_cb("[OK] OTP 验证成功")
|
log_cb("[OK] OTP 验证成功")
|
||||||
|
|
||||||
|
# 创建账户(带重试)
|
||||||
log_status("API注册", "创建账户...")
|
log_status("API注册", "创建账户...")
|
||||||
if not reg.create_account(real_name, birthdate):
|
create_success = reg.create_account(real_name, birthdate)
|
||||||
log_cb("[X] 创建账户失败")
|
|
||||||
return None
|
# 如果创建失败,重新获取验证码再试一次
|
||||||
|
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] 账户创建成功")
|
log_cb("[OK] 账户创建成功")
|
||||||
|
|
||||||
# 验证 session 是否有效
|
# 验证 session 是否有效
|
||||||
|
|||||||
@@ -955,8 +955,8 @@ def run_payment_flow(page, email, step_callback=None):
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_msg = str(e)
|
error_msg = str(e)
|
||||||
if _is_connection_lost(error_msg) or _is_shutdown_requested():
|
if _is_connection_lost(error_msg):
|
||||||
log_progress("[!] 检测到停止请求,中断支付流程")
|
log_progress("[!] 浏览器连接断开")
|
||||||
return {"stopped": True}
|
return {"stopped": True}
|
||||||
log_progress(f"[X] 邮箱填写失败: {e}")
|
log_progress(f"[X] 邮箱填写失败: {e}")
|
||||||
log_progress(f"当前URL: {page.url}")
|
log_progress(f"当前URL: {page.url}")
|
||||||
@@ -1141,9 +1141,9 @@ def run_payment_flow(page, email, step_callback=None):
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_msg = str(e)
|
error_msg = str(e)
|
||||||
# 检查是否是连接断开(由 /stop 命令导致)
|
# 只有连接断开才认为是停止请求,普通异常按错误处理
|
||||||
if _is_connection_lost(error_msg) or _is_shutdown_requested():
|
if _is_connection_lost(error_msg):
|
||||||
log_status("停止", "[!] 检测到停止请求,支付流程已中断")
|
log_status("停止", "[!] 浏览器连接断开,支付流程已中断")
|
||||||
return {"stopped": True}
|
return {"stopped": True}
|
||||||
log_status("错误", f"[X] 支付流程异常: {e}")
|
log_status("错误", f"[X] 支付流程异常: {e}")
|
||||||
return None
|
return None
|
||||||
@@ -2109,10 +2109,10 @@ def run_single_registration(progress_callback=None, step_callback=None) -> dict:
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_msg = str(e)
|
error_msg = str(e)
|
||||||
# 检查是否是连接断开(由 /stop 命令导致)
|
# 只有连接断开才认为是停止请求
|
||||||
if _is_connection_lost(error_msg) or _is_shutdown_requested():
|
if _is_connection_lost(error_msg):
|
||||||
log_status("停止", "[!] 注册被用户停止")
|
log_status("停止", "[!] 浏览器连接断开")
|
||||||
return {"success": False, "error": "用户停止", "stopped": True, "account": email, "password": password}
|
return {"success": False, "error": "浏览器连接断开", "stopped": True, "account": email, "password": password}
|
||||||
log_status("错误", f"注册异常: {e}")
|
log_status("错误", f"注册异常: {e}")
|
||||||
return {"success": False, "error": str(e), "account": email, "password": password}
|
return {"success": False, "error": str(e), "account": email, "password": password}
|
||||||
finally:
|
finally:
|
||||||
@@ -2278,12 +2278,13 @@ def run_single_registration_api(progress_callback=None, step_callback=None, prox
|
|||||||
|
|
||||||
log_status("失败", "注册成功但支付/获取token失败")
|
log_status("失败", "注册成功但支付/获取token失败")
|
||||||
return {"success": False, "error": "支付流程失败", "account": email, "password": password}
|
return {"success": False, "error": "支付流程失败", "account": email, "password": password}
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_msg = str(e)
|
error_msg = str(e)
|
||||||
if _is_connection_lost(error_msg) or _is_shutdown_requested():
|
# 只有连接断开才认为是停止请求
|
||||||
log_status("停止", "[!] 注册被用户停止")
|
if _is_connection_lost(error_msg):
|
||||||
return {"success": False, "error": "用户停止", "stopped": True, "account": email, "password": password}
|
log_status("停止", "[!] 浏览器连接断开")
|
||||||
|
return {"success": False, "error": "浏览器连接断开", "stopped": True, "account": email, "password": password}
|
||||||
log_status("错误", f"注册异常: {e}")
|
log_status("错误", f"注册异常: {e}")
|
||||||
return {"success": False, "error": str(e), "account": email, "password": password}
|
return {"success": False, "error": str(e), "account": email, "password": password}
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
Reference in New Issue
Block a user