This commit is contained in:
2026-01-20 21:26:44 +08:00
parent 906aceff6e
commit 26438386c1
2 changed files with 178 additions and 3 deletions

View File

@@ -125,6 +125,20 @@ def preload_all_account_ids() -> tuple[int, int]:
import sys
from concurrent.futures import ThreadPoolExecutor, as_completed
# 导入 Telegram 进度显示接口
try:
from bot_notifier import (
preload_progress_start,
preload_progress_update,
preload_progress_done,
preload_progress_finish
)
except ImportError:
def preload_progress_start(total): pass
def preload_progress_update(team_name): pass
def preload_progress_done(team_name, success): pass
def preload_progress_finish(stopped=False): pass
success_count = 0
fail_count = 0
@@ -143,6 +157,9 @@ def preload_all_account_ids() -> tuple[int, int]:
total = len(teams_need_fetch)
log.info(f"并行预加载 {total} 个 Team 的 account_id...", icon="sync")
# 启动 Telegram 进度显示
preload_progress_start(total)
need_save = False
failed_teams = []
stopped = False
@@ -172,6 +189,7 @@ def preload_all_account_ids() -> tuple[int, int]:
team, account_id, status = future.result()
completed += 1
team_name = team['name']
if status == "stopped":
stopped = True
@@ -180,15 +198,20 @@ def preload_all_account_ids() -> tuple[int, int]:
success_count += 1
if team.get("format") == "new":
need_save = True
log.info(f"预加载 [{completed}/{total}] {team['name']}: ✓ {account_id}")
log.info(f"预加载 [{completed}/{total}] {team_name}: ✓ {account_id}")
preload_progress_done(team_name, True)
else:
fail_count += 1
failed_teams.append(team['name'])
log.warning(f"预加载 [{completed}/{total}] {team['name']}: ✗ 失败")
failed_teams.append(team_name)
log.warning(f"预加载 [{completed}/{total}] {team_name}: ✗ 失败")
preload_progress_done(team_name, False)
# 加上已缓存的数量
success_count += cached_count
# 完成 Telegram 进度显示
preload_progress_finish(stopped=stopped)
# 持久化到 team.json
if need_save:
if save_team_json():