Shamrock: fix #124

This commit is contained in:
Simplxs 2023-12-04 15:07:33 +08:00
parent 4e3870a512
commit ec39aa7bc3
No known key found for this signature in database
GPG Key ID: E23537FF14DD6507

View File

@ -63,28 +63,32 @@ internal object PrimitiveListener {
subType = pb[1, 2, 2].asInt subType = pb[1, 2, 2].asInt
} }
val msgTime = pb[1, 2, 6].asLong val msgTime = pb[1, 2, 6].asLong
when (msgType) { try {
33 -> onGroupMemIncreased(msgTime, pb) when (msgType) {
34 -> onGroupMemberDecreased(msgTime, pb) 33 -> onGroupMemIncreased(msgTime, pb)
44 -> onGroupAdminChange(msgTime, pb) 34 -> onGroupMemberDecreased(msgTime, pb)
84 -> onGroupApply(msgTime, pb) 44 -> onGroupAdminChange(msgTime, pb)
87 -> onInviteGroup(msgTime, pb) 84 -> onGroupApply(msgTime, pb)
528 -> when (subType) { 87 -> onInviteGroup(msgTime, pb)
35 -> onFriendApply(msgTime, pb) 528 -> when (subType) {
39 -> onCardChange(msgTime, pb) 35 -> onFriendApply(msgTime, pb)
// invite 39 -> onCardChange(msgTime, pb)
68 -> onGroupApply(msgTime, pb) // invite
138 -> onC2CRecall(msgTime, pb) 68 -> onGroupApply(msgTime, pb)
290 -> onC2cPoke(msgTime, pb) 138 -> onC2CRecall(msgTime, pb)
} 290 -> onC2cPoke(msgTime, pb)
}
732 -> when (subType) { 732 -> when (subType) {
12 -> onGroupBan(msgTime, pb) 12 -> onGroupBan(msgTime, pb)
16 -> onGroupTitleChange(msgTime, pb) 16 -> onGroupTitleChange(msgTime, pb)
17 -> onGroupRecall(msgTime, pb) 17 -> onGroupRecall(msgTime, pb)
20 -> onGroupPokeAndGroupSign(msgTime, pb) 20 -> onGroupPokeAndGroupSign(msgTime, pb)
21 -> onEssenceMessage(msgTime, pb) 21 -> onEssenceMessage(msgTime, pb)
}
} }
} catch (e: Exception) {
LogCenter.log("onMsgPush(msgType: $msgType): "+e.stackTraceToString(), Level.WARN)
} }
} }
@ -153,8 +157,21 @@ internal object PrimitiveListener {
private suspend fun onCardChange(msgTime: Long, pb: ProtoMap) { private suspend fun onCardChange(msgTime: Long, pb: ProtoMap) {
val targetId = pb[1, 3, 2, 1, 13, 2].asUtf8String var detail = pb[1, 3, 2]
val newCardList = pb[1, 3, 2, 1, 13, 3].asList if (detail !is ProtoMap) {
try {
val readPacket = ByteReadPacket(detail.asByteArray)
readPacket.readBuf32Long()
readPacket.discardExact(1)
detail = ProtoUtils.decodeFromByteArray(readPacket.readBytes(readPacket.readShort().toInt()))
readPacket.release()
} catch (e: Exception) {
LogCenter.log("onCardChange error: ${e.stackTraceToString()}", Level.WARN)
}
}
val targetId = detail[1, 13, 2].asUtf8String
val newCardList = detail[1, 13, 3].asList
var newCard = "" var newCard = ""
newCardList newCardList
.value .value
@ -163,7 +180,7 @@ internal object PrimitiveListener {
newCard = it[2].asUtf8String newCard = it[2].asUtf8String
} }
} }
val groupId = pb[1, 3, 2, 1, 13, 4].asLong val groupId = pb[1, 13, 4].asLong
var oldCard = "" var oldCard = ""
val targetQQ = ContactHelper.getUinByUidAsync(targetId).toLong() val targetQQ = ContactHelper.getUinByUidAsync(targetId).toLong()
LogCenter.log("群组[$groupId]成员$targetQQ 群名片变动 -> $newCard") LogCenter.log("群组[$groupId]成员$targetQQ 群名片变动 -> $newCard")
@ -181,14 +198,18 @@ internal object PrimitiveListener {
} }
private suspend fun onGroupTitleChange(msgTime: Long, pb: ProtoMap) { private suspend fun onGroupTitleChange(msgTime: Long, pb: ProtoMap) {
val groupCode = pb[1, 1, 1].asULong var detail = pb[1, 3, 2]
if (detail !is ProtoMap) {
val readPacket = ByteReadPacket(pb[1, 3, 2].asByteArray) try {
val detail = if (readPacket.readBuf32Long() == groupCode) { val readPacket = ByteReadPacket(detail.asByteArray)
readPacket.discardExact(1) readPacket.readBuf32Long()
ProtoUtils.decodeFromByteArray(readPacket.readBytes(readPacket.readShort().toInt())) readPacket.discardExact(1)
} else pb[1, 3, 2] detail = ProtoUtils.decodeFromByteArray(readPacket.readBytes(readPacket.readShort().toInt()))
readPacket.release() readPacket.release()
} catch (e: Exception) {
LogCenter.log("onGroupTitleChange error: ${e.stackTraceToString()}", Level.WARN)
}
}
val targetUin = detail[5, 5].asLong val targetUin = detail[5, 5].asLong
@ -213,14 +234,18 @@ internal object PrimitiveListener {
} }
private suspend fun onEssenceMessage(msgTime: Long, pb: ProtoMap) { private suspend fun onEssenceMessage(msgTime: Long, pb: ProtoMap) {
val groupCode = pb[1, 1, 1].asULong var detail = pb[1, 3, 2]
if (detail !is ProtoMap) {
val readPacket = ByteReadPacket(pb[1, 3, 2].asByteArray) try {
val detail = if (readPacket.readBuf32Long() == groupCode) { val readPacket = ByteReadPacket(detail.asByteArray)
readPacket.discardExact(1) readPacket.readBuf32Long()
ProtoUtils.decodeFromByteArray(readPacket.readBytes(readPacket.readShort().toInt())) readPacket.discardExact(1)
} else pb[1, 3, 2] detail = ProtoUtils.decodeFromByteArray(readPacket.readBytes(readPacket.readShort().toInt()))
readPacket.release() readPacket.release()
} catch (e: Exception) {
LogCenter.log("onEssenceMessage error: ${e.stackTraceToString()}", Level.WARN)
}
}
val groupId = detail[4].asLong val groupId = detail[4].asLong
val mesSeq = detail[37].asInt val mesSeq = detail[37].asInt