diff --git a/en/platform/telegram.md b/en/platform/telegram.md index 1b64049..68ae143 100644 --- a/en/platform/telegram.md +++ b/en/platform/telegram.md @@ -36,4 +36,20 @@ Fill in the configuration fields that appear: - Enable: Check this option. - Bot Token: Your Telegram bot's `token`. -Please ensure your network environment can access Telegram. You may need to configure a proxy using `Configuration -> Other Settings -> HTTP Proxy`. \ No newline at end of file +Please ensure your network environment can access Telegram. You may need to configure a proxy using `Configuration -> Other Settings -> HTTP Proxy`. + +## Streaming Output + +The Telegram platform supports streaming output. Enable the "Streaming Output" switch in "AI Configuration" -> "Other Settings". + +### Private Chat Streaming + +In private chats, AstrBot uses the `sendMessageDraft` API (added in Telegram Bot API v9.3) for streaming output. This displays a "typing" draft preview animation in the chat interface, creating a more natural "typewriter" effect. It avoids issues with the traditional approach such as message flickering, push notification interference, and API edit frequency limits. + +### Group Chat Streaming + +In group chats, since the `sendMessageDraft` API only supports private chats, AstrBot automatically falls back to the traditional `send_message` + `edit_message_text` approach. + +:::warning +`sendMessageDraft` requires `python-telegram-bot>=22.6`. +::: diff --git a/zh/platform/telegram.md b/zh/platform/telegram.md index 849785b..0156b66 100644 --- a/zh/platform/telegram.md +++ b/zh/platform/telegram.md @@ -37,4 +37,20 @@ - 启用(enable): 勾选。 - Bot Token: 你的 Telegram 机器人的 `token`。 -请确保你的网络环境可以访问 Telegram。你可能需要使用 `配置页->其他配置->HTTP 代理` 来设置代理。 \ No newline at end of file +请确保你的网络环境可以访问 Telegram。你可能需要使用 `配置页->其他配置->HTTP 代理` 来设置代理。 + +## 流式输出 + +Telegram 平台支持流式输出。需要在「AI 配置」->「其他配置」中开启「流式输出」开关。 + +### 私聊流式输出 + +在私聊中,AstrBot 使用 Telegram Bot API v9.3 新增的 `sendMessageDraft` API 实现流式输出。这种方式会在私聊界面展示一个「正在输入」的草稿预览动画,体验更接近「打字机」效果,且避免了传统方案的消息闪烁、推送通知干扰和 API 编辑频率限制等问题。 + +### 群聊流式输出 + +在群聊中,由于 `sendMessageDraft` API 仅支持私聊,AstrBot 会自动回退到传统的 `send_message` + `edit_message_text` 方案。 + +:::warning +`sendMessageDraft` 功能需要 `python-telegram-bot>=22.6`。 +:::