← Back to library

Telegram Inbound Unification:message 与 channel_post 走同一路径防漏处理

问题/场景:Telegram 频道帖与普通消息分流处理容易产生行为不一致(去重、边界、告警)。前置条件:已接入 Telegram 且处理频道消息。实施步骤:统一 message/channel_post 入口 → 保留频道专属边界逻辑 → 扩展去重 key 覆盖 channel_post。关键命令:npm run build。验证:同一 update 在两类入口下行为一致且不重复入库。风险:若历史依赖分流副作用,迁移后需回归测试。来源:PR #20591。

GITHUBDiscovered 2026-02-19Author obviyus
Prerequisites
  • Telegram bot has permissions for both private/group messages and channel posts.
  • Your pipeline has dedupe logic and regression test harness for inbound updates.
Steps
  1. Refactor inbound dispatcher so `message` and `channel_post` call the same handler function.
  2. Keep channel-only behavior (synthetic sender / no oversize warning reply) as explicit branch options.
  3. Extend dedupe and sequence-key extraction to include `channel_post` payload fields.
  4. Add regression tests for duplicate and mixed update streams.
Commands
npm run build
Verify

Replay mixed Telegram updates; each logical message is processed once and channel-specific behavior remains intact.

Caveats
  • If third-party plugins rely on old handler branching, update their assumptions before rollout.
  • Historical dedupe keys may differ between deployments, so old duplicates may still appear during migration(需验证).
Source attribution

This tip is aggregated from community/public sources and preserved with attribution.

Open original source ↗
Visit original post