# OpenAI 自动注册工具 自动化注册 OpenAI 账号,使用临时邮箱接收验证邮件,支持一键生成欧洲账单 URL。 ## 功能特点 - ✅ **自动生成临时邮箱**:通过临时邮箱 API 自动创建邮箱 - ✅ **多域名支持**:支持选择不同的邮箱域名后缀(最多 3 个) - ✅ **自动接收验证邮件**:轮询等待 OpenAI 发送的验证码 - ✅ **自动提取验证码**:从邮件中提取并提交验证码 - ✅ **成功/失败管理**:成功注册的邮箱保留,失败的自动删除 - ✅ **批量注册**:支持一次注册多个账号 - ✅ **欧洲账单生成**:自动生成 ChatGPT Team Plan 欧洲账单 checkout URL - ✅ **完整日志**:详细的调试输出,方便排查问题 ## 🚀 快速开始 ### 方式 1: Telegram Bot (推荐) 最简单的使用方式,无需命令行操作: ```bash # 1. 安装依赖 uv pip install -e . # 2. 配置 config.py(临时邮箱设置) cp config.example.py config.py nano config.py # 3. 设置 Bot Token export TELEGRAM_BOT_TOKEN='your_bot_token_here' # 4. 启动 Bot ./deployment/start_bot.sh ``` 详细教程: [docs/TELEGRAM_BOT_GUIDE.md](docs/TELEGRAM_BOT_GUIDE.md) **功能:** - 📱 Telegram 界面操作 - ✅ 自动注册账号 - ✅ 获取 Access Token - ✅ 生成欧洲账单 URL - 🔐 用户访问控制 ### 方式 2: 命令行工具 #### 1. 配置临时邮箱 API 复制配置模板并填入真实信息: ```bash cp config.example.py config.py ``` 编辑 `config.py`,填入你的临时邮箱 API 信息: ```python TEMPMAIL_CONFIG = { 'api_base_url': 'https://your.tempmail.domain', # 你的临时邮箱域名 # 方式1:用户名密码登录(推荐) 'username': 'your_username', # 你的临时邮箱系统用户名 'password': 'your_password', # 你的密码 # 方式2:JWT Token(备用) # 'admin_token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...', # 域名选择(0=第1个域名, 1=第2个, 2=第3个) 'domain_index': 0, # 改成 0, 1, 或 2 来选择不同的域名后缀 } ``` 临时邮箱 API 文档见:[docs/tempmail.md](docs/tempmail.md) ### 2. 安装依赖 ```bash # 使用 uv (推荐,更快) uv pip install -e . # 或使用传统 pip pip install -r requirements.txt ``` ### 3. 注册账号 注册 1 个账号(自动生成邮箱和密码): ```bash python auto_register.py ``` ## 使用方法 ### 📋 命令合集(Command Reference) #### 🔹 基础注册 ```bash # 注册 1 个账号(自动生成邮箱和密码) python auto_register.py # 注册 10 个账号 python auto_register.py --count 10 # 注册 5 个账号,使用相同密码 python auto_register.py --count 5 --password "MySecurePassword123!" # 保存到指定文件 python auto_register.py --count 10 --output my_accounts.json # 完整示例:注册 20 个账号,指定密码和输出文件 python auto_register.py --count 20 --password "MyPassword123!" --output accounts.json ``` #### 🔹 注册 + 生成欧洲账单 ```bash # 注册 1 个账号并生成欧洲账单 URL python auto_register.py --eu-billing # 批量注册 10 个账号并生成账单 python auto_register.py --count 10 --eu-billing # 完整示例:批量注册 + 账单 + 自定义输出 python auto_register.py --count 5 --password "MyPass123!" --eu-billing --output team_accounts.json ``` #### 🔹 已注册账号生成账单 ```bash # 批量生成账单(从 registered_accounts.json 读取) python generate_billing.py # 从自定义文件读取并生成账单 python generate_billing.py --input my_accounts.json --output billing_urls.json # 单个账号生成账单 python generate_billing.py --email user@example.com --password "MyPassword123!" ``` --- ### 批量注册 注册 10 个账号: ```bash python auto_register.py --count 10 ``` ### 指定密码 所有账号使用相同密码: ```bash python auto_register.py --count 5 --password "MySecurePassword123!" ``` ### 自定义输出文件 保存到指定文件: ```bash python auto_register.py --count 10 --output accounts.json ``` ### 注册 + 欧洲账单生成 注册账号的同时生成欧洲账单 checkout URL: ```bash # 注册 1 个账号并生成账单 python auto_register.py --eu-billing # 批量注册 10 个账号并生成账单 python auto_register.py --count 10 --eu-billing ``` ### 已有账号批量生成账单 对已注册的账号批量生成欧洲账单 URL: ```bash # 从 registered_accounts.json 读取账号 python generate_billing.py # 从自定义文件读取 python generate_billing.py --input my_accounts.json --output billing_urls.json # 单个账号生成账单 python generate_billing.py --email user@example.com --password "MyPassword123!" ``` ### 完整示例 ```bash # 批量注册 20 个账号,指定密码,生成账单,保存到自定义文件 python auto_register.py \ --count 20 \ --password "MyPassword123!" \ --eu-billing \ --output team_accounts.json ``` ## 配置说明 ### 欧洲账单配置 在 `config.py` 中可以自定义欧洲账单参数: ```python EU_BILLING_CONFIG = { 'plan_name': 'chatgptteamplan', 'team_plan_data': { 'workspace_name': 'Sepa', # 工作空间名称 'price_interval': 'month', # 'month' 或 'year' 'seat_quantity': 5, # 座位数量(最少 5 个) }, 'billing_details': { 'country': 'DE', # 国家代码(DE, FR, IT 等) 'currency': 'EUR', # 货币 }, 'promo_campaign': { 'promo_campaign_id': 'team-1-month-free', # 促销码 'is_coupon_from_query_param': False, }, 'checkout_ui_mode': 'redirect', } ``` ### 域名选择 临时邮箱支持多个域名后缀,通过 `domain_index` 参数选择: ```python TEMPMAIL_CONFIG = { # ... 'domain_index': 0, # 0 = 第1个域名, 1 = 第2个, 2 = 第3个 } ``` 这样可以避免某个域名被 OpenAI 屏蔽时,切换到其他域名继续注册。 ### 调试模式 调试输出在 `config.py` 中控制: ```python DEBUG = True # 打印详细日志 DEBUG = False # 静默模式 ``` ## 输出格式 ### 注册账号输出(registered_accounts.json) 普通注册(无账单): ```json [ { "email": "random123@domain.com", "password": "MyPassword123!", "verified": true } ] ``` 注册 + 账单生成(使用 `--eu-billing`): ```json [ { "email": "random123@domain.com", "password": "MyPassword123!", "verified": true, "checkout_url": "https://chatgpt.com/checkout/openai_llc/cs_xxx..." } ] ``` ### 账单生成输出(billing_urls.json) 使用 `generate_billing.py` 的输出格式: ```json [ { "email": "user@example.com", "checkout_url": "https://chatgpt.com/checkout/openai_llc/cs_xxx...", "generated_at": "2026-01-11T08:30:00Z" }, { "email": "fail@example.com", "error": "Failed to retrieve access token: HTTP 401" } ] ``` ## 工作流程 ### 完整注册流程(含账单生成) ``` 1. 生成临时邮箱 [TempMailClient.generate_mailbox()] ↓ 2. 初始化 OpenAI 注册流程 [OpenAIRegistrar._step1_init_through_chatgpt()] ↓ 3. 初始化 Sentinel [_step2_init_sentinel() + _step2_5_submit_sentinel()] ↓ 4. 解 PoW [_step2_6_solve_pow() + _step2_7_submit_pow()] ↓ 5. 提交注册请求 [_step3_attempt_register()] ↓ 6. 等待验证邮件 [TempMailClient.wait_for_email()] ↓ 7. 提取验证码 [TempMailClient.extract_verification_code()] ↓ 8. 提交验证码 [_step4_verify_email()] ↓ 9. 获取 Access Token [_step5_get_access_token()] ← 新增 ↓ 10. 生成欧洲账单 [EUBillingGenerator.generate_checkout_url()] ← 新增 ↓ 11. 注册完成 ├─ ✓ 成功 → 保留邮箱 + 账单 URL └─ ✗ 失败 → 删除邮箱 [TempMailClient.delete_mailbox()] ``` ## 文件结构 ``` . ├── auto_register.py # 主脚本(批量注册 + 可选账单生成) ├── generate_billing.py # 独立账单生成工具 ├── tg_bot.py # Telegram Bot 主程序 ✨ ├── config.example.py # 配置模板 ├── config.py # 配置文件(需自行创建) ├── requirements.txt # Python 依赖 ├── pyproject.toml # uv 项目配置 ├── deployment/ # 部署相关文件 │ ├── Dockerfile # Docker 镜像 │ ├── docker-compose.yml # Docker Compose 配置 │ ├── start_bot.sh # Bot 快速启动脚本 │ ├── telegram-bot.service # Systemd 服务配置 │ └── .env.example # 环境变量模板 ├── docs/ # 文档 │ ├── CHANGELOG.md # 更新日志 │ ├── TELEGRAM_BOT_GUIDE.md # Bot 部署指南 📖 │ └── tempmail.md # 临时邮箱 API 文档 ├── modules/ │ ├── register.py # 注册逻辑 + Access Token │ ├── billing.py # 欧洲账单生成 │ ├── tempmail.py # 临时邮箱客户端 │ ├── http_client.py # HTTP 客户端 │ ├── fingerprint.py # 浏览器指纹 │ ├── sentinel_solver.py # Sentinel 求解 │ └── pow_solver.py # PoW 求解 └── reference/ # 参考实现 └── autoteam.py # 账单生成参考 ``` ## 注意事项 ### 临时邮箱系统 - 只保留**成功注册**的邮箱 - 失败的邮箱会**自动删除**,不占用空间 - 你可以在临时邮箱系统中查看所有成功注册的账号 ### 速率限制 - OpenAI 可能有注册频率限制 - 建议在批量注册时添加延迟(如每个账号间隔 30 秒) - 如遇到 429 错误,请降低注册速度 ### 配置文件安全 - `config.py` 包含敏感信息,已加入 `.gitignore` - 不要将 `config.py` 提交到 git 仓库 - 使用 `config.example.py` 作为模板 ## 常见问题 ### 1. 收不到验证邮件 - 检查临时邮箱 API 是否正常工作 - 检查邮箱域名是否被 OpenAI 屏蔽(尝试切换 `domain_index`) - 增加等待时间(修改 `wait_for_email()` 的 `timeout` 参数) ### 2. PoW 求解失败 - 确保安装了 Node.js - 检查 `sdk.js` 路径是否正确 - 增加 PoW 超时时间(`config.py` 中的 `POW_CONFIG`) ### 3. 注册被拒绝(409 Conflict) - 邮箱可能已被使用(理论上临时邮箱应该是新的) - OpenAI 可能检测到异常行为,尝试更换 IP ### 4. Cloudflare 403 - 可能触发了反爬虫检测 - 尝试更换 User-Agent(`config.py` 中的 `FINGERPRINT_CONFIG`) - 添加延迟,降低请求频率 ### 5. 某个域名被屏蔽 - 修改 `config.py` 中的 `domain_index`,切换到其他域名 - 例如:第1个域名不行就改成 `domain_index: 1` 或 `domain_index: 2` ## 许可证 MIT License