update
This commit is contained in:
@@ -14,7 +14,7 @@ from config import (
|
||||
)
|
||||
|
||||
|
||||
def make_progress_bar(current: int, total: int, width: int = 10) -> str:
|
||||
def make_progress_bar(current: int, total: int, width: int = 20) -> str:
|
||||
"""生成文本进度条
|
||||
|
||||
Args:
|
||||
@@ -23,19 +23,16 @@ def make_progress_bar(current: int, total: int, width: int = 10) -> str:
|
||||
width: 进度条宽度 (字符数)
|
||||
|
||||
Returns:
|
||||
进度条字符串,如 "████████░░ 80%"
|
||||
进度条字符串,如 "▓▓▓▓░░░░░░"
|
||||
"""
|
||||
if total <= 0:
|
||||
return "░" * width + " 0%"
|
||||
return "░" * width
|
||||
|
||||
percent = min(current / total, 1.0)
|
||||
filled = int(width * percent)
|
||||
empty = width - filled
|
||||
|
||||
bar = "█" * filled + "░" * empty
|
||||
percent_text = f"{int(percent * 100)}%"
|
||||
|
||||
return f"{bar} {percent_text}"
|
||||
return "▓" * filled + "░" * empty
|
||||
|
||||
|
||||
class ProgressTracker:
|
||||
@@ -54,6 +51,7 @@ class ProgressTracker:
|
||||
self.success = 0
|
||||
self.failed = 0
|
||||
self.current_account = ""
|
||||
self.current_phase = "" # 当前阶段 (注册/授权/验证)
|
||||
self.current_step = ""
|
||||
self.current_role = "" # 当前账号角色 (member/owner)
|
||||
self.messages: Dict[int, Message] = {} # chat_id -> Message
|
||||
@@ -63,29 +61,34 @@ class ProgressTracker:
|
||||
|
||||
def _get_progress_text(self) -> str:
|
||||
"""生成进度消息文本"""
|
||||
bar = make_progress_bar(self.current, self.total, 12)
|
||||
bar = make_progress_bar(self.current, self.total, 20)
|
||||
|
||||
# 标题行:显示 Team 序号
|
||||
if self.teams_total > 0:
|
||||
title = f"<b>📦 Team [{self.team_index}/{self.teams_total}]: {self.team_name}</b>"
|
||||
title = f"<b>◈ Team [{self.team_index}/{self.teams_total}]: {self.team_name}</b>"
|
||||
else:
|
||||
title = f"<b>📦 正在处理: {self.team_name}</b>"
|
||||
title = f"<b>◈ 正在处理: {self.team_name}</b>"
|
||||
|
||||
owner_tag = " (含 Owner)" if self.include_owner else ""
|
||||
lines = [
|
||||
title,
|
||||
"",
|
||||
f"进度: {bar}",
|
||||
f"账号: {self.current}/{self.total}" + (f" (含 Owner)" if self.include_owner else ""),
|
||||
f"成功: {self.success} | 失败: {self.failed}",
|
||||
f"🔄 注册进度 {self.current}/{self.total}{owner_tag}",
|
||||
bar,
|
||||
"",
|
||||
f"✅ 成功: {self.success}",
|
||||
f"❌ 失败: {self.failed}",
|
||||
]
|
||||
|
||||
if self.current_account:
|
||||
lines.append("")
|
||||
role_tag = " 👑" if self.current_role == "owner" else ""
|
||||
lines.append(f"当前: <code>{self.current_account}</code>{role_tag}")
|
||||
lines.append(f"⏳ 正在处理: <code>{self.current_account}</code>{role_tag}")
|
||||
|
||||
if self.current_step:
|
||||
lines.append(f"步骤: {self.current_step}")
|
||||
if self.current_phase and self.current_step:
|
||||
lines.append(f" ▸ [{self.current_phase}] {self.current_step}")
|
||||
elif self.current_step:
|
||||
lines.append(f" ▸ {self.current_step}")
|
||||
|
||||
return "\n".join(lines)
|
||||
|
||||
@@ -137,12 +140,14 @@ class ProgressTracker:
|
||||
self._loop = loop
|
||||
asyncio.run_coroutine_threadsafe(self._send_initial_message(), loop)
|
||||
|
||||
def update(self, current: int = None, account: str = None, step: str = None, role: str = None):
|
||||
def update(self, current: int = None, account: str = None, phase: str = None, step: str = None, role: str = None):
|
||||
"""更新进度 (供同步代码调用)"""
|
||||
if current is not None:
|
||||
self.current = current
|
||||
if account is not None:
|
||||
self.current_account = account
|
||||
if phase is not None:
|
||||
self.current_phase = phase
|
||||
if step is not None:
|
||||
self.current_step = step
|
||||
if role is not None:
|
||||
@@ -158,6 +163,7 @@ class ProgressTracker:
|
||||
else:
|
||||
self.failed += 1
|
||||
self.current_account = ""
|
||||
self.current_phase = ""
|
||||
self.current_step = ""
|
||||
self.current_role = ""
|
||||
# 最后一个账号完成时强制更新,确保显示 100%
|
||||
@@ -440,10 +446,17 @@ def progress_start(team_name: str, total: int, team_index: int = 0,
|
||||
return None
|
||||
|
||||
|
||||
def progress_update(account: str = None, step: str = None, role: str = None):
|
||||
"""更新当前进度"""
|
||||
def progress_update(account: str = None, phase: str = None, step: str = None, role: str = None):
|
||||
"""更新当前进度
|
||||
|
||||
Args:
|
||||
account: 当前处理的账号
|
||||
phase: 当前阶段 (注册/授权/验证)
|
||||
step: 当前步骤
|
||||
role: 账号角色
|
||||
"""
|
||||
if _notifier and _notifier.get_progress():
|
||||
_notifier.get_progress().update(account=account, step=step, role=role)
|
||||
_notifier.get_progress().update(account=account, phase=phase, step=step, role=role)
|
||||
|
||||
|
||||
def progress_account_done(email: str, success: bool):
|
||||
|
||||
Reference in New Issue
Block a user