diff --git a/mirai-core-api/src/commonMain/kotlin/message/data/Voice.kt b/mirai-core-api/src/commonMain/kotlin/message/data/Voice.kt index c24a600b8..7b354c85c 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/Voice.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/Voice.kt @@ -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() { diff --git a/mirai-core/src/commonMain/kotlin/contact/GroupImpl.kt b/mirai-core/src/commonMain/kotlin/contact/GroupImpl.kt index f9b2f1c30..9f052d6db 100644 --- a/mirai-core/src/commonMain/kotlin/contact/GroupImpl.kt +++ b/mirai-core/src/commonMain/kotlin/contact/GroupImpl.kt @@ -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, "") } } diff --git a/mirai-core/src/commonMain/kotlin/message/conversions.kt b/mirai-core/src/commonMain/kotlin/message/conversions.kt index 807fd4085..203166d58 100644 --- a/mirai-core/src/commonMain/kotlin/message/conversions.kt +++ b/mirai-core/src/commonMain/kotlin/message/conversions.kt @@ -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) { diff --git a/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/MessageSvc.PbSendMsg.kt b/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/MessageSvc.PbSendMsg.kt index 95a6d04c9..5ea80c590 100644 --- a/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/MessageSvc.PbSendMsg.kt +++ b/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/MessageSvc.PbSendMsg.kt @@ -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