This commit is contained in:
Him188 2020-04-15 18:29:17 +08:00
parent c6059ab9ec
commit e1004f12c9
2 changed files with 12 additions and 3 deletions

View File

@ -273,13 +273,21 @@ internal fun List<ImMsgBody.Elem>.joinToMessageChain(groupIdOrZero: Long, bot: B
}
element.lightApp != null -> {
val content = runWithBugReport("解析 lightApp", { element.lightApp.data.toUHexString() }) {
MiraiPlatformUtils.unzip(element.lightApp.data, 1).encodeToString()
when (element.lightApp.data[0].toInt()) {
0 -> element.lightApp.data.encodeToString(offset = 1)
1 -> MiraiPlatformUtils.unzip(element.lightApp.data, 1).encodeToString()
else -> error("unknown compression flag=${element.lightApp.data[0]}")
}
}
message.add(LightApp(content))
}
element.richMsg != null -> {
val content = runWithBugReport("解析 richMsg", { element.richMsg.template1.toUHexString() }) {
MiraiPlatformUtils.unzip(element.richMsg.template1, 1).encodeToString()
when (element.richMsg.template1[0].toInt()) {
0 -> element.richMsg.template1.encodeToString(offset = 1)
1 -> MiraiPlatformUtils.unzip(element.richMsg.template1, 1).encodeToString()
else -> error("unknown compression flag=${element.richMsg.template1[0]}")
}
}
when (element.richMsg.serviceId) {
// 5: 使用微博长图转换功能分享到QQ群

View File

@ -93,7 +93,8 @@ internal fun UByteArray.toUHexString(separator: String = " ", offset: Int = 0, l
}
@Suppress("NOTHING_TO_INLINE")
internal inline fun ByteArray.encodeToString(charset: Charset = Charsets.UTF_8): String = String(this, charset = charset)
internal inline fun ByteArray.encodeToString(offset: Int = 0, charset: Charset = Charsets.UTF_8): String =
String(this, charset = charset, offset = offset)
@PublishedApi
internal inline fun ByteArray.toReadPacket(offset: Int = 0, length: Int = this.size - offset) =