✨ Add support for msg emoji like api (NapCat)#337
Conversation
审阅者指南此 PR 扩展了机器人 API 和事件框架,通过添加新的动作方法、事件类型、处理管道、插件钩子以及相应的 DTO/注解,以支持 NapCat 风格的消息表情符号反应。 消息表情点赞事件处理的时序图sequenceDiagram
participant Bot
participant EventHandler
participant NoticeEvent
participant InjectionHandler
participant BotPlugin
participant MessageEmojiLikeNoticeHandler
Bot->>EventHandler: Receives group_msg_emoji_like event
EventHandler->>NoticeEvent: Calls messageEmojiLikeMessage()
NoticeEvent->>InjectionHandler: invokeMessageEmojiLikeNotice()
InjectionHandler->>MessageEmojiLikeNoticeHandler: invoke()
NoticeEvent->>BotPlugin: onMessageEmojiLikeNotice()
BotPlugin-->>NoticeEvent: MESSAGE_IGNORE or MESSAGE_BLOCK
表情符号反应新 ActionParams 字段的 ER 图erDiagram
ACTION_PARAMS {
STRING EMOJI_ID
STRING SET
}
新 MessageEmojiLikeNoticeEvent DTO 的类图classDiagram
class NoticeEvent
class MessageEmojiLikeNoticeEvent {
+Long groupId
+Integer messageId
+Long operatorId
+String code
+Integer count
}
MessageEmojiLikeNoticeEvent --|> NoticeEvent
NapCatExtend 接口更新的类图classDiagram
class NapCatExtend {
+ActionRaw sendFriendPoke(long userId)
+ActionRaw sendFriendPoke(long userId, long targetId)
+ActionRaw setMsgEmojiLike(int msgId, String code, boolean isSet)
}
包含 onMessageEmojiLikeNotice 的 BotPlugin 更新类图classDiagram
class BotPlugin {
+int onGroupReactionNotice(Bot bot, GroupMessageReactionNoticeEvent event)
+int onMessageEmojiLikeNotice(Bot bot, MessageEmojiLikeNoticeEvent event)
}
新 MessageEmojiLikeNoticeHandler 注解的类图classDiagram
class MessageEmojiLikeNoticeHandler {
}
文件级变更
提示和命令与 Sourcery 交互
自定义您的体验访问您的 仪表板 以:
获取帮助Original review guide in EnglishReviewer's GuideThis PR extends the bot API and event framework to support NapCat-style message emoji reactions by adding a new action method, event type, handling pipeline, plugin hook, and corresponding DTO/annotation. Sequence diagram for message emoji like event handlingsequenceDiagram
participant Bot
participant EventHandler
participant NoticeEvent
participant InjectionHandler
participant BotPlugin
participant MessageEmojiLikeNoticeHandler
Bot->>EventHandler: Receives group_msg_emoji_like event
EventHandler->>NoticeEvent: Calls messageEmojiLikeMessage()
NoticeEvent->>InjectionHandler: invokeMessageEmojiLikeNotice()
InjectionHandler->>MessageEmojiLikeNoticeHandler: invoke()
NoticeEvent->>BotPlugin: onMessageEmojiLikeNotice()
BotPlugin-->>NoticeEvent: MESSAGE_IGNORE or MESSAGE_BLOCK
ER diagram for new ActionParams fields for emoji reactionserDiagram
ACTION_PARAMS {
STRING EMOJI_ID
STRING SET
}
Class diagram for new MessageEmojiLikeNoticeEvent DTOclassDiagram
class NoticeEvent
class MessageEmojiLikeNoticeEvent {
+Long groupId
+Integer messageId
+Long operatorId
+String code
+Integer count
}
MessageEmojiLikeNoticeEvent --|> NoticeEvent
Class diagram for NapCatExtend interface updateclassDiagram
class NapCatExtend {
+ActionRaw sendFriendPoke(long userId)
+ActionRaw sendFriendPoke(long userId, long targetId)
+ActionRaw setMsgEmojiLike(int msgId, String code, boolean isSet)
}
Class diagram for BotPlugin update with onMessageEmojiLikeNoticeclassDiagram
class BotPlugin {
+int onGroupReactionNotice(Bot bot, GroupMessageReactionNoticeEvent event)
+int onMessageEmojiLikeNotice(Bot bot, MessageEmojiLikeNoticeEvent event)
}
Class diagram for new MessageEmojiLikeNoticeHandler annotationclassDiagram
class MessageEmojiLikeNoticeHandler {
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
嗨 @TinyTsuki - 我已审阅了你的更改,它们看起来很棒!
AI 代理提示
请处理此代码审查中的评论:
## 个人评论
### 评论 1
<location> `src/main/java/com/mikuac/shiro/core/Bot.java:1578` </location>
<code_context>
+ * @return result {@link ActionRaw}
+ */
+ @Override
+ public ActionRaw setMsgEmojiLike(int msgId, String code, boolean isSet) {
+ Map<String, Object> params = new HashMap<>();
+ params.put(ActionParams.MESSAGE_ID, msgId);
</code_context>
<issue_to_address>
考虑支持 long 类型作为消息 ID 以保持一致性。
其他方法使用 long 类型作为消息 ID。如果 ID 可能超过 Integer.MAX_VALUE,将 msgId 更新为 long 类型将确保一致性并防止未来出现问题。
建议的实现:
```java
* @param msgId 消息 ID (long)
```
```java
public ActionRaw setMsgEmojiLike(long msgId, String code, boolean isSet) {
Map<String, Object> params = new HashMap<>();
params.put(ActionParams.MESSAGE_ID, msgId);
params.put(ActionParams.EMOJI_ID, code);
params.put(ActionParams.SET, isSet);
JsonObjectWrapper result = actionHandler.action(session, ActionPathEnum.SET_MSG_EMOJI_LIKE, params);
return result != null ? result.to(ActionRaw.class) : null;
}
```
如果代码库中其他地方有任何对 `setMsgEmojiLike` 的调用,它们的 `msgId` 参数类型应更新为 `long` 以保持一致性。
</issue_to_address>帮助我更有用!请点击每个评论上的 👍 或 👎,我将利用这些反馈来改进您的评论。
Original comment in English
Hey @TinyTsuki - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/main/java/com/mikuac/shiro/core/Bot.java:1578` </location>
<code_context>
+ * @return result {@link ActionRaw}
+ */
+ @Override
+ public ActionRaw setMsgEmojiLike(int msgId, String code, boolean isSet) {
+ Map<String, Object> params = new HashMap<>();
+ params.put(ActionParams.MESSAGE_ID, msgId);
</code_context>
<issue_to_address>
Consider supporting long type for message ID for consistency.
Other methods use long for message IDs. If IDs may exceed Integer.MAX_VALUE, updating msgId to long will ensure consistency and prevent future issues.
Suggested implementation:
```java
* @param msgId 消息 ID (long)
```
```java
public ActionRaw setMsgEmojiLike(long msgId, String code, boolean isSet) {
Map<String, Object> params = new HashMap<>();
params.put(ActionParams.MESSAGE_ID, msgId);
params.put(ActionParams.EMOJI_ID, code);
params.put(ActionParams.SET, isSet);
JsonObjectWrapper result = actionHandler.action(session, ActionPathEnum.SET_MSG_EMOJI_LIKE, params);
return result != null ? result.to(ActionRaw.class) : null;
}
```
If there are any calls to `setMsgEmojiLike` elsewhere in the codebase, their `msgId` argument type should be updated to `long` for consistency.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| * @return result {@link ActionRaw} | ||
| */ | ||
| @Override | ||
| public ActionRaw setMsgEmojiLike(int msgId, String code, boolean isSet) { |
There was a problem hiding this comment.
suggestion: 考虑支持 long 类型作为消息 ID 以保持一致性。
其他方法使用 long 类型作为消息 ID。如果 ID 可能超过 Integer.MAX_VALUE,将 msgId 更新为 long 类型将确保一致性并防止未来出现问题。
建议的实现:
* @param msgId 消息 ID (long) public ActionRaw setMsgEmojiLike(long msgId, String code, boolean isSet) {
Map<String, Object> params = new HashMap<>();
params.put(ActionParams.MESSAGE_ID, msgId);
params.put(ActionParams.EMOJI_ID, code);
params.put(ActionParams.SET, isSet);
JsonObjectWrapper result = actionHandler.action(session, ActionPathEnum.SET_MSG_EMOJI_LIKE, params);
return result != null ? result.to(ActionRaw.class) : null;
}如果代码库中其他地方有任何对 setMsgEmojiLike 的调用,它们的 msgId 参数类型应更新为 long 以保持一致性。
Original comment in English
suggestion: Consider supporting long type for message ID for consistency.
Other methods use long for message IDs. If IDs may exceed Integer.MAX_VALUE, updating msgId to long will ensure consistency and prevent future issues.
Suggested implementation:
* @param msgId 消息 ID (long) public ActionRaw setMsgEmojiLike(long msgId, String code, boolean isSet) {
Map<String, Object> params = new HashMap<>();
params.put(ActionParams.MESSAGE_ID, msgId);
params.put(ActionParams.EMOJI_ID, code);
params.put(ActionParams.SET, isSet);
JsonObjectWrapper result = actionHandler.action(session, ActionPathEnum.SET_MSG_EMOJI_LIKE, params);
return result != null ? result.to(ActionRaw.class) : null;
}If there are any calls to setMsgEmojiLike elsewhere in the codebase, their msgId argument type should be updated to long for consistency.
|
LGTM, Thanks! |
Sourcery 总结
通过添加
setMsgEmojiLikeAPI、连接MESSAGE_EMOJI_LIKE通知事件处理,并暴露一个插件钩子用于自定义处理,实现对消息表情符号点赞(如 NapCat)的支持。新特性:
setMsgEmojiLike动作,允许在消息上添加或移除表情符号反应MESSAGE_EMOJI_LIKE通知事件,包括其 DTO、处理程序注解、枚举条目和插件钩子onMessageEmojiLikeNoticeOriginal summary in English
Summary by Sourcery
Implement support for message emoji like (NapCat) by adding the setMsgEmojiLike API, wiring up event handling for MESSAGE_EMOJI_LIKE notices, and exposing a plugin hook for custom handling.
New Features: