Skip to content

🐛 Incorrect structure of emoji details (likes) in MessageEmojiLikeNoticeEvent; Message blocking was not working perfectly.#343

Merged
MisakaTAT merged 2 commits into
MisakaTAT:mainfrom
TinyTsuki:dev
Sep 8, 2025
Merged

Conversation

@TinyTsuki

@TinyTsuki TinyTsuki commented Sep 5, 2025

Copy link
Copy Markdown
Contributor

Sourcery 总结

修复 MessageEmojiLikeNoticeEvent 中的表情符号详细结构,并通过重构处理程序调用方法以支持可中断的事件处理来改进消息阻塞功能。

Bug 修复:

  • 重新设计 MessageEmojiLikeNoticeEvent,将表情符号 ID 和计数封装到一个嵌套的 Likes 类中,而不是独立的字段
  • 修正 GroupMessageReactionNoticeEvent 中表情符号 ID 和计数的 Javadoc 注解

改进:

  • 重构注入处理程序方法,使其返回一个布尔值以指示是否停止进一步的消息处理
  • 更新 MessageEvent 和 EventUtils,以检查消息阻塞标志并在请求时停止传播
Original summary in English

Summary by Sourcery

Fix emoji detail structure in MessageEmojiLikeNoticeEvent and improve message blocking functionality by refactoring handler invocation methods to support interruptible event processing.

Bug Fixes:

  • Redesign MessageEmojiLikeNoticeEvent to wrap emoji id and count into a nested Likes class instead of separate fields
  • Correct Javadoc annotations for emoji id and count in GroupMessageReactionNoticeEvent

Enhancements:

  • Refactor injection handler methods to return a boolean indicating whether to halt further message processing
  • Update MessageEvent and EventUtils to check message-blocking flags and stop propagation when requested

…iceEvent; Message blocking was not working perfectly.
@sourcery-ai

sourcery-ai Bot commented Sep 5, 2025

Copy link
Copy Markdown

审阅者指南

此拉取请求(PR)通过引入嵌套的 Likes 类来重构表情符号点赞事件的 JSON 映射,并优化了消息处理管道,通过将处理程序方法转换为返回布尔值并添加控制流检查来完全支持消息阻塞,此外还修正了反应事件 DTO 中的文档。

更新后的消息阻塞流程序列图(消息事件处理)

sequenceDiagram
participant Bot
participant EventUtils
participant InjectionHandler
participant Plugin
participant Interceptor

Bot->>EventUtils: pushAnyMessageEvent()
EventUtils->>InjectionHandler: invokeAnyMessage()
InjectionHandler-->>EventUtils: returns boolean (blocked?)
alt Message blocked
  EventUtils-->>Bot: returns true
else Not blocked
  EventUtils->>Plugin: onAnyMessage()
  Plugin-->>EventUtils: returns MESSAGE_BLOCK or not
  alt Plugin blocks
    EventUtils-->>Bot: returns true
  else Not blocked
    EventUtils-->>Bot: returns false
  end
end
Bot->>Interceptor: afterCompletion()
Loading

更新后的 MessageEmojiLikeNoticeEvent 结构类图

classDiagram
class MessageEmojiLikeNoticeEvent {
  Long operatorId
  Likes likes
}
class Likes {
  String emojiId
  Integer count
}
MessageEmojiLikeNoticeEvent --> Likes
Loading

更新后的消息处理程序方法签名类图

classDiagram
class InjectionHandler {
  boolean invokeAnyMessage(Bot, AnyMessageEvent)
  boolean invokeGuildMessage(Bot, GuildMessageEvent)
  boolean invokeGroupMessage(Bot, GroupMessageEvent)
  boolean invokePrivateMessage(Bot, PrivateMessageEvent)
  boolean invokeMessage(Bot, MessageEvent, Optional<List<HandlerMethod>>)
}
InjectionHandler --> Bot
InjectionHandler --> AnyMessageEvent
InjectionHandler --> GuildMessageEvent
InjectionHandler --> GroupMessageEvent
InjectionHandler --> PrivateMessageEvent
InjectionHandler --> MessageEvent
InjectionHandler --> HandlerMethod
Loading

更新后的 EventUtils.pushAnyMessageEvent 方法类图

classDiagram
class EventUtils {
  boolean pushAnyMessageEvent(Bot, JsonObjectWrapper, List<ArrayMsg>)
}
EventUtils --> Bot
EventUtils --> JsonObjectWrapper
EventUtils --> ArrayMsg
Loading

修正后的 GroupMessageReactionNoticeEvent 文档类图

classDiagram
class GroupMessageReactionNoticeEvent {
  String subType
  String code  "表情ID"
  Integer count "表情数量"
}
Loading

文件级更改

更改 详情 文件
将表情符号点赞详情重构为嵌套对象
  • 将扁平的 codecount 字段替换为嵌套的 Likes
  • Likes 中映射 JSON 属性 emoji_idcount
src/main/java/com/mikuac/shiro/dto/event/notice/MessageEmojiLikeNoticeEvent.java
将注入方法转换为返回阻塞状态
  • invokeAny/Group/Guild/Private/Message 签名更改为布尔类型
  • invokeMessage 指示阻塞时提前返回
src/main/java/com/mikuac/shiro/handler/injection/InjectionHandler.java
MessageEvent 处理中添加阻塞检查
  • 捕获 pushAnyMessageEventinvokeXxxMessage 的返回值
  • 如果任何阶段返回阻塞,则跳过后续插件调用
src/main/java/com/mikuac/shiro/handler/event/MessageEvent.java
重构 pushAnyMessageEvent 以返回阻塞指示
  • 将返回类型更改为布尔值
  • 在任何 MESSAGE_BLOCK 结果时立即返回 true
src/main/java/com/mikuac/shiro/common/utils/EventUtils.java
修正 GroupMessageReactionNoticeEvent 中的 Javadoc
  • code 字段的注释更新为 '表情ID'
  • count 字段的注释更新为 '表情数量'
src/main/java/com/mikuac/shiro/dto/event/notice/GroupMessageReactionNoticeEvent.java

提示和命令

与 Sourcery 互动

  • 触发新审阅: 在拉取请求上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审阅评论。
  • 从审阅评论生成 GitHub issue: 通过回复审阅评论,要求 Sourcery 从中创建一个 issue。您也可以回复审阅评论并带上 @sourcery-ai issue 来创建 issue。
  • 生成拉取请求标题: 随时在拉取请求标题的任意位置写入 @sourcery-ai 来生成标题。您也可以在拉取请求上评论 @sourcery-ai title 来随时(重新)生成标题。
  • 生成拉取请求摘要: 随时在拉取请求正文的任意位置写入 @sourcery-ai summary,以在您希望的位置生成 PR 摘要。您也可以在拉取请求上评论 @sourcery-ai summary 来随时(重新)生成摘要。
  • 生成审阅者指南: 在拉取请求上评论 @sourcery-ai guide 来随时(重新)生成审阅者指南。
  • 解决所有 Sourcery 评论: 在拉取请求上评论 @sourcery-ai resolve 来解决所有 Sourcery 评论。如果您已经处理了所有评论并且不想再看到它们,这会很有用。
  • 驳回所有 Sourcery 审阅: 在拉取请求上评论 @sourcery-ai dismiss 来驳回所有现有 Sourcery 审阅。如果您想从头开始新的审阅,这尤其有用——别忘了评论 @sourcery-ai review 来触发新的审阅!

自定义您的体验

访问您的仪表板以:

  • 启用或禁用审阅功能,例如 Sourcery 生成的拉取请求摘要、审阅者指南等。
  • 更改审阅语言。
  • 添加、删除或编辑自定义审阅说明。
  • 调整其他审阅设置。

获取帮助

Original review guide in English

Reviewer's Guide

This PR restructures the emoji like event JSON mapping by introducing a nested Likes class and refines the message processing pipeline to fully support blocking by converting handler methods to return booleans and adding control‐flow checks, plus it corrects documentation in the reaction event DTO.

Sequence diagram for updated message blocking flow in message event processing

sequenceDiagram
participant Bot
participant EventUtils
participant InjectionHandler
participant Plugin
participant Interceptor

Bot->>EventUtils: pushAnyMessageEvent()
EventUtils->>InjectionHandler: invokeAnyMessage()
InjectionHandler-->>EventUtils: returns boolean (blocked?)
alt Message blocked
  EventUtils-->>Bot: returns true
else Not blocked
  EventUtils->>Plugin: onAnyMessage()
  Plugin-->>EventUtils: returns MESSAGE_BLOCK or not
  alt Plugin blocks
    EventUtils-->>Bot: returns true
  else Not blocked
    EventUtils-->>Bot: returns false
  end
end
Bot->>Interceptor: afterCompletion()
Loading

Class diagram for updated MessageEmojiLikeNoticeEvent structure

classDiagram
class MessageEmojiLikeNoticeEvent {
  Long operatorId
  Likes likes
}
class Likes {
  String emojiId
  Integer count
}
MessageEmojiLikeNoticeEvent --> Likes
Loading

Class diagram for updated message handler method signatures

classDiagram
class InjectionHandler {
  boolean invokeAnyMessage(Bot, AnyMessageEvent)
  boolean invokeGuildMessage(Bot, GuildMessageEvent)
  boolean invokeGroupMessage(Bot, GroupMessageEvent)
  boolean invokePrivateMessage(Bot, PrivateMessageEvent)
  boolean invokeMessage(Bot, MessageEvent, Optional<List<HandlerMethod>>)
}
InjectionHandler --> Bot
InjectionHandler --> AnyMessageEvent
InjectionHandler --> GuildMessageEvent
InjectionHandler --> GroupMessageEvent
InjectionHandler --> PrivateMessageEvent
InjectionHandler --> MessageEvent
InjectionHandler --> HandlerMethod
Loading

Class diagram for updated EventUtils.pushAnyMessageEvent method

classDiagram
class EventUtils {
  boolean pushAnyMessageEvent(Bot, JsonObjectWrapper, List<ArrayMsg>)
}
EventUtils --> Bot
EventUtils --> JsonObjectWrapper
EventUtils --> ArrayMsg
Loading

Class diagram for corrected GroupMessageReactionNoticeEvent documentation

classDiagram
class GroupMessageReactionNoticeEvent {
  String subType
  String code  "表情ID"
  Integer count "表情数量"
}
Loading

File-Level Changes

Change Details Files
Restructure emoji like details into nested object
  • Replace flat code and count fields with a nested Likes class
  • Map JSON properties emoji_id and count inside Likes
src/main/java/com/mikuac/shiro/dto/event/notice/MessageEmojiLikeNoticeEvent.java
Convert injection methods to return blocking status
  • Change invokeAny/Group/Guild/Private/Message signatures to boolean
  • Return early when invokeMessage indicates a block
src/main/java/com/mikuac/shiro/handler/injection/InjectionHandler.java
Add blocking checks in MessageEvent processing
  • Capture pushAnyMessageEvent and invokeXxxMessage return values
  • Skip downstream plugin calls if any stage returns blocked
src/main/java/com/mikuac/shiro/handler/event/MessageEvent.java
Refactor pushAnyMessageEvent to return block indication
  • Change return type to boolean
  • Return true immediately on any MESSAGE_BLOCK result
src/main/java/com/mikuac/shiro/common/utils/EventUtils.java
Correct Javadoc in GroupMessageReactionNoticeEvent
  • Update comments for code field to '表情ID'
  • Update comments for count field to '表情数量'
src/main/java/com/mikuac/shiro/dto/event/notice/GroupMessageReactionNoticeEvent.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

你好 - 我已审阅了你的更改 - 这里有一些反馈:

  • 在 MessageEvent.process 中,bot.getPluginList().stream().anyMatch(...) 调用没有重新分配给 messageBlocked,因此插件 MESSAGE_BLOCK 信号实际上不会停止进一步处理 — 捕获并传播该结果。
  • MessageEvent.process 中私聊/群聊/公会消息处理存在大量重复 — 考虑将通用的 push/invoke/plugin 逻辑提取到一个共享的帮助器中以提高可维护性。
  • 在使用嵌套的 Likes 类重构 MessageEmojiLikeNoticeEvent 后,请仔细检查所有期望 'code' 和 'count' 的序列化器和客户端是否已更新或别名以实现向后兼容性。
供 AI 代理的提示
请解决此代码审查中的注释:
## 总体评论
- 在 MessageEvent.process 中,bot.getPluginList().stream().anyMatch(...) 调用没有重新分配给 messageBlocked,因此插件 MESSAGE_BLOCK 信号实际上不会停止进一步处理 — 捕获并传播该结果。
- MessageEvent.process 中私聊/群聊/公会消息处理存在大量重复 — 考虑将通用的 push/invoke/plugin 逻辑提取到一个共享的帮助器中以提高可维护性。
- 在使用嵌套的 Likes 类重构 MessageEmojiLikeNoticeEvent 后,请仔细检查所有期望 'code' 和 'count' 的序列化器和客户端是否已更新或别名以实现向后兼容性。

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
帮助我更有用!请点击每个评论上的 👍 或 👎,我将使用这些反馈来改进你的评论。
Original comment in English

Hey there - I've reviewed your changes - here's some feedback:

  • In MessageEvent.process, the bot.getPluginList().stream().anyMatch(...) calls aren’t assigned back to messageBlocked, so plugin MESSAGE_BLOCK signals won’t actually halt further processing — capture and propagate that result.
  • There’s significant duplication in the private/group/guild message handling in MessageEvent.process — consider extracting the common push/invoke/plugin logic into a shared helper to improve maintainability.
  • After restructuring MessageEmojiLikeNoticeEvent with the nested Likes class, double-check that all serializers and clients expecting 'code' and 'count' are updated or aliased for backward compatibility.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In MessageEvent.process, the bot.getPluginList().stream().anyMatch(...) calls aren’t assigned back to messageBlocked, so plugin MESSAGE_BLOCK signals won’t actually halt further processing — capture and propagate that result.
- There’s significant duplication in the private/group/guild message handling in MessageEvent.process — consider extracting the common push/invoke/plugin logic into a shared helper to improve maintainability.
- After restructuring MessageEmojiLikeNoticeEvent with the nested Likes class, double-check that all serializers and clients expecting 'code' and 'count' are updated or aliased for backward compatibility.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@MisakaTAT
MisakaTAT merged commit d7a43de into MisakaTAT:main Sep 8, 2025
@TinyTsuki
TinyTsuki deleted the dev branch May 19, 2026 03:24
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.

2 participants