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( data class MessageElement(
@ProtoNumber(1) val text: TextElement? = null, @ProtoNumber(1) val text: TextElement? = null,
@ProtoNumber(51) val json: JsonElement? = 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 import kotlinx.serialization.protobuf.ProtoNumber
@Serializable @Serializable
data class RichMediaElement( data class CommonElement(
@ProtoNumber(1) val type: Int? = null, @ProtoNumber(1) val type: Int? = null,
@ProtoNumber(2) val data: ByteArray? = null, @ProtoNumber(2) val data: ByteArray? = null,
@ProtoNumber(3) val u1: Int? = null, @ProtoNumber(3) val u1: Int? = null,

View File

@ -109,10 +109,11 @@ internal object PrimitiveListener {
} }
private fun onGroupMessage(msgTime: Long, body: MessageBody) { private fun onGroupMessage(msgTime: Long, body: MessageBody) {
runCatching {
body.rich?.elements?.filter { body.rich?.elements?.filter {
it.richMedia != null it.commElem != null && it.commElem!!.type == 48
}?.map { }?.map {
ProtoBuf.decodeFromByteArray<RichMediaForPicData>(it.richMedia!!.data!!) ProtoBuf.decodeFromByteArray<RichMediaForPicData>(it.commElem!!.data!!)
}?.forEach { }?.forEach {
it.display?.show?.download?.url?.let { it.display?.show?.download?.url?.let {
RKEY_PATTERN.matcher(it).takeIf { RKEY_PATTERN.matcher(it).takeIf {
@ -123,6 +124,8 @@ internal object PrimitiveListener {
} }
} }
} }
}
} }
private suspend fun onC2CPoke(msgTime: Long, richMsg: MessageBody) { private suspend fun onC2CPoke(msgTime: Long, richMsg: MessageBody) {