Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ public class MessageReactionEvent(
* `true` 为添加,`false` 为移除
*/
public val operation: Boolean,
): BotEvent, AbstractEvent()
): BotEvent, AbstractEvent(){
public override fun toString()= "MessageReactionEvent(bot=$bot, group=$group, operator=$operator, messageId=$messageId, reaction='$reaction', count=$count, operation=$operation)"
}
Comment on lines +40 to +42
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.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class GroupMsgEmojiLikeNotice : NoticeEvent() {
var messageId = 0
@SerializedName("likes")
var likes = LinkedList<Like>()
@SerializedName("is_add")
var isAdd: Boolean? = null

class Like {
@SerializedName("emoji_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,12 @@ internal fun addGroupListeners() {
val group = bot.group(e.groupId)
val member = group.queryMember(e.userId) ?: return@listen
val operator = if (member.id == bot.id) null else member
// TODO: 接口中没有提及是添加还是删除,可能要开一张缓存表来记录
val isAdd = if (e.isAdd == null) {
logger.warning("请更新至新版 NapCat 或 LLOnebot")
true
} else {
e.isAdd!!
Comment on lines +433 to +437
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.
}
for (like in e.likes) {
bot.eventDispatcher.broadcastAsync(MessageReactionEvent(
bot = bot,
Expand All @@ -439,7 +444,7 @@ internal fun addGroupListeners() {
operator = operator,
reaction = like.emojiId,
count = like.count,
operation = true, // TODO
operation = isAdd
))
}
}
Expand Down