Skip to content

Commit

Permalink
Merge pull request #175 from simple-robot/dev/fix-174
Browse files Browse the repository at this point in the history
修复事件中接收的 MessageContent 中, `referenceMessage` 的行为与 `reference` 不一致,会错误地获取自身消息详情而非引用消息详情的问题
  • Loading branch information
ForteScarlet authored Aug 29, 2024
2 parents ffc382f + 517e442 commit e61ca36
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,10 @@ public class KookReceiveMessageContent internal constructor(
}
}

override suspend fun referenceMessage(): KookMessageContent {
override suspend fun referenceMessage(): KookMessageContent? {
return if (isDirect) {
val details = detailsFromDirect(bot, source.msgId, source.authorId)
val ref = referenceFromDirect(bot, source.msgId, source.authorId) ?: return null
val details = detailsFromDirect(bot, ref.quote.id, source.authorId)
KookUpdatedMessageContent(
bot = bot,
isDirect = false,
Expand All @@ -277,7 +278,8 @@ public class KookReceiveMessageContent internal constructor(
isMentionHere = false
)
} else {
val details = detailsFromChannel(bot, source.msgId)
val ref = referenceFromChannel(bot, source.msgId) ?: return null
val details = detailsFromChannel(bot, ref.quote.id)
details.toContent(bot)
}
}
Expand Down Expand Up @@ -344,9 +346,11 @@ public class KookUpdatedMessageContent internal constructor(
}

@JvmSynthetic
override suspend fun referenceMessage(): KookMessageContent {
override suspend fun referenceMessage(): KookMessageContent? {
return if (isDirect) {
val details = detailsFromDirectWithChatCode(bot, msgId, chatCode!!)
val chatCode = chatCode!!
val ref = referenceFromDirectWithChatCode(bot, msgId, chatCode) ?: return null
val details = detailsFromDirectWithChatCode(bot, ref.quote.id, chatCode)
KookUpdatedMessageContent(
bot = bot,
isDirect = false,
Expand All @@ -359,7 +363,8 @@ public class KookUpdatedMessageContent internal constructor(
isMentionHere = false
)
} else {
val details = detailsFromChannel(bot, msgId)
val ref = referenceFromChannel(bot, msgId) ?: return null
val details = detailsFromChannel(bot, ref.quote.id)
details.toContent(bot)
}
}
Expand Down

0 comments on commit e61ca36

Please sign in to comment.