diff --git a/run.py b/run.py index 0973472..4c4a5d2 100644 --- a/run.py +++ b/run.py @@ -344,14 +344,20 @@ def process_accounts(accounts: list, team_name: str, team_index: int = 0, # 已授权但未入库的状态 (直接尝试入库,不重新授权) # - authorized: 授权成功但入库失败 # - partial: 部分完成 - need_crs_only = account_status in ["authorized", "partial"] + # 注意: S2A 模式下 partial 状态需要重新授权,因为入库是授权过程的一部分 + if AUTH_PROVIDER == "s2a": + need_crs_only = account_status == "authorized" # S2A: partial 需要重新授权 + else: + need_crs_only = account_status in ["authorized", "partial"] # 已注册但未授权的状态 (使用密码登录授权) # - registered: 已注册,需要授权 # - auth_failed: 授权失败,重试 + # - partial (S2A模式): 入库验证失败,需要重新授权 # - 新格式 Owner (role=owner 且状态不是 team_owner/completed) 也走密码登录 need_auth_only = ( account_status in ["registered", "auth_failed"] + or (AUTH_PROVIDER == "s2a" and account_status == "partial") # S2A: partial 需要重新授权 or (account_role == "owner" and account_status not in ["team_owner", "completed", "authorized", "partial"]) ) diff --git a/telegram_bot.py b/telegram_bot.py index 4d65f96..7cccbb3 100644 --- a/telegram_bot.py +++ b/telegram_bot.py @@ -709,6 +709,13 @@ class ProvisionerBot: team_name = TEAMS[team_idx].get("name", f"Team{team_idx}") self.current_team = team_name + # 重置停止标志,确保新任务可以正常运行 + try: + import run + run._shutdown_requested = False + except Exception: + pass + await update.message.reply_text(f"🚀 开始处理 Team {team_idx}: {team_name}...") # 在后台线程执行任务 @@ -732,6 +739,14 @@ class ProvisionerBot: return self.current_team = "全部" + + # 重置停止标志,确保新任务可以正常运行 + try: + import run + run._shutdown_requested = False + except Exception: + pass + await update.message.reply_text(f"🚀 开始处理所有 Team (共 {len(TEAMS)} 个)...") loop = asyncio.get_event_loop() @@ -781,6 +796,13 @@ class ProvisionerBot: # 启动任务 (run_all_teams 会自动处理未完成的账号) self.current_team = "继续处理" + # 重置停止标志,确保新任务可以正常运行 + try: + import run + run._shutdown_requested = False + except Exception: + pass + loop = asyncio.get_event_loop() self.current_task = loop.run_in_executor( self.executor, @@ -805,12 +827,9 @@ class ProvisionerBot: self.current_team = None # 清理进度跟踪 progress_finish() - # 重置停止标志,以便下次任务可以正常运行 - try: - import run - run._shutdown_requested = False - except Exception: - pass + # 注意: 不在这里重置 _shutdown_requested + # 让标志保持 True,直到下次任务启动时再重置 + # 这样可以确保线程池中的任务能够正确检测到停止信号 def _run_team_task(self, team_idx: int): """执行单个 Team 任务 (在线程池中运行)"""