Fix nameCard deserializing

This commit is contained in:
Him188 2020-04-11 22:29:54 +08:00
parent fdef3bdbdd
commit 0f91587ae7
2 changed files with 7 additions and 7 deletions

View File

@ -84,12 +84,12 @@ internal class OnlinePush {
val group = bot.getGroupOrNull(pbPushMsg.msg.msgHead.groupInfo!!.groupCode) ?: return null // 机器人还正在进群 val group = bot.getGroupOrNull(pbPushMsg.msg.msgHead.groupInfo!!.groupCode) ?: return null // 机器人还正在进群
val sender = group[pbPushMsg.msg.msgHead.fromUin] as MemberImpl val sender = group[pbPushMsg.msg.msgHead.fromUin] as MemberImpl
val name = extraInfo?.groupCard?.run { val name = extraInfo?.groupCard?.run {
try { kotlin.runCatching {
loadAs(Oidb0x8fc.CommCardNameBuf.serializer()).richCardName!!.first { it.text.isNotEmpty() } if (this[0] == 0x0A.toByte() && this[1] == 0x0A.toByte() && this[2] == 0x0A.toByte() && this[3] == 0x08.toByte())
.text.encodeToString() loadAs(Oidb0x8fc.CommCardNameBuf.serializer()).richCardName?.firstOrNull { it.text.isNotEmpty() }
} catch (e: Exception) { ?.text?.encodeToString()
encodeToString() else return@runCatching null
} }.getOrNull() ?: encodeToString()
} ?: pbPushMsg.msg.msgHead.groupInfo.groupCard // 没有 extraInfo 就从 head 里取 } ?: pbPushMsg.msg.msgHead.groupInfo.groupCard // 没有 extraInfo 就从 head 里取
val flags = extraInfo?.flags ?: 0 val flags = extraInfo?.flags ?: 0

View File

@ -10,7 +10,7 @@ internal object ByteArrayPool : DefaultPool<ByteArray>(256) {
/** /**
* 每一个 [ByteArray] 的大小 * 每一个 [ByteArray] 的大小
*/ */
const val BUFFER_SIZE: Int = 81920 / 2 const val BUFFER_SIZE: Int = 8192 * 8
override fun produceInstance(): ByteArray = ByteArray(BUFFER_SIZE) override fun produceInstance(): ByteArray = ByteArray(BUFFER_SIZE)