diff --git a/deploy/profile-scripts/alert_helper.py b/deploy/profile-scripts/alert_helper.py index cdf850a3..3cc03507 100644 --- a/deploy/profile-scripts/alert_helper.py +++ b/deploy/profile-scripts/alert_helper.py @@ -113,6 +113,21 @@ def notify(category, body, level=INFO): body = "\n".join(lines[:ACTION_MAX_LINES]) + f"\n…(共{len(lines)}行)" prefix = f"🚨【MoFin·{category}】" + # 写入 broadcast_messages(统一消息源,告警类) + try: + from messenger import _classify, DB + import sqlite3 as _sq3 + from datetime import datetime as _dt + _cat = "system_error" if level == ACTION else _classify(category, body) + _conn = _sq3.connect(DB, timeout=30) + _conn.execute( + "INSERT INTO broadcast_messages (ts, category, title, content, source) VALUES (?,?,?,?,?)", + (_dt.now().isoformat(), _cat, f"MoFin·{category}", body, category)) + _conn.commit() + _conn.close() + except Exception: + pass + try: _send(f"{prefix}\n{body}") except Exception as e: