Skip to content

完善Reaction相关实现#183

Merged
MrXiaoM merged 3 commits into
MrXiaoM:mainfrom
xiaoyv404:feat/reaction
Feb 11, 2026
Merged

完善Reaction相关实现#183
MrXiaoM merged 3 commits into
MrXiaoM:mainfrom
xiaoyv404:feat/reaction

Conversation

@xiaoyv404
Copy link
Copy Markdown
Contributor

在提出此拉取请求时,我确认了以下几点(请复选框):

  • 我已阅读并理解贡献文档
  • 我已检查没有与此请求重复的 Pull Requests。
  • 我已经考虑过,并确认这份呈件对其他人很有价值。
  • 我接受此提交可能不会被使用,并根据维护人员的意愿关闭 Pull Requests。

填写PR内容:

为 MessageReactionEvent 添加 toString 方法
Napcat, LLonebot 新版本 group_msg_emoji_like 接口 is_add 字段支持

Copilot AI review requested due to automatic review settings February 11, 2026 10:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 完善消息表情回应(Reaction)相关能力:在接收到 OneBot 的群消息表情回应通知时,能够区分“添加/移除”操作,并补充 MessageReactionEventtoString() 便于日志/调试定位。

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!!
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里 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

Copilot uses AI. Check for mistakes.
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)"
}
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toString 的实现与本仓库其他事件类的风格不一致:缺少 : String 返回类型标注、=/{ 前后的空格,以及当前输出直接拼接了 bot/group/operator 对象本身而不是更稳定的标识(仓库内常用 bot.idgroup.idoperator.id 这类字段,见 MemberEssenceNoticeEvent.toString 等)。建议按现有事件的写法统一格式并优先输出 ID,避免日志过长/不稳定。

Copilot uses AI. Check for mistakes.
@MrXiaoM MrXiaoM merged commit 5a51e1a into MrXiaoM:main Feb 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants