From fb5a1adcec3f2158dff4720e103717c6a2c2156c Mon Sep 17 00:00:00 2001 From: xxm Date: Sat, 22 Aug 2026 10:18:25 +0800 Subject: [PATCH] =?UTF-8?q?feat(alert=5Fhelper):=20notify=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E5=86=99broadcast=5Fmessages(deploy=5Fguard=E7=AD=89?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E8=BF=9B=E7=BB=9F=E4=B8=80=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=BA=90)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/alert_helper.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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: