From 83f721c59a9389fdc2b9923eb41bd788c210929f Mon Sep 17 00:00:00 2001 From: Him188 Date: Thu, 23 Apr 2020 14:20:55 +0800 Subject: [PATCH] Cleanup --- .../net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt | 3 +-- .../network/protocol/packet/chat/MultiMsg.kt | 11 ++++++----- .../net.mamoe.mirai/message/data/ForwardMessage.kt | 9 ++++----- 3 files changed, 11 insertions(+), 12 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 2a011dc48..41d51d8b6 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 @@ -569,8 +569,7 @@ internal abstract class QQAndroidBotBase constructor( val data = message.calculateValidationDataForGroup( sequenceId = sequenceId, random = Random.nextInt().absoluteValue.toUInt(), - groupCode = groupCode, - botMemberNameCard = group.botAsMember.nameCardOrNick + groupCode = groupCode ) val response = diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/MultiMsg.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/MultiMsg.kt index 466a9c19e..eb704131c 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/MultiMsg.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/MultiMsg.kt @@ -42,14 +42,15 @@ internal class MessageValidationData @OptIn(MiraiInternalAPI::class) constructor } } +@Suppress("NOTHING_TO_INLINE") +internal inline fun Int.toLongUnsigned(): Long = this.toLong().and(0xFFFF_FFFF) + @OptIn(MiraiInternalAPI::class) internal fun Collection.calculateValidationDataForGroup( sequenceId: Int, - random: UInt, - groupCode: Long, - botMemberNameCard: String + random: Int, + groupCode: Long ): MessageValidationData { - val msgTransmit = MsgTransmit.PbMultiMsgTransmit( msg = this.map { chain -> MsgComm.Msg( @@ -57,7 +58,7 @@ internal fun Collection.calculateValidationDataForGroup( fromUin = chain.senderId, msgSeq = sequenceId, msgTime = chain.time, - msgUid = 0x01000000000000000L or random.toLong(), + msgUid = 0x01000000000000000L or random.toLongUnsigned(), mutiltransHead = MsgComm.MutilTransHead( status = 0, msgId = 1 diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/ForwardMessage.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/ForwardMessage.kt index 538adc5e6..e0e5e4f7a 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/ForwardMessage.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/ForwardMessage.kt @@ -547,13 +547,12 @@ class ForwardMessageBuilder private constructor( /** 构造 [ForwardMessage] */ fun build(): ForwardMessage = ForwardMessage(container.toList(), this.displayStrategy) - - @Suppress("NOTHING_TO_INLINE") - private inline fun Int.toLongUnsigned(): Long = this.toLong().and(0xFFFF_FFFF) - @OptIn(MiraiExperimentalAPI::class) internal fun Bot.smartName(): String = when (val c = this@ForwardMessageBuilder.context) { is Group -> c.botAsMember.nameCardOrNick else -> nick } -} \ No newline at end of file +} + +@Suppress("NOTHING_TO_INLINE") +internal inline fun Int.toLongUnsigned(): Long = this.toLong().and(0xFFFF_FFFF)