Repository navigation
fix: separate handler matching from wake state - #10774
Open
helo060228 wants to merge 2 commits into
Open
helo060228 wants to merge 2 commits into
helo060228 wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="astrbot/core/platform/astr_message_event.py" line_range="103" />
<code_context>
+ """通过消息过滤器的插件处理器,不代表事件已唤醒机器人。"""
self.is_at_or_wake_command = False
- """是否是 At 机器人或者带有唤醒词或者是私聊(插件注册的事件监听器会让 is_wake 设为 True, 但是不会让这个属性置为 True)"""
+ """是否是 At 机器人或者带有唤醒词或者是私聊"""
self._extras: dict[str, Any] = {}
self._force_stopped: bool = False
</code_context>
<issue_to_address>
**Private chats misdocumented as always active**
When `friend_message_needs_wake_prefix` is enabled for a non-webchat private message, the field comment says every private chat sets `is_at_or_wake_command`, but `WakingCheckStage` leaves it false for private messages when `friend_message_needs_wake_prefix` is enabled (except webchat). Callers relying on the comment will misinterpret the event’s wake intent.
Clarify in the field comment that private chats set this flag only when prefix requirements allow it.
</issue_to_address>
### Comment 2
<location path="astrbot/core/platform/astr_message_event.py" line_range="100" />
<code_context>
"""用户是否是管理员。如果是管理员,这里是 admin"""
self.is_wake = False
"""是否唤醒(是否通过 WakingStage)"""
+ self.matched_handlers: list[StarHandlerMetadata] = []
+ """通过消息过滤器的插件处理器,不代表事件已唤醒机器人。"""
self.is_at_or_wake_command = False
</code_context>
<issue_to_address>
**New comments are not English**
The added and updated docstrings use Chinese, contrary to the repository rule that comments and logs be in English.
Write both docstrings in English.
Also at `astrbot/core/platform/astr_message_event.py:103`.
</issue_to_address>Sourcery assessment
Approved.
Describe matched_handlers as filter matches that do not imply a wake, and state that private chats set is_at_or_wake_command only when prefix rules allow it. Co-authored-by: helo060228 <helo060228@users.noreply.github.com>
This branch has not been deployed
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
event.is_wakefocused on explicit user intent: @ mentions, wake prefixes, private-chat policy, and session waiters.event.matched_handlerswhile preservingactivated_handlers.Verification
pytest tests/unit/test_waking_check_wake_state.py tests/unit/test_command_group_filter.py tests/unit/test_session_waiter_pipeline.py tests/unit/test_astr_message_event.py -q— 117 passedruff check astrbot/core/platform/astr_message_event.py astrbot/core/pipeline/waking_check/stage.py tests/unit/test_waking_check_wake_state.pygit diff --checkCloses #10699
Summary by Sourcery
Separate plugin handler matching from explicit wake-state determination so ambient listeners can process ordinary messages without waking the LLM.
New Features:
matched_handlersproperty.Bug Fixes:
Enhancements:
is_wakerepresents explicit user intent rather than handler matching.Tests: