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:
79
run.py
79
run.py
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user