feat(telegram_bot): Add Cloud Mail configuration and batch team processing

- Add Cloud Mail API configuration support (api_base, api_auth, domains) in config.py
- Implement run_teams_by_count() function for processing specified number of teams with smart filtering
- Add Cloud Mail management commands: /cloudmail, /cloudmail_token, /cloudmail_api, /cloudmail_domains
- Add callback handlers for run_all, run, and cloudmail interactive operations
- Refactor /run command to use interactive selection for count and email service instead of direct argument
- Update bot command descriptions and help text to reflect new functionality
- Add Cloud Mail domain management and token configuration capabilities
- Enable batch processing with progress tracking and automatic team completion detection
This commit is contained in:
2026-01-30 14:07:37 +08:00
parent 79c3eb733c
commit f39dff8ee6
3 changed files with 936 additions and 54 deletions

View File

@@ -307,6 +307,7 @@ def reload_config() -> dict:
"""
global _cfg, _raw_teams, TEAMS
global EMAIL_PROVIDER, INCLUDE_TEAM_OWNERS, AUTH_PROVIDER
global EMAIL_API_BASE, EMAIL_API_AUTH, EMAIL_DOMAINS, EMAIL_DOMAIN
global BROWSER_HEADLESS, ACCOUNTS_PER_TEAM
global GPTMAIL_API_KEYS, GPTMAIL_DOMAINS, GPTMAIL_PREFIX
global PROXY_ENABLED, PROXIES
@@ -361,6 +362,13 @@ def reload_config() -> dict:
GPTMAIL_DOMAINS = _gptmail.get("domains", [])
GPTMAIL_API_KEYS = _gptmail.get("api_keys", []) or ["gpt-test"]
# Cloud Mail (email) 配置
_email = _cfg.get("email", {})
EMAIL_API_BASE = _email.get("api_base", "")
EMAIL_API_AUTH = _email.get("api_auth", "")
EMAIL_DOMAINS = _email.get("domains", []) or ([_email["domain"]] if _email.get("domain") else [])
EMAIL_DOMAIN = EMAIL_DOMAINS[0] if EMAIL_DOMAINS else ""
# 代理配置
_proxy_enabled_top = _cfg.get("proxy_enabled")
_proxy_enabled_browser = _cfg.get("browser", {}).get("proxy_enabled")

79
run.py
View File

@@ -1298,6 +1298,85 @@ def run_single_team(team_index: int = 0):
return _current_results
def run_teams_by_count(count: int):
"""运行指定数量的 Team
Args:
count: 要处理的 Team 数量
"""
global _tracker, _current_results, _shutdown_requested
log.header("ChatGPT Team 批量注册自动化")
# 打印系统配置
_print_system_config()
# 限制数量不超过总数
actual_count = min(count, len(TEAMS))
log.info(f"选择处理前 {actual_count} 个 Team (共 {len(TEAMS)} 个)", icon="team")
log.info(f"统一密码: {DEFAULT_PASSWORD}", icon="code")
log.info("按 Ctrl+C 可安全退出并保存进度")
log.separator()
# 先显示整体状态
_tracker = load_team_tracker()
_current_results = []
# 筛选需要处理的 Team (只取前 count 个中需要处理的)
teams_to_process = []
for i, team in enumerate(TEAMS[:actual_count]):
team_name = team["name"]
team_accounts = _tracker.get("teams", {}).get(team_name, [])
member_accounts = [acc for acc in team_accounts if acc.get("role") != "owner"]
owner_accounts = [acc for acc in team_accounts if acc.get("role") == "owner" and acc.get("status") != "completed"]
completed_count = sum(1 for acc in member_accounts if acc.get("status") == "completed")
member_count = len(member_accounts)
needs_processing = (
member_count < ACCOUNTS_PER_TEAM or
completed_count < member_count or
len(owner_accounts) > 0
)
if needs_processing:
teams_to_process.append((i, team))
if not teams_to_process:
log.success("选定的 Team 已全部完成处理,无需继续")
return _current_results
skipped_count = actual_count - len(teams_to_process)
if skipped_count > 0:
log.info(f"跳过 {skipped_count} 个已完成的 Team处理剩余 {len(teams_to_process)}")
teams_total = len(teams_to_process)
with Timer("全部流程"):
for idx, (original_idx, team) in enumerate(teams_to_process):
if _shutdown_requested:
log.warning("检测到中断请求,停止处理...")
break
log.separator("", 60)
team_email = team.get('account') or team.get('owner_email', '')
log.highlight(f"Team {idx + 1}/{teams_total}: {team['name']} ({team_email})", icon="team")
log.separator("", 60)
results, _ = process_single_team(team, team_index=idx + 1, teams_total=teams_total)
_current_results.extend(results)
if idx < teams_total - 1 and not _shutdown_requested:
wait_time = 3
log.countdown(wait_time, "下一个 Team")
print_summary(_current_results)
return _current_results
def test_email_only():
"""测试模式: 只创建邮箱和邀请,不注册"""
global _tracker

File diff suppressed because it is too large Load Diff