From 641874851c9daf5b0ef2389ebe50e88b393891db Mon Sep 17 00:00:00 2001 From: zzhyyyyy <2685922758@qq.com> Date: Mon, 20 Jul 2026 15:48:31 +0800 Subject: [PATCH] =?UTF-8?q?feat(wx-poc):=20poller=20=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E5=BD=92=E6=A1=A3=E5=BB=B6=E8=BF=9F(msgtime=E2=86=92=E5=8F=96?= =?UTF-8?q?=E5=88=B0)=E7=94=A8=E4=BA=8E=E6=8E=92=E6=9F=A5=205-6s=20?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E5=BB=B6=E8=BF=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 会话存档消息自带 msgtime(腾讯发送时刻, 毫秒), 与 poller 取到当下之差 ≈ 企业微信会话存档归档延迟 + 本地 ≤0.5s 轮询间隔。加一行日志直接印出, 用来 坐实 5-6s 弹窗延迟里哪段是企业微信归档(不可控)、哪段是我们(已测 ~1.5s)。 Co-Authored-By: Claude Opus 4.8 --- scripts/wx_finance_poller.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/wx_finance_poller.py b/scripts/wx_finance_poller.py index 864d849..94f9dce 100644 --- a/scripts/wx_finance_poller.py +++ b/scripts/wx_finance_poller.py @@ -94,6 +94,14 @@ def _handle(client: httpx.Client, msg: dict) -> None: # weapp 卡片按小程序判源平台;image(截图)判不出平台,沿用 meituan。 source = _resolve_source(msg) if msgtype == "weapp" else "meituan" logger.info("命中触发 from=%s type=%s source=%s", frm, msgtype, source) + # 归档延迟排查: msgtime 是腾讯给的消息发送时刻(毫秒), 与 poller 此刻之差 + # ≈ 企业微信会话存档的归档延迟(+ 本地 ≤0.5s 轮询间隔), 用来隔离"是我们慢还是归档慢"。 + try: + _msgtime_ms = float(msg.get("msgtime") or 0) + if _msgtime_ms > 0: + logger.info("归档延迟(msgtime→poller取到) ≈ %.2fs", time.time() - _msgtime_ms / 1000.0) + except Exception: + pass _notify(client, source, msgtype)