From 35454820343ab45bd1751d2a021b50ae62ebc416 Mon Sep 17 00:00:00 2001 From: Him188 Date: Wed, 22 Apr 2020 18:39:10 +0800 Subject: [PATCH] Fix #253 --- .../mamoe/mirai/qqandroid/QQAndroidBot.common.kt | 1 + .../protocol/packet/chat/receive/OnlinePush.kt | 8 +++++++- .../net.mamoe.mirai/event/events/BotEvents.kt | 16 ++++++++++++++-- .../message/data/MessageSource.kt | 1 + 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt index b1127dd1e..623cd1097 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt @@ -313,6 +313,7 @@ internal abstract class QQAndroidBotBase constructor( this, source.fromId, source.id, + source.internalId, source.time, null, group diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt index f2265008b..97ffb438f 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt @@ -381,7 +381,13 @@ internal class OnlinePush { when { pkg.authorUin == bot.id && operator.id == bot.id -> null else -> { - MessageRecallEvent.GroupRecall(bot, pkg.authorUin, pkg.msgRandom, pkg.time, operator, group) + MessageRecallEvent.GroupRecall(bot, + pkg.authorUin, + pkg.seq, + pkg.msgRandom, + pkg.time, + operator, + group) } } } diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt index 1a2ae792f..e12906230 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt @@ -122,17 +122,25 @@ sealed class MessageRecallEvent : BotEvent { */ abstract val messageId: Int + /** + * 消息内部 id. + * @see MessageSource.id + */ + @SinceMirai("0.39.0") + abstract val messageInternalId: Int + /** * 原发送时间 */ abstract val messageTime: Int // seconds /** - * 好友消息撤回事件, 暂不支持解析. - */ + * 好友消息撤回事件, 暂不支持. + */ // TODO: 2020/4/22 支持好友消息撤回事件的解析和主动广播 data class FriendRecall( override val bot: Bot, override val messageId: Int, + override val messageInternalId: Int, override val messageTime: Int, /** * 撤回操作人, 可能为 [Bot.uin] 或好友的 [QQ.id] @@ -143,10 +151,14 @@ sealed class MessageRecallEvent : BotEvent { get() = bot.id } + /** + * 群消息撤回事件. + */ data class GroupRecall( override val bot: Bot, override val authorId: Long, override val messageId: Int, + override val messageInternalId: Int, override val messageTime: Int, /** * 操作人. 为 null 时则为 [Bot] 操作. diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/MessageSource.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/MessageSource.kt index e0f33371c..132669760 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/MessageSource.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/MessageSource.kt @@ -63,6 +63,7 @@ sealed class MessageSource : Message, MessageMetadata, ConstrainSingle