This commit is contained in:
2026-01-26 07:17:55 +08:00
parent adb60cdfd6
commit 8cb7a50bb9

View File

@@ -216,7 +216,18 @@ class ChatGPTAPIRegister:
log_progress(f"[X] 创建账户失败: {resp.status_code} - {resp.text[:200]}") log_progress(f"[X] 创建账户失败: {resp.status_code} - {resp.text[:200]}")
return False return False
# 检查响应是否为空
resp_text = resp.text.strip()
if not resp_text:
log_progress("[X] 创建账户失败: 服务器返回空响应")
return False
try:
data = resp.json() data = resp.json()
except Exception as json_err:
log_progress(f"[X] 创建账户失败: JSON 解析错误 - {json_err}")
return False
continue_url = data.get("continue_url") continue_url = data.get("continue_url")
if continue_url: if continue_url:
request_with_retry(self.session.get, continue_url, allow_redirects=True) request_with_retry(self.session.get, continue_url, allow_redirects=True)
@@ -374,6 +385,10 @@ def get_verification_code_api(target_email: str, mail_api_base: str, mail_api_to
code_match = re.search(r'\b(\d{6})\b', html_body) code_match = re.search(r'\b(\d{6})\b', html_body)
if code_match: if code_match:
code = code_match.group(1) code = code_match.group(1)
# 如果是已知的无效验证码,跳过继续等待新的
if code == "783500":
log_status("跳过", f"[!] 检测到旧验证码 {code},继续等待新验证码...")
continue
log_status("捕获", f"[OK] 提取到验证码: {code}") log_status("捕获", f"[OK] 提取到验证码: {code}")
return code return code
except Exception: except Exception:
@@ -684,9 +699,38 @@ def api_register_account_only(
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] 创建账户失败")
# 如果创建失败,重新获取验证码再试一次
if not create_success:
log_cb("[!] 创建账户失败,尝试重新验证...")
# 重新发送验证邮件
log_status("API注册", "重新发送验证邮件...")
if not reg.send_verification_email():
log_cb("[X] 重新发送验证邮件失败")
return False return False
log_cb("[OK] 验证邮件已重新发送")
# 重新获取验证码
time.sleep(2) # 等待新邮件
otp_code = get_verification_code_func(email)
if not otp_code:
log_cb("[X] 未能获取新验证码")
return False
log_status("API注册", f"重新验证 OTP: {otp_code}")
if not reg.validate_otp(otp_code):
log_cb("[X] OTP 重新验证失败")
return False
log_cb("[OK] OTP 重新验证成功")
# 再次尝试创建账户
log_status("API注册", "重新创建账户...")
if not reg.create_account(real_name, birthdate):
log_cb("[X] 创建账户仍然失败")
return False
log_cb("[OK] 账户创建成功") log_cb("[OK] 账户创建成功")
# 验证 session 是否有效 # 验证 session 是否有效