try fix tim pc

This commit is contained in:
mzdluo123 2020-07-07 11:28:39 +08:00
parent 9494472cee
commit 82faf7732c
No known key found for this signature in database
GPG Key ID: 9F7BC2C154107A1D
5 changed files with 22 additions and 13 deletions

View File

@ -33,6 +33,8 @@ private val UNSUPPORTED_MERGED_MESSAGE_PLAIN = PlainText("你的QQ暂不支持
private val UNSUPPORTED_POKE_MESSAGE_PLAIN = PlainText("[戳一戳]请使用最新版手机QQ体验新功能。")
private val UNSUPPORTED_FLASH_MESSAGE_PLAIN = PlainText("[闪照]请使用新版手机QQ查看闪照。")
@OptIn(ExperimentalStdlibApi::class)
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
internal fun MessageChain.toRichTextElems(forGroup: Boolean, withGeneralFlags: Boolean): MutableList<ImMsgBody.Elem> {
val elements = ArrayList<ImMsgBody.Elem>(this.size)
@ -156,7 +158,13 @@ internal fun MessageChain.toRichTextElems(forGroup: Boolean, withGeneralFlags: B
is VipFace -> {
transformOneMessage(PlainText(it.contentToString()))
}
is PttMessage,
is PttMessage -> {
elements.add(
ImMsgBody.Elem(
extraInfo = ImMsgBody.ExtraInfo(flags = 16,groupMask = 1)
)
)
}
is ForwardMessage,
is MessageSource, // mirai metadata only
is RichMessage // already transformed above
@ -218,8 +226,8 @@ internal fun MsgComm.Msg.toMessageChain(
val ptt = this.msgBody.richText.ptt
val pptMsg = ptt?.run {
when(fileType) {
4 -> Voice(String(fileName), fileMd5, fileSize.toLong(),fileKey,String(downPara))
when (fileType) {
4 -> Voice(String(fileName), fileMd5, fileSize.toLong(), time, String(downPara))
else -> null
}
}
@ -431,7 +439,8 @@ internal fun List<ImMsgBody.Elem>.joinToMessageChain(groupIdOrZero: Long, bot: B
.orEmpty(),
proto.pokeType,
proto.vaspokeId
))
)
)
}
3 -> {
val proto = element.commonElem.pbElem.loadAs(HummerCommelem.MsgElemInfoServtype3.serializer())

View File

@ -273,7 +273,7 @@ internal class TryUpPttReq(
internal class TryUpPttRsp(
@ProtoId(1) @JvmField val fileId: Long = 0L,
@ProtoId(2) @JvmField val result: Int = 0,
@ProtoId(3) @JvmField val failMsg: ByteArray = EMPTY_BYTE_ARRAY,
@ProtoId(3) @JvmField val failMsg: ByteArray? = null,
@ProtoId(4) @JvmField val boolFileExit: Boolean = false,
@ProtoId(5) @JvmField val uint32UpIp: List<Int>? = null,
@ProtoId(6) @JvmField val uint32UpPort: List<Int>? = null,

View File

@ -144,12 +144,8 @@ internal object MessageSvcPbSendMsg : OutgoingPacketFactory<MessageSvcPbSendMsg.
fileMd5 = md5,
boolValid = true,
fileSize = fileSize.toInt(),
groupFileKey = fileKey,
fileType = 4,
// 不知道能不能解决tim无法收听的问题
reserve = "16 36 20 38 36 65 41 31 04 37 61 39 35 37 37 61 33 62 37 30 33 66 65 33 31 20 20 20 20 20 20 35 30 55 49 30 E3 3F 8F 9F FB CA 1D 79 60 6C F4 74 F2 35 35 34 39 33 30 45 33 33 46 38 46 39 46 46 42 43 41 31 44 37 39 36 30 36 43 46 34 37 34 46 32 2E 61 6D 72 41".hexToBytes(),
pbReserve = "08 00".hexToBytes(),
time = 2
time = voiceLength
)
}
)

View File

@ -11,6 +11,7 @@ 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
@ -77,6 +78,9 @@ internal class PttStore {
val resp0 = readProtoBuf(Cmd0x388.RspBody.serializer())
resp0.msgTryupPttRsp ?: error("cannot find `msgTryupPttRsp` from `Cmd0x388.RspBody`")
val resp = resp0.msgTryupPttRsp.first()
if (resp.failMsg != null) {
throw IllegalStateException(resp.failMsg.encodeToString())
}
return Response.RequireUpload(
fileId = resp.fileid,
uKey = resp.upUkey,

View File

@ -16,7 +16,7 @@ abstract class PttMessage : MessageContent {
abstract val fileName: String
abstract val md5: ByteArray
abstract val fileSize: Long
abstract val fileKey:ByteArray
abstract val voiceLength:Int
}
@ -29,7 +29,7 @@ class Voice(
override val fileName: String,
override val md5: ByteArray,
override val fileSize: Long,
override val fileKey: ByteArray,
override val voiceLength: Int,
private val _url: String
) : PttMessage() {
@ -44,7 +44,7 @@ class Voice(
private var _stringValue: String? = null
get() = field ?: kotlin.run {
field = "[mirai:voice:$fileName]"
field = "[mirai:voice:$fileName,url:$url]"
field
}