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