[core] Fix group audio url fetching. fix #2269

This commit is contained in:
Karlatemp 2022-10-10 00:10:25 +08:00
parent faa7ebeaba
commit 9eef7d3787
No known key found for this signature in database
GPG Key ID: BA173CA2B9956C59
2 changed files with 54 additions and 1 deletions

View File

@ -31,6 +31,7 @@ import net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody
import net.mamoe.mirai.internal.network.protocol.data.proto.MsgComm
import net.mamoe.mirai.internal.network.protocol.data.proto.MsgOnlinePush
import net.mamoe.mirai.internal.network.protocol.data.proto.Oidb0x8fc
import net.mamoe.mirai.internal.network.protocol.packet.chat.voice.PttStore
import net.mamoe.mirai.internal.utils.io.serialization.loadAs
import net.mamoe.mirai.message.data.MessageSourceKind
import net.mamoe.mirai.utils.*
@ -104,6 +105,26 @@ internal class GroupMessageProcessor(
elem.anonGroupMsg != null -> anonymous = elem.anonGroupMsg
}
}
msg.msg.msgBody.richText.ptt?.let pttPatch@{ ptt ->
if (ptt.downPara.isNotEmpty()) return@pttPatch
kotlin.runCatching {
val response = bot.network.sendAndExpect(
PttStore.GroupPttDown(
bot.client,
group.groupCode,
ptt,
msg.msg
),
5000,
2
)
ptt.downPara =
"http://${response.strDomain}${response.downPara.decodeToString()}".encodeToByteArray()
}
}
}

View File

@ -16,6 +16,8 @@ import net.mamoe.mirai.internal.network.Packet
import net.mamoe.mirai.internal.network.QQAndroidClient
import net.mamoe.mirai.internal.network.protocol.data.proto.Cmd0x346
import net.mamoe.mirai.internal.network.protocol.data.proto.Cmd0x388
import net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody
import net.mamoe.mirai.internal.network.protocol.data.proto.MsgComm
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacketFactory
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacketWithRespType
import net.mamoe.mirai.internal.network.protocol.packet.buildOutgoingUniPacket
@ -148,6 +150,36 @@ internal class PttStore {
}
operator fun invoke(
client: QQAndroidClient,
groupCode: Long,
ptt: ImMsgBody.Ptt,
msg: MsgComm.Msg,
) = buildOutgoingUniPacket(client) {
writeProtoBuf(
Cmd0x388.ReqBody.serializer(), Cmd0x388.ReqBody(
netType = 3, // wifi
subcmd = 4,
msgGetpttUrlReq = listOf(
Cmd0x388.GetPttUrlReq(
groupCode = groupCode,
fileid = 0,
fileId = ptt.fileId.toLong(),
fileMd5 = ptt.fileMd5,
dstUin = msg.msgHead.toUin,
fileKey = ptt.groupFileKey,
buType = 3,
innerIp = 0,
buildVer = "8.5.5".encodeToByteArray(),
codec = 0,
reqTerm = 5,
reqPlatformType = 9,
)
)
)
)
}
@OptIn(ExperimentalStdlibApi::class)
operator fun invoke(
client: QQAndroidClient,
@ -167,7 +199,7 @@ internal class PttStore {
dstUin = dstUin,
buType = 4,
innerIp = 0,
buildVer = "6.5.5.663".encodeToByteArray(),
buildVer = "8.5.5".encodeToByteArray(),
codec = 0,
reqTerm = 5,
reqPlatformType = 9