docs: clarify DefaultSessionFilter handling in documentation - #10143
fudengming wants to merge 1 commit into
Conversation
In AstrBotDevs#1326, the return value of `DefaultSessionFilter` changed from `event.get_sender_id()` to `event.unified_msg_origin`, while the documentation still says `sender_id` is returned.
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="docs/en/dev/star/guides/session-control.md" line_range="125" />
<code_context>
- return (
- event.get_group_id() if event.get_group_id() else event.unified_msg_origin
- )
+ return f"{event.unified_msg_origin}:{event.get_sender_id()}"
</code_context>
<issue_to_address>
**issue:** The example combines `unified_msg_origin` with `get_sender_id()`, so the resulting key still contains the group/session identifier and users from different groups can never share one session. This contradicts the preceding description that the custom filter can combine users from different groups into a single session.
**Triggers:** When a developer follows this example to create a session shared by users in different groups.
**Suggested fix:** Use a grouping key that omits the group-specific portion, such as the sender ID for cross-group per-user sessions, or show an explicit shared key for the users that should be grouped.
```suggestion
return event.get_sender_id()
```
</issue_to_address>
### Comment 2
<location path="docs/zh/dev/star/guides/session-control.md" line_range="102" />
<code_context>
## 自定义会话 ID 算子
-默认情况下,AstrBot 会话控制器会将基于 `sender_id` (发送人的 ID)作为识别不同会话的标识,如果想将一整个群作为一个会话,则需要自定义会话 ID 算子。
+默认情况下,AstrBot 会话控制器会将基于 `unified_msg_origin` (会话 ID)作为识别不同会话的标识,如果只想将一个群的一个或一些用户又或不同群的不同用户作为一个会话,则需要自定义会话 ID 算子。
```py
</code_context>
<issue_to_address>
**issue:** The parallel documentation page `docs/zh/dev/star/plugin.md` still states that the default filter returns `sender_id` and shows the old group-wide filter, so Chinese users consulting that page continue to receive the behavior that this change is intended to correct.
**Triggers:** When users read the session-control material in `docs/zh/dev/star/plugin.md` instead of the updated guide.
**Suggested fix:** Update the duplicated session-filter section in `docs/zh/dev/star/plugin.md` to match the new default and custom-filter behavior, or replace it with a link to the canonical guide.
</issue_to_address>Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: docs/en/dev/star/guides/session-control.md:125, docs/zh/dev/star/guides/session-control.md:102
| return ( | ||
| event.get_group_id() if event.get_group_id() else event.unified_msg_origin | ||
| ) | ||
| return f"{event.unified_msg_origin}:{event.get_sender_id()}" |
There was a problem hiding this comment.
issue: The example combines unified_msg_origin with get_sender_id(), so the resulting key still contains the group/session identifier and users from different groups can never share one session. This contradicts the preceding description that the custom filter can combine users from different groups into a single session.
Triggers: When a developer follows this example to create a session shared by users in different groups.
Suggested fix: Use a grouping key that omits the group-specific portion, such as the sender ID for cross-group per-user sessions, or show an explicit shared key for the users that should be grouped.
| return f"{event.unified_msg_origin}:{event.get_sender_id()}" | |
| return event.get_sender_id() |
| ## 自定义会话 ID 算子 | ||
|
|
||
| 默认情况下,AstrBot 会话控制器会将基于 `sender_id` (发送人的 ID)作为识别不同会话的标识,如果想将一整个群作为一个会话,则需要自定义会话 ID 算子。 | ||
| 默认情况下,AstrBot 会话控制器会将基于 `unified_msg_origin` (会话 ID)作为识别不同会话的标识,如果只想将一个群的一个或一些用户又或不同群的不同用户作为一个会话,则需要自定义会话 ID 算子。 |
There was a problem hiding this comment.
issue: The parallel documentation page docs/zh/dev/star/plugin.md still states that the default filter returns sender_id and shows the old group-wide filter, so Chinese users consulting that page continue to receive the behavior that this change is intended to correct.
Triggers: When users read the session-control material in docs/zh/dev/star/plugin.md instead of the updated guide.
Suggested fix: Update the duplicated session-filter section in docs/zh/dev/star/plugin.md to match the new default and custom-filter behavior, or replace it with a link to the canonical guide.
In #1326, the return value of
DefaultSessionFilterchanged fromevent.get_sender_id()toevent.unified_msg_origin, while the documentation still sayssender_idis returned.Modifications / 改动点
Only documentation.
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
📚 I checked the affected WebUI instructions and screenshots in
docs/zhanddocs/enagainst the changed navigation, page structure, and labels, and updated them in this PR (or explained why no documentation update is needed). For renamed, moved, or merged entry points, I included an old entry → new entry mapping in the documentation and changelog./ 我已对照变化后的 WebUI 入口、页面结构和术语,核对并在本 PR 中更新
docs/zh和docs/en的相关操作说明与截图(或说明无需更新文档的原因)。入口改名、移动或合并时,已在文档和 changelog 中补充 旧入口 → 新入口 对照。🤓 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.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Clarify how default and custom session filters determine session boundaries.
Enhancements:
Documentation:
unified_msg_originas the default identifier and explain per-user session filtering within groups and across chats.