This commit is contained in:
Him188 2020-04-23 14:20:55 +08:00
parent 1b4e1475a0
commit 83f721c59a
3 changed files with 11 additions and 12 deletions

View File

@ -569,8 +569,7 @@ internal abstract class QQAndroidBotBase constructor(
val data = message.calculateValidationDataForGroup( val data = message.calculateValidationDataForGroup(
sequenceId = sequenceId, sequenceId = sequenceId,
random = Random.nextInt().absoluteValue.toUInt(), random = Random.nextInt().absoluteValue.toUInt(),
groupCode = groupCode, groupCode = groupCode
botMemberNameCard = group.botAsMember.nameCardOrNick
) )
val response = val response =

View File

@ -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) @OptIn(MiraiInternalAPI::class)
internal fun Collection<ForwardMessage.INode>.calculateValidationDataForGroup( internal fun Collection<ForwardMessage.INode>.calculateValidationDataForGroup(
sequenceId: Int, sequenceId: Int,
random: UInt, random: Int,
groupCode: Long, groupCode: Long
botMemberNameCard: String
): MessageValidationData { ): MessageValidationData {
val msgTransmit = MsgTransmit.PbMultiMsgTransmit( val msgTransmit = MsgTransmit.PbMultiMsgTransmit(
msg = this.map { chain -> msg = this.map { chain ->
MsgComm.Msg( MsgComm.Msg(
@ -57,7 +58,7 @@ internal fun Collection<ForwardMessage.INode>.calculateValidationDataForGroup(
fromUin = chain.senderId, fromUin = chain.senderId,
msgSeq = sequenceId, msgSeq = sequenceId,
msgTime = chain.time, msgTime = chain.time,
msgUid = 0x01000000000000000L or random.toLong(), msgUid = 0x01000000000000000L or random.toLongUnsigned(),
mutiltransHead = MsgComm.MutilTransHead( mutiltransHead = MsgComm.MutilTransHead(
status = 0, status = 0,
msgId = 1 msgId = 1

View File

@ -547,13 +547,12 @@ class ForwardMessageBuilder private constructor(
/** 构造 [ForwardMessage] */ /** 构造 [ForwardMessage] */
fun build(): ForwardMessage = ForwardMessage(container.toList(), this.displayStrategy) 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) @OptIn(MiraiExperimentalAPI::class)
internal fun Bot.smartName(): String = when (val c = this@ForwardMessageBuilder.context) { internal fun Bot.smartName(): String = when (val c = this@ForwardMessageBuilder.context) {
is Group -> c.botAsMember.nameCardOrNick is Group -> c.botAsMember.nameCardOrNick
else -> nick else -> nick
} }
} }
@Suppress("NOTHING_TO_INLINE")
internal inline fun Int.toLongUnsigned(): Long = this.toLong().and(0xFFFF_FFFF)