This commit is contained in:
sandtechnology 2020-12-19 01:45:19 +08:00
parent 176ae71e7a
commit ea113dd246
4 changed files with 12 additions and 3 deletions

View File

@ -39,6 +39,7 @@ public class Voice @MiraiInternalApi constructor(
public override val fileName: String,
public override val md5: ByteArray,
public override val fileSize: Long,
public val codec: Int = 0,
private val _url: String
) : PttMessage() {

View File

@ -453,7 +453,7 @@ internal class GroupImpl(
response.fileKey,
codec
)
Voice("${md5.toUHexString("")}.amr", md5, content.size.toLong(), "")
Voice("${md5.toUHexString("")}.amr", md5, content.size.toLong(), codec, "")
}
}

View File

@ -248,7 +248,7 @@ internal fun MsgComm.Msg.toMessageChain(
// 4 -> Voice(String(fileName), fileMd5, fileSize.toLong(),String(downPara))
// else -> null
// }
Voice(String(fileName), fileMd5, fileSize.toLong(), String(downPara))
Voice(String(fileName), fileMd5, fileSize.toLong(), format, String(downPara))
}
return buildMessageChain(elements.size + 1 + if (pptMsg == null) 0 else 1) {

View File

@ -35,6 +35,7 @@ import net.mamoe.mirai.internal.utils.io.serialization.readProtoBuf
import net.mamoe.mirai.internal.utils.io.serialization.writeProtoBuf
import net.mamoe.mirai.message.data.MessageChain
import net.mamoe.mirai.message.data.PttMessage
import net.mamoe.mirai.message.data.Voice
import net.mamoe.mirai.utils.currentTimeSeconds
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract
@ -145,7 +146,14 @@ internal object MessageSvcPbSendMsg : OutgoingPacketFactory<MessageSvcPbSendMsg.
boolValid = true,
fileSize = fileSize.toInt(),
fileType = 4,
pbReserve = byteArrayOf(0)
pbReserve = byteArrayOf(0),
format = let {
if (it is Voice) {
it.codec
} else {
0
}
}
)
}
)