fix(session_waiter): bind empty-mention waiter to the initiating sender (#9377) - #9422
Open
Qixuan112 wants to merge 2 commits into
Open
fix(session_waiter): bind empty-mention waiter to the initiating sender (#9377)#9422Qixuan112 wants to merge 2 commits into
Qixuan112 wants to merge 2 commits into
Conversation
…er to avoid intercepting other group members (AstrBotDevs#9377)
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider moving
_SenderSessionFilterout ofhandle_empty_mentioninto module scope so it isn’t redefined on every call and can be reused or tested independently. - When building the session key in
_SenderSessionFilter.filter, consider explicitly handling cases whereget_sender_id()might beNoneor unexpected to avoid collisions or hard-to-debug behavior.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider moving `_SenderSessionFilter` out of `handle_empty_mention` into module scope so it isn’t redefined on every call and can be reused or tested independently.
- When building the session key in `_SenderSessionFilter.filter`, consider explicitly handling cases where `get_sender_id()` might be `None` or unexpected to avoid collisions or hard-to-debug behavior.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Author
|
Addressed both suggestions in dfd6c00:
(🤖 Addressed by Claude Code) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #9377
Problem
When a user sent an empty @mention (or wake-prefix-only message) in a group chat, the
empty_mention_waiterusedDefaultSessionFilterwhich keyed sessions only byevent.unified_msg_origin(the group/conversation ID). This meant any subsequent message from any member in that group would trigger the waiter and be consumed viaevent.stop_event(), causing other members' messages to be silently intercepted.Fix
Added a custom
_SenderSessionFilterthat includesevent.get_sender_id()in the session key:This ensures the waiter only responds to messages from the same sender who initiated the empty mention, matching expected multi-user group chat behavior.
Changes
astrbot/builtin_stars/astrbot/main.py: importedSessionFilter, added a sender-scoped filter forempty_mention_waiter(+6/-1 lines)Summary by Sourcery
Bug Fixes: