feat(qq): 支持 QQ GroupMessageCreateEvent 全量群消息事件#33
Open
This-is-XiaoDeng wants to merge 3 commits into
Open
Conversation
QQ adapter v1.7.0+ 新增了 GroupMessageCreateEvent(全量群消息, 无需@机器人),GroupAtMessageCreateEvent 现继承自它。 修改: - 添加 GroupMessageCreateEvent 导入 - extract_platform(): 添加 EventType.GROUP_MESSAGE_CREATE → qq - extract_level(): 添加 EventType.GROUP_MESSAGE_CREATE → LEVEL2 - extract_id2(): 添加 GroupMessageCreateEvent → group_openid
- 新增 test_group_message_create_event 测试全量群消息事件 - 修复 test_group_at_message_create_event 的 __type__ 错误 (之前误写为 C2C_MESSAGE_CREATE) - 适配 adapter-qq v1.7.1 的 GroupMemberAuthor 新增 bot 字段 和 GroupMessageCreateEvent 新增 group_id 字段
- 用单独 try/except 导入 GroupMessageCreateEvent,低版本设为 None - extract_platform/level 中使用 _HAS_GROUP_MESSAGE 标志守卫 EventType.GROUP_MESSAGE_CREATE 的访问 - extract_id2 中检查 GroupMessageCreateEvent 是否为 None 再 isinstance - 低版本 adapter 完全不受影响,高版本自动启用新事件支持
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.
背景
QQ adapter (adapter-qq) v1.7.0+ 新增了
GroupMessageCreateEvent(EventType.GROUP_MESSAGE_CREATE),用于接收不需要 @ 机器人的全量群消息。GroupAtMessageCreateEvent现已继承自此类。改动
nonebot_plugin_session/adapters/qq.pyGroupMessageCreateEvent导入(独立 try/except 兼容低版本)extract_platform()_HAS_GROUP_MESSAGE标志守卫,高版本 ⮕qqextract_level()LEVEL2extract_id2()self.event.group_openidtests/test_qq.pytest_group_message_create_event;修复test_group_at_message_create_event的__type__误写为C2C_MESSAGE_CREATE的问题;适配 adapter-qq v1.7.1 模型变化兼容性
GroupMessageCreateEvent导入失败时设为None,isinstance检查搭配is not None守卫,不会报错EventType.GROUP_MESSAGE_CREATE的访问用hasattr(EventType, ...)守卫,低版本不会触发AttributeError