fix(telegram): dedupe webhook+polling updates via shared DB guard
All checks were successful
CD Pipeline / deploy (push) Successful in 8m50s
All checks were successful
CD Pipeline / deploy (push) Successful in 8m50s
Webhook (Flask) and polling (momo-telegram-bot) consumed the same Telegram update_id, causing /menu callbacks to fire twice. Add a shared dedup module backed by telegram_update_dedup table (300s TTL, 60s cleanup) with in-memory fallback, wired into both paths. Polling launcher now skips startup when webhook is configured to prevent dual-consumption at the source. 38 tests across webhook, menu keyboards, telegram_api, dedup guard, and trend bot service. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -85,6 +85,12 @@ async def main():
|
||||
# 建立 Bot 服務
|
||||
bot_service = TelegramBotService(token)
|
||||
|
||||
if not bot_service.should_run_polling():
|
||||
logger.warning(
|
||||
"Webhook 已設定,Polling Bot 已跳過啟動;請使用 OpenClaw webhook 路徑處理互動。"
|
||||
)
|
||||
return
|
||||
|
||||
# 取得 Application
|
||||
app = bot_service.get_application()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user