feat(config, email_service, telegram_bot): Add dynamic GPTMail API key management and config reload capability

- Add reload_config() function to dynamically reload config.toml and team.json without restart
- Implement GPTMail API key management with support for multiple keys (api_keys list)
- Add functions to manage GPTMail keys: get_gptmail_keys(), add_gptmail_key(), remove_gptmail_key()
- Add key rotation strategies: get_next_gptmail_key() (round-robin) and get_random_gptmail_key()
- Add gptmail_keys.json file support for dynamic key management
- Fix config parsing to handle include_team_owners and proxy settings in multiple locations
- Update email_service.py to use key rotation for GPTMail API calls
- Update telegram_bot.py to support dynamic key management
- Add install_service.sh script for service installation
- Update config.toml.example with new api_keys configuration option
- Improve configuration flexibility by supporting both old (api_key) and new (api_keys) formats
This commit is contained in:
2026-01-17 05:52:05 +08:00
parent 64707768f8
commit b902922d22
5 changed files with 1067 additions and 84 deletions

View File

@@ -8,6 +8,42 @@
# - "gptmail": GPTMail 临时邮箱系统,无需创建用户,直接生成即可收信
email_provider = "gptmail"
# ==================== 授权服务选择 ====================
# 选择使用的授权服务: "crs" / "cpa" / "s2a"
# - crs: 原有 CRS 系统,需手动添加账号到 CRS
# - cpa: CPA (Codex/Copilot Authorization) 系统,后台自动处理账号
# - s2a: Sub2API 系统,支持 OAuth 授权和账号入库
auth_provider = "cpa"
# 是否将 team.json 中的 Team Owner 也添加到授权服务
# 开启后,运行时会自动将 team.json 中的 Owner 账号也进行授权入库
# 注意: 请确保 Team Owner 邮箱可以接收验证码
include_team_owners = false
# ==================== 代理配置 ====================
# 是否启用代理 (默认关闭)
proxy_enabled = false
# 支持配置多个代理,程序会轮换使用
# type: 代理类型 (socks5/http/https)
# host: 代理服务器地址
# port: 代理端口
# username/password: 代理认证信息 (可选)
# [[proxies]]
# type = "socks5"
# host = "127.0.0.1"
# port = 1080
# username = ""
# password = ""
# [[proxies]]
# type = "http"
# host = "proxy.example.com"
# port = 8080
# username = "user"
# password = "pass"
# ---------- Cloud Mail 邮箱系统配置 ----------
# 仅当 email_provider = "cloudmail" 时生效
# 项目地址: https://github.com/maillab/cloud-mail
@@ -30,8 +66,16 @@ web_url = "https://your-email-service.com"
[gptmail]
# API 接口地址
api_base = "https://mail.chatgpt.org.uk"
# API 密钥 (gpt-test 为测试密钥,每日有调用限制)
# API 密钥配置 (支持两种方式)
# 方式1: 单个 Key (兼容旧配置)
api_key = "gpt-test"
# 方式2: 多个 Key 轮询 (推荐,可分散请求限制)
# api_keys = ["key1", "key2", "key3"]
# 注意: 也可以通过 Telegram Bot 的 /gptmail_add 命令动态添加 Key
# 邮箱前缀 (留空则自动生成 {8位随机字符}-oaiteam 格式)
prefix = ""
# 可用域名列表,生成邮箱时随机选择
@@ -74,18 +118,6 @@ domains = [
"zawauk.org", "zumuntahassociationuk.org"
]
# ==================== 授权服务选择 ====================
# 选择使用的授权服务: "crs" / "cpa" / "s2a"
# - crs: 原有 CRS 系统,需手动添加账号到 CRS
# - cpa: CPA (Codex/Copilot Authorization) 系统,后台自动处理账号
# - s2a: Sub2API 系统,支持 OAuth 授权和账号入库
auth_provider = "cpa"
# 是否将 team.json 中的 Team Owner 也添加到授权服务
# 开启后,运行时会自动将 team.json 中的 Owner 账号也进行授权入库
# 注意: 请确保 Team Owner 邮箱可以接收验证码
include_team_owners = false
# ==================== CRS 服务配置 ====================
# CRS (Central Registration Service) 用于管理注册账号的中心服务
[crs]
@@ -171,30 +203,6 @@ short_wait = 10
# 无头模式 (服务器运行时设为 true)
headless = false
# ==================== 代理配置 ====================
# 是否启用代理 (默认关闭)
proxy_enabled = false
# 支持配置多个代理,程序会轮换使用
# type: 代理类型 (socks5/http/https)
# host: 代理服务器地址
# port: 代理端口
# username/password: 代理认证信息 (可选)
# [[proxies]]
# type = "socks5"
# host = "127.0.0.1"
# port = 1080
# username = ""
# password = ""
# [[proxies]]
# type = "http"
# host = "proxy.example.com"
# port = 8080
# username = "user"
# password = "pass"
# ==================== 文件配置 ====================
[files]
# 导出账号信息的 CSV 文件路径