Commit d51678fa authored by Him188's avatar Him188

Misc improvements

parent 474e5481
......@@ -12,8 +12,7 @@
package net.mamoe.mirai.qqandroid
import io.ktor.client.request.*
import io.ktor.client.request.forms.MultiPartFormDataContent
import io.ktor.client.request.forms.formData
import io.ktor.client.request.forms.*
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.async
import kotlinx.coroutines.sync.Mutex
......@@ -56,7 +55,6 @@ import kotlin.coroutines.CoroutineContext
import kotlin.jvm.JvmField
import kotlin.jvm.JvmSynthetic
import kotlin.math.absoluteValue
import kotlin.math.log
import kotlin.random.Random
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.FriendInfo as JceFriendInfo
......@@ -793,8 +791,7 @@ internal abstract class QQAndroidBotBase constructor(
}
}
@ExperimentalStdlibApi
@MiraiExperimentalAPI
@OptIn(ExperimentalStdlibApi::class)
@LowLevelAPI
override suspend fun _lowLevelQueryGroupVoiceDownloadUrl(
md5: ByteArray,
......
......@@ -230,14 +230,13 @@ internal fun MsgComm.Msg.toMessageChain(
isTemp: Boolean = false
): MessageChain {
val elements = this.msgBody.richText.elems
val ptt = this.msgBody.richText.ptt
val pptMsg = ptt?.run {
val pptMsg = msgBody.richText.ptt?.run {
// when (fileType) {
// 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(), String(downPara))
}
return buildMessageChain(elements.size + 1 + if (pptMsg == null) 0 else 1) {
......
......@@ -9,13 +9,9 @@ import net.mamoe.mirai.qqandroid.network.protocol.data.proto.Cmd0x388
import net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket
import net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacketFactory
import net.mamoe.mirai.qqandroid.network.protocol.packet.buildOutgoingUniPacket
import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.image.ImgStore
import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.image.getRandomString
import net.mamoe.mirai.qqandroid.utils._miraiContentToString
import net.mamoe.mirai.qqandroid.utils.encodeToString
import net.mamoe.mirai.qqandroid.utils.io.serialization.readProtoBuf
import net.mamoe.mirai.qqandroid.utils.io.serialization.writeProtoBuf
import net.mamoe.mirai.qqandroid.utils.toUHexString
internal class PttStore {
object GroupPttUp : OutgoingPacketFactory<GroupPttUp.Response>("PttStore.GroupPttUp") {
......@@ -35,15 +31,14 @@ internal class PttStore {
}
}
@ExperimentalStdlibApi
@OptIn(ExperimentalStdlibApi::class)
operator fun invoke(
client: QQAndroidClient,
uin: Long,
groupCode: Long,
md5: ByteArray,
size: Long,
voiceLength: Int,
size: Long = 0,
voiceLength: Int = 0,
fileId: Long = 0
): OutgoingPacket {
val pack = Cmd0x388.ReqBody(
......@@ -96,13 +91,13 @@ internal class PttStore {
object GroupPttDown : OutgoingPacketFactory<GroupPttDown.Response>("PttStore.GroupPttDown") {
sealed class Response() : Packet {
sealed class Response : Packet {
class DownLoadInfo(
val downDomain: ByteArray,
val downPara:ByteArray,
val strDomain:String,
val uint32DownIp:List<Int>,
val uint32DownPort:List<Int>
val downPara: ByteArray,
val strDomain: String,
val uint32DownIp: List<Int>,
val uint32DownPort: List<Int>
) : GroupPttDown.Response() {
override fun toString(): String {
return "GroupPttDown(downPara=${downPara.encodeToString()},strDomain=$strDomain})"
......@@ -111,11 +106,11 @@ internal class PttStore {
}
@ExperimentalStdlibApi
@OptIn(ExperimentalStdlibApi::class)
operator fun invoke(
client: QQAndroidClient,
groupCode: Long,
dstUin:Long,
dstUin: Long,
md5: ByteArray
): OutgoingPacket = buildOutgoingUniPacket(client) {
......@@ -144,7 +139,7 @@ internal class PttStore {
val resp0 = readProtoBuf(Cmd0x388.RspBody.serializer())
resp0.msgGetpttUrlRsp ?: error("cannot find `msgGetpttUrlRsp` from `Cmd0x388.RspBody`")
val resp = resp0.msgGetpttUrlRsp.first()
if (!resp.failMsg.contentEquals(EMPTY_BYTE_ARRAY)){
if (!resp.failMsg.contentEquals(EMPTY_BYTE_ARRAY)) {
throw IllegalStateException(resp.failMsg.encodeToString())
}
return Response.DownLoadInfo(
......
package net.mamoe.mirai.message.data
import net.mamoe.mirai.utils.MiraiExperimentalAPI
import net.mamoe.mirai.utils.MiraiInternalAPI
import net.mamoe.mirai.utils.SinceMirai
/**
* 需要通过上传到服务器的消息,如语音、文件
......@@ -22,8 +24,8 @@ public abstract class PttMessage : MessageContent {
/**
* 语音消息, 目前只支持接收和转发
*/
@MiraiExperimentalAPI
public class Voice(
@SinceMirai("1.2.0")
public class Voice @MiraiInternalAPI constructor(
public override val fileName: String,
public override val md5: ByteArray,
public override val fileSize: Long,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment