From 5e0141eb2818f76e908b0a13f489c38444d02a3d Mon Sep 17 00:00:00 2001 From: xxm Date: Fri, 21 Aug 2026 22:27:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(messenger):=20=E4=BF=AE=E5=A4=8Dhook?= =?UTF-8?q?=E9=80=92=E5=BD=92=E2=80=94=E2=80=94=E5=86=99broadcast=E8=A1=A8?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E6=93=8D=E4=BD=9CDB=E4=B8=8D=E7=BB=8Fsend(?= =?UTF-8?q?=E9=98=B2=E6=97=A0=E9=99=90=E5=BE=AA=E7=8E=AF)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/messenger.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/deploy/profile-scripts/messenger.py b/deploy/profile-scripts/messenger.py index 26898803..e3a2c0a5 100644 --- a/deploy/profile-scripts/messenger.py +++ b/deploy/profile-scripts/messenger.py @@ -148,21 +148,27 @@ class _MessengerStdout: def _write_broadcast_from_stdout(text, script): - """把 stdout 内容写入 broadcast_messages(仅包含有意义的内容行)""" + """把 stdout 内容直接写入 broadcast_messages(不经 send, 避免 xmpp 递归)""" if not text or not text.strip(): return - # 过滤纯日志/进度(如 [DB]/[SYNC]/百分比), 只保留有信息量的行 t = text.strip() - skip_prefix = ("[DB]", "[SYNC", "[guard", "[regime] ", "⏱", "📊 ", "📥 ", "💾 ", "🔄 ") + skip_prefix = ("[DB]", "[SYNC", "[guard", "[regime] ", "⏱", "📊 ", "📥 ", "💾 ", "🔄 ", "[SILENT]") for line in t.split("\n"): line = line.strip() if not line or len(line) < 3: continue if line.startswith(skip_prefix): continue - # 有意义的内容行 → 写广播表 + if line.startswith("【") and "】" in line and "MoFin·" in line: + continue # 跳过已格式化的 messenger 输出, 防递归 try: - send(title=f"MoFin·{_job_title(script)}", content=line, source=script) + category = _classify(_job_title(script), line) + conn = sqlite3.connect(DB, timeout=30) + conn.execute( + "INSERT INTO broadcast_messages (ts, category, title, content, source) VALUES (?,?,?,?,?)", + (datetime.now().isoformat(), category, _job_title(script), line, script)) + conn.commit() + conn.close() except Exception: pass