完善Reaction相关实现#183
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
该 PR 完善消息表情回应(Reaction)相关能力:在接收到 OneBot 的群消息表情回应通知时,能够区分“添加/移除”操作,并补充 MessageReactionEvent 的 toString() 便于日志/调试定位。
Changes:
- 为
group_msg_emoji_like通知事件补充is_add字段解析(可空)。 - 在群监听中将
is_add映射到MessageReactionEvent.operation,用于标识添加/移除。 - 为
MessageReactionEvent增加toString()实现。
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/listener/group.kt | 使用 is_add 决定 Reaction 事件的 operation,并在缺失字段时给出提示 |
| overflow-core/src/main/kotlin/cn/evolvefield/onebot/sdk/event/notice/misc/GroupMsgEmojiLikeNotice.kt | 为通知事件新增 is_add 字段以支持新实现 |
| overflow-core-api/src/main/kotlin/top/mrxiaom/overflow/event/MessageReactionEvent.kt | 新增 toString() 便于输出事件关键信息 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+433
to
+437
| val isAdd = if (e.isAdd == null) { | ||
| logger.warning("请更新至新版 NapCat 或 LLOnebot") | ||
| true | ||
| } else { | ||
| e.isAdd!! |
There was a problem hiding this comment.
这里 else 分支对 e.isAdd 使用了 !!,在你已经判空后属于不必要的非空断言,后续如果逻辑改动更容易引入 NPE。建议改成直接使用 e.isAdd(或用 Elvis/?: 结构统一写法)来避免 !!。
Suggested change
| val isAdd = if (e.isAdd == null) { | |
| logger.warning("请更新至新版 NapCat 或 LLOnebot") | |
| true | |
| } else { | |
| e.isAdd!! | |
| val isAdd = e.isAdd ?: run { | |
| logger.warning("请更新至新版 NapCat 或 LLOnebot") | |
| true |
Comment on lines
+40
to
+42
| ): BotEvent, AbstractEvent(){ | ||
| public override fun toString()= "MessageReactionEvent(bot=$bot, group=$group, operator=$operator, messageId=$messageId, reaction='$reaction', count=$count, operation=$operation)" | ||
| } |
There was a problem hiding this comment.
toString 的实现与本仓库其他事件类的风格不一致:缺少 : String 返回类型标注、=/{ 前后的空格,以及当前输出直接拼接了 bot/group/operator 对象本身而不是更稳定的标识(仓库内常用 bot.id、group.id、operator.id 这类字段,见 MemberEssenceNoticeEvent.toString 等)。建议按现有事件的写法统一格式并优先输出 ID,避免日志过长/不稳定。
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.
在提出此拉取请求时,我确认了以下几点(请复选框):
填写PR内容:
为 MessageReactionEvent 添加 toString 方法
Napcat, LLonebot 新版本 group_msg_emoji_like 接口 is_add 字段支持