Shamrock: fix comm_elem parser

This commit is contained in:
白池 2024-02-18 20:08:57 +08:00
parent 50d7dfa06d
commit 4283651b1e
3 changed files with 16 additions and 13 deletions

View File

@ -8,5 +8,5 @@ import protobuf.message.element.*
data class MessageElement(
@ProtoNumber(1) val text: TextElement? = null,
@ProtoNumber(51) val json: JsonElement? = null,
@ProtoNumber(53) val richMedia: RichMediaElement? = null,
@ProtoNumber(53) val commElem: CommonElement? = null,
)

View File

@ -4,7 +4,7 @@ import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber
@Serializable
data class RichMediaElement(
data class CommonElement(
@ProtoNumber(1) val type: Int? = null,
@ProtoNumber(2) val data: ByteArray? = null,
@ProtoNumber(3) val u1: Int? = null,

View File

@ -109,19 +109,22 @@ internal object PrimitiveListener {
}
private fun onGroupMessage(msgTime: Long, body: MessageBody) {
body.rich?.elements?.filter {
it.richMedia != null
}?.map {
ProtoBuf.decodeFromByteArray<RichMediaForPicData>(it.richMedia!!.data!!)
}?.forEach {
it.display?.show?.download?.url?.let {
RKEY_PATTERN.matcher(it).takeIf {
it.find()
}?.group(1)?.let { rkey ->
LogCenter.log("更新NT RKEY成功$rkey")
RichProtoSvc.multiMediaRKey = rkey
runCatching {
body.rich?.elements?.filter {
it.commElem != null && it.commElem!!.type == 48
}?.map {
ProtoBuf.decodeFromByteArray<RichMediaForPicData>(it.commElem!!.data!!)
}?.forEach {
it.display?.show?.download?.url?.let {
RKEY_PATTERN.matcher(it).takeIf {
it.find()
}?.group(1)?.let { rkey ->
LogCenter.log("更新NT RKEY成功$rkey")
RichProtoSvc.multiMediaRKey = rkey
}
}
}
}
}