Skip to content

Refactor _extract_session_id for chat type handling#5775

Open
lppsuixn wants to merge 2 commits intoAstrBotDevs:masterfrom
lppsuixn:fix-wecomai-chatid-extrat
Open

Refactor _extract_session_id for chat type handling#5775
lppsuixn wants to merge 2 commits intoAstrBotDevs:masterfrom
lppsuixn:fix-wecomai-chatid-extrat

Conversation

@lppsuixn
Copy link

@lppsuixn lppsuixn commented Mar 5, 2026

Update session ID extraction to handle group and single chat types.

fix #5770
修复企业微信智能机器人群聊id不正确

Modifications / 改动点

  • This is NOT a breaking change. / 这不是一个破坏性变更。

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


Checklist / 检查清单

  • 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。/ 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.
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到了 requirements.txtpyproject.toml 文件相应位置。/ 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

错误修复:

  • 通过使用群聊 ID 而不是用户 ID,修复了 WeCom AI 机器人群聊会话 ID 生成不正确的问题。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Fix incorrect session ID generation for WeCom AI bot group chats by using chat IDs instead of user IDs.

@auto-assign auto-assign bot requested review from LIghtJUNction and Soulter March 5, 2026 15:28
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 5, 2026
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - 我已经审核了你的修改,看起来非常不错!


Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,请考虑分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈来改进后续的评审。
Original comment in English

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@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!

This pull request refactors the session ID extraction mechanism for the WeCom AI bot adapter. The primary goal is to correctly identify and use appropriate session identifiers for different chat types, specifically addressing a bug where group chats were assigned incorrect session IDs. This change ensures that conversations in both single and group chats are properly managed and tracked.

Highlights

  • Session ID Extraction Logic: Modified the _extract_session_id method to dynamically determine the session ID based on the chat type, using chatid for group chats and userid for single chats.
  • Bug Fix: Resolved an issue where WeCom AI bot group chats were generating incorrect session IDs by ensuring the chatid is used instead of the userid for group conversations.
Changelog
  • astrbot/core/platform/sources/wecom_ai_bot/wecomai_adapter.py
    • Updated the _extract_session_id method to include logic for distinguishing between 'group' and 'single' chat types.
    • Implemented conditional session ID generation: chatid is now used for group chats, and userid for single chats.
    • Added comments to the _extract_session_id method explaining the new logic for chat type handling.
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

@dosubot
Copy link

dosubot bot commented Mar 5, 2026

Related Documentation

Checked 1 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@dosubot dosubot bot added the area:platform The bug / feature is about IM platform adapter, such as QQ, Lark, Telegram, WebChat and so on. label Mar 5, 2026
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

The pull request correctly implements session ID extraction based on chat type (group or single), which resolves the reported issue regarding incorrect session ID generation for WeCom AI bot group chats. The updated docstring also enhances clarity regarding the logic. The identified opportunity to improve the _extract_session_id method by passing the correct chat type to the format_session_id utility function remains valid, ensuring consistency with its intended usage and the parse_session_id function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:platform The bug / feature is about IM platform adapter, such as QQ, Lark, Telegram, WebChat and so on. size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]企微智能机器人支持不同的群聊设置不用的人格,不同的主动发送webhook url

1 participant