@@ -18,23 +18,49 @@ object PreventRetractingMessageCore {
1818
1919 fun handleInfoSyncPush (buffer : ByteArray , param : XC_MethodHook .MethodHookParam ) {
2020 val infoSyncPush = InfoSyncPushOuterClass .InfoSyncPush .parseFrom(buffer)
21- infoSyncPush.syncRecallContent.syncInfoBodyList.forEach { syncInfoBody ->
22- syncInfoBody.msgList.forEach { qqMessage ->
23- val msgType = qqMessage.messageContentInfo.msgType
24- val msgSubType = qqMessage.messageContentInfo.msgSubType
25- if ((msgType == 732 && msgSubType == 17 ) || (msgType == 528 && msgSubType == 138 )) {
26- val newInfoSyncPush = infoSyncPush.toBuilder().apply {
27- syncRecallContent = syncRecallContent.toBuilder().apply {
28- for (i in 0 until syncInfoBodyCount) {
29- setSyncInfoBody(
30- i, getSyncInfoBody(i).toBuilder().clearMsg().build()
31- )
32- }
33- }.build()
34- }.build()
35- param.args[1 ] = newInfoSyncPush.toByteArray()
21+ val recallMsgSeqList = mutableListOf<Pair <String , Int >>()
22+ // 新代码 构建新的InfoSyncPush
23+ val newInfoSyncPush = infoSyncPush.toBuilder().apply {
24+ syncRecallContent = syncRecallContent.toBuilder().apply {
25+ syncInfoBodyList.forEachIndexed { index, syncInfoBody ->
26+ val newMsgList = syncInfoBody.msgList.filter { qqMessage ->
27+ val msgType = qqMessage.messageContentInfo.msgType
28+ val msgSubType = qqMessage.messageContentInfo.msgSubType
29+ val isRecall =
30+ (msgType == 732 && msgSubType == 17 ) || (msgType == 528 && msgSubType == 138 )
31+ // 是私聊消息
32+ if (msgType == 528 && msgSubType == 138 ) {
33+ val opInfo = qqMessage.messageBody.operationInfo
34+ val c2cRecall = C2CRecallOperationInfo
35+ .parseFrom(opInfo)
36+ val msgSeq = c2cRecall.info.msgSeq
37+ val senderUid = qqMessage.messageHead.senderUid
38+ recallMsgSeqList.add(senderUid to msgSeq)
39+ } else if (msgType == 732 && msgSubType == 17 ) {
40+ // 群聊消息
41+ val opInfo = qqMessage.messageBody.operationInfo
42+ val groupRecall =
43+ QQMessageOuterClass .QQMessage .MessageBody .GroupRecallOperationInfo
44+ .parseFrom(opInfo)
45+ // groupUin
46+ val groupPeerId = groupRecall.peerId.toString()
47+ // msg seq
48+ val recallMsgSeq = groupRecall.info.msgInfo.msgSeq
49+ recallMsgSeqList.add(groupPeerId to recallMsgSeq)
50+ }
51+ ! isRecall
52+ }
53+ setSyncInfoBody(
54+ index,
55+ syncInfoBody.toBuilder().clearMsg().addAllMsg(newMsgList).build()
56+ )
3657 }
37- }
58+ }.build()
59+ }.build()
60+ param.args[1 ] = newInfoSyncPush.toByteArray()
61+ val retracting = HookItemFactory .getItem(PreventRetractingMessage ::class .java)
62+ recallMsgSeqList.forEach { (peerId, msgSeq) ->
63+ retracting.writeAndRefresh(peerId, msgSeq)
3864 }
3965 }
4066
@@ -134,4 +160,4 @@ object PreventRetractingMessageCore {
134160
135161 }
136162
137- }
163+ }
0 commit comments