style: 去掉引用语法, 明细改普通行(企微连续引用行渲染粘连)
This commit is contained in:
@@ -104,14 +104,14 @@ def wecom_alert_failure(event: dict | str | None = None) -> dict:
|
||||
|
||||
lines = [f"## 流程失败:{flow_name or resource_name or '未知'}"]
|
||||
if run_name:
|
||||
lines.append(f"> Run {run_name} · {event_name.split('.')[-1]} · {_fmt_ts(occurred)}")
|
||||
lines.append(f"Run {run_name} · {event_name.split('.')[-1]} · {_fmt_ts(occurred)}")
|
||||
if state_msg:
|
||||
lines.append(f'> 错误:<font color="warning">{state_msg[:150].replace(chr(10), " ")}</font>')
|
||||
lines.append(f'错误:<font color="warning">{state_msg[:150].replace(chr(10), " ")}</font>')
|
||||
if run_id:
|
||||
lines.append(f"> [查看详情]({UI_BASE}/runs/flow-run/{run_id})")
|
||||
lines.append(f"[查看详情]({UI_BASE}/runs/flow-run/{run_id})")
|
||||
else:
|
||||
raw = json.dumps(ev, ensure_ascii=False)[:300] if ev else "(事件内容解析失败)"
|
||||
lines.append(f"> 原始事件:{raw}")
|
||||
lines.append(f"原始事件:{raw}")
|
||||
|
||||
result["sent"] = send_markdown("\n".join(lines))
|
||||
result.update({"flowName": flow_name or None, "runId": run_id})
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
2. OCR:今天处理了多少订单、识别失败多少(按 ocrProcessedAt 盖章统计)。
|
||||
3. 失败任务:近 24h 哪些 workflow、哪些 run、失败几次、何时失败(事件报警的兜底汇总)。
|
||||
|
||||
消息排版遵循 WeCom aibot markdown 子集(无表格、无 font 标签,引用块 + emoji)。
|
||||
排版:标题 + 单行结论 + 普通明细行,状态用 <font color> 三色文字表达,不用 emoji/引用/表格。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -50,7 +50,7 @@ def _system_lines(name: str, report: dict, goods: dict, lines: list[str]) -> boo
|
||||
diff_days = [d for d in days_r if not d.get("ok")]
|
||||
diff_units = sum(_affected_units(d.get("diff")) for d in diff_days)
|
||||
if diff_units:
|
||||
lines.append(f"> 状态不符约 {diff_units:,} 单({len(diff_days)} 天),已自动刷新修复")
|
||||
lines.append(f"状态不符约 {diff_units:,} 单({len(diff_days)} 天),已自动刷新修复")
|
||||
return (not ok) or bool(zero)
|
||||
|
||||
|
||||
@@ -81,9 +81,9 @@ def build_daily_message(
|
||||
lines.append(f'**任务** 失败 <font color="warning">{len(failures)} 次</font>(24h)')
|
||||
for f in failures[:6]:
|
||||
start = (f.get("start") or "")[5:] # MM-DD HH:MM
|
||||
lines.append(f"> {f.get('flow', '?')}:{f.get('name', '?')} {f.get('state', '?')} {start}")
|
||||
lines.append(f"{f.get('flow', '?')}:{f.get('name', '?')} {f.get('state', '?')} {start}")
|
||||
if len(failures) > 6:
|
||||
lines.append(f"> …等共 {len(failures)} 次")
|
||||
lines.append(f"…等共 {len(failures)} 次")
|
||||
else:
|
||||
lines.append("**任务** 失败 0 次(24h)")
|
||||
|
||||
|
||||
@@ -380,7 +380,7 @@ def device_check(alarm_threshold: int = 80) -> dict:
|
||||
for m in mounts:
|
||||
g = growth.get(label_map.get(m["label"], ""))
|
||||
growth_txt = f" · 增长最快 {g['dir']} {_fmt_growth(g['growth'])}" if g and g.get("dir") else ""
|
||||
lines.append(f"> {m['label']} {_mark(m['pct'], threshold)} · 已用 {_gb(m['used'])} · 剩 {_gb(m['free'])}{growth_txt}")
|
||||
lines.append(f"{m['label']} {_mark(m['pct'], threshold)} · 已用 {_gb(m['used'])} · 剩 {_gb(m['free'])}{growth_txt}")
|
||||
|
||||
# ---- GPU ----
|
||||
gpu_stats = agg.get("gpus") or []
|
||||
@@ -427,15 +427,15 @@ def device_check(alarm_threshold: int = 80) -> dict:
|
||||
docker_txt += " · PG " + ("正常" if svc.get("pg") else '<font color="warning">异常</font>')
|
||||
lines.append(f"**Docker** {docker_txt}")
|
||||
for it in issues[:8]:
|
||||
lines.append(f"> {it['name']}:{it['issue']}")
|
||||
lines.append(f"{it['name']}:{it['issue']}")
|
||||
|
||||
failures = checks.get("prefectFailures") or []
|
||||
if failures:
|
||||
lines.append(f'**任务** 失败 <font color="warning">{len(failures)} 次</font>(24h)')
|
||||
for f in failures[:5]:
|
||||
lines.append(f"> {f['flow']}:{f['name']} {f['state']} {(f.get('start') or '')[5:]}")
|
||||
lines.append(f"{f['flow']}:{f['name']} {f['state']} {(f.get('start') or '')[5:]}")
|
||||
if len(failures) > 5:
|
||||
lines.append(f"> …共 {len(failures)} 次")
|
||||
lines.append(f"…共 {len(failures)} 次")
|
||||
else:
|
||||
lines.append("**任务** 失败 0 次(24h)")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user