Skip to content

feat(telegram): support Bot API 9.5 sendMessageDraft in group chats (#1)#6666

Draft
lekoOwO wants to merge 2 commits intoAstrBotDevs:masterfrom
lekoOwO:master
Draft

feat(telegram): support Bot API 9.5 sendMessageDraft in group chats (#1)#6666
lekoOwO wants to merge 2 commits intoAstrBotDevs:masterfrom
lekoOwO:master

Conversation

@lekoOwO
Copy link

@lekoOwO lekoOwO commented Mar 20, 2026

elegram Bot API 9.5 現已支援在群組聊天中使用 sendMessageDraft。在此之前,AstrBot 的 Telegram 適配器在群組中進行流式輸出時,必須回退(fallback)到頻繁編輯訊息的方式。

本 PR 通過升級 python-telegram-bot 並移除私聊限制,讓群組聊天也能享有更平滑的串流動畫體驗。

Modifications / 改动点

  • astrbot/core/platform/sources/telegram/tg_event.py:

    • 移除 send_streaming 中針對私聊(is_private)的顯式檢查。
    • 現在群組聊天也會優先使用 _send_streaming_draft 進行流式輸出。
    • 更新相關註解以符合 Bot API 9.5+ 的規格。
  • pyproject.toml & requirements.txt:

    • python-telegram-bot 依賴版本從 >=22.6 提升至 >=22.7 以支援新版 API。
  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

  • 驗證步驟:在 Telegram 群組中觸發長回覆。
  • 預期結果:日誌顯示 [Telegram] streaming output: using sendMessageDraft,且群組內出現草稿動畫效果。

Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • 😮 My changes do not introduce malicious code.

還需要我針對具體的測試日誌內容幫你補充到「運行截圖」一欄嗎?

Summary by Sourcery

Enable Telegram streaming responses to use sendMessageDraft in both private and group chats by leveraging Bot API 9.5+ support.

New Features:

  • Allow Telegram group chats to use sendMessageDraft-based streaming output instead of falling back to edit_message_text.

Enhancements:

  • Update Telegram adapter logging and documentation strings to reflect sendMessageDraft support for all chat types in Bot API 9.5+.

Build:

  • Bump python-telegram-bot dependency from >=22.6 to >=22.7 to support the newer Telegram Bot API.

* Initial plan

* feat: update python-telegram-bot to >=22.7 and remove is_private check for Bot API 9.5

Co-authored-by: lekoOwO <20151124+lekoOwO@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lekoOwO <20151124+lekoOwO@users.noreply.github.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此 PR 旨在顯著提升 AstrBot 在 Telegram 群組聊天中的流式輸出體驗。透過利用 Telegram Bot API 9.5 新增的 sendMessageDraft 功能,現在群組聊天也能享受更平滑的串流動畫,取代了以往頻繁編輯訊息的備用方案,從而改善了用戶互動的流暢性。

Highlights

  • Telegram Bot API 9.5 支援: 引入了對 Telegram Bot API 9.5 sendMessageDraft 的支援,使其現在可以在群組聊天中使用,提供更流暢的串流動畫體驗。
  • 移除私聊限制: 移除了 send_streaming 函數中針對私聊的顯式檢查,允許群組聊天也能優先使用 _send_streaming_draft 進行流式輸出。
  • 依賴升級: 將 python-telegram-bot 的依賴版本從 >=22.6 升級至 >=22.7,以支援新的 Bot API 功能。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

本次 PR 很好地利用了 Telegram Bot API 9.5 的新特性,通过在群组聊天中也使用 sendMessageDraft,提升了流式输出的体验。代码实现简洁明了,依赖项的更新也正确无误。不过,相关的文档(如 docs/zh/platform/telegram.md)似乎没有同步更新,建议一并修改以反映群聊现在也支持 sendMessageDraft 的事实。此外,有一处日志的语言可以调整以保持一致性。

@lekoOwO
Copy link
Author

lekoOwO commented Mar 20, 2026

fixes #6659

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants