From 67f4c0fb6267b648b4cbb24b9f7d6c63da63dde0 Mon Sep 17 00:00:00 2001 From: Yufeng He <40085740+universeplayer@users.noreply.github.com> Date: Mon, 6 Apr 2026 20:48:24 +0800 Subject: [PATCH] fix(telegram): skip empty text in sendMessageDraft to prevent 400 spam When streaming is enabled, markdownify() can produce empty strings for certain inputs (whitespace-only, formatting-only markdown). The draft sender loop then calls sendMessageDraft with empty text, which Telegram rejects with 'Text must be non-empty', flooding the log every 0.5s. Add an early return in _send_message_draft() when text is empty or whitespace-only. This matches WebChat's approach of skipping empty responses. Fixes #7353 --- astrbot/core/platform/sources/telegram/tg_event.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/astrbot/core/platform/sources/telegram/tg_event.py b/astrbot/core/platform/sources/telegram/tg_event.py index f963969b7c..8d86570739 100644 --- a/astrbot/core/platform/sources/telegram/tg_event.py +++ b/astrbot/core/platform/sources/telegram/tg_event.py @@ -389,6 +389,9 @@ async def _send_message_draft( message_thread_id: 可选,目标消息线程 ID parse_mode: 可选,消息文本的解析模式 """ + if not text or not text.strip(): + return + kwargs: dict[str, Any] = {} if message_thread_id: kwargs["message_thread_id"] = int(message_thread_id)