feat(priority): group priority changed notifications by target group and fetch remote account details
This commit is contained in:
@@ -79,11 +79,41 @@ def format_dingtalk_priority_changed(
|
||||
f"- **摘要**:{success} 更新 / {failed} 失败 / {skipped} 跳过",
|
||||
"",
|
||||
]
|
||||
|
||||
# 按目标分组聚合
|
||||
from collections import defaultdict
|
||||
groups = defaultdict(list)
|
||||
for u in updates:
|
||||
emoji = {"success": "✅", "failed": "❌", "skipped": "⏭️"}.get(u.get("status", ""), "➖")
|
||||
gid = u.get("group_id", "?")
|
||||
priority = u.get("new_priority", "—")
|
||||
lines.append(f"{emoji} `{gid}` → priority={priority}")
|
||||
tg_name = u.get("target_group_name") or u.get("target_group_id") or u.get("group_id") or "未知目标分组"
|
||||
groups[tg_name].append(u)
|
||||
|
||||
for tg_name, items in groups.items():
|
||||
lines.append(f"目标分组:{tg_name}")
|
||||
for u in items:
|
||||
emoji = {"success": "✅", "failed": "❌", "skipped": "⏭️"}.get(u.get("status", ""), "➖")
|
||||
acc_name = u.get("account_name") or u.get("account_id") or "未知账号"
|
||||
acc_id = u.get("account_id") or "未知ID"
|
||||
|
||||
old_p = u.get("old_priority")
|
||||
old_p_str = "未知" if old_p in (None, "", "未知") else str(old_p)
|
||||
|
||||
new_p = u.get("new_priority")
|
||||
new_p_str = "未知" if new_p in (None, "", "未知") else str(new_p)
|
||||
|
||||
src_group = u.get("source_group_name") or u.get("source_group_id") or "未知来源"
|
||||
|
||||
rate = u.get("source_rate")
|
||||
rate_str = str(rate) if rate is not None else "—"
|
||||
|
||||
line = f"- {emoji} {acc_name}(账号ID {acc_id}):old={old_p_str} → new={new_p_str},来源分组={src_group},倍率={rate_str}"
|
||||
if u.get("status") == "failed" and u.get("message"):
|
||||
line += f",原因={u.get('message')}"
|
||||
lines.append(line)
|
||||
lines.append("")
|
||||
|
||||
while lines and not lines[-1]:
|
||||
lines.pop()
|
||||
|
||||
return {
|
||||
"msgtype": "markdown",
|
||||
"markdown": {
|
||||
|
||||
Reference in New Issue
Block a user