From f5112aaac5ea34f4aae6984f5d5508d6847ad7cc Mon Sep 17 00:00:00 2001 From: ryoii Date: Fri, 24 Apr 2020 21:16:54 +0800 Subject: [PATCH] Fix: delete notify sent from tx server --- .../packet/chat/receive/MessageSvc.kt | 46 +++++++++++++------ 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt index acb9defcf..f9eb059cc 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt @@ -50,6 +50,7 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.* import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.GroupInfoImpl import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.NewContact import net.mamoe.mirai.qqandroid.network.protocol.packet.list.FriendList +import net.mamoe.mirai.qqandroid.utils._miraiContentToString import net.mamoe.mirai.qqandroid.utils.io.serialization.readProtoBuf import net.mamoe.mirai.qqandroid.utils.io.serialization.readUniPacket import net.mamoe.mirai.qqandroid.utils.io.serialization.toByteArray @@ -206,8 +207,17 @@ internal class MessageSvc { .filterNot { it.msg == null } .flatMapConcat { it.msg!!.asFlow() } .mapNotNull { msg -> + + println(msg._miraiContentToString()) + when (msg.msgHead.msgType) { 33 -> { // 邀请入群 + + // 删除消息 + bot.network.run { + NewContact.Del(bot.client, msg.msgHead).sendWithoutExpect() + } + val group = bot.getGroupByUinOrNull(msg.msgHead.fromUin) if (msg.msgHead.authUin == bot.id) { if (group != null) { @@ -221,14 +231,33 @@ internal class MessageSvc { } else { group ?: return@mapNotNull null - if (group.members.contains(msg.msgHead.authUin)) { - return@mapNotNull null - } return@mapNotNull MemberJoinEvent.Invite(group.newMember(msg.getNewMemberInfo()) .also { group.members.delegate.addLast(it) }) } } + 34 -> { // 主动入群 + + // 删除消息 + bot.network.run { + NewContact.Del(bot.client, msg.msgHead).sendWithoutExpect() + } + + // 27 0B 60 E7 01 44 71 47 90 03 3E 03 3F A2 06 B4 B4 BD A8 D5 DF 00 30 36 42 35 35 46 45 32 45 35 36 43 45 45 44 30 38 30 35 31 41 35 42 37 36 39 35 34 45 30 46 43 43 36 36 45 44 43 46 45 43 42 39 33 41 41 44 32 32 + val group = bot.getGroupByUinOrNull(msg.msgHead.fromUin) + group ?: return@mapNotNull null + + if (group.members.contains(msg.msgHead.authUin)) { + return@mapNotNull null + } + return@mapNotNull MemberJoinEvent.Active(group.newMember(msg.getNewMemberInfo()) + .also { group.members.delegate.addLast(it) }) + } 166 -> { + // 删除消息 + bot.network.run { + NewContact.Del(bot.client, msg.msgHead).sendWithoutExpect() + } + if (msg.msgHead.fromUin == bot.id) { loop@ while (true) { val instance = bot.client.getFriendSeq() @@ -303,17 +332,6 @@ internal class MessageSvc { } return@mapNotNull null } - 34 -> { // 主动入群 - // 27 0B 60 E7 01 44 71 47 90 03 3E 03 3F A2 06 B4 B4 BD A8 D5 DF 00 30 36 42 35 35 46 45 32 45 35 36 43 45 45 44 30 38 30 35 31 41 35 42 37 36 39 35 34 45 30 46 43 43 36 36 45 44 43 46 45 43 42 39 33 41 41 44 32 32 - val group = bot.getGroupByUinOrNull(msg.msgHead.fromUin) - group ?: return@mapNotNull null - - if (group.members.contains(msg.msgHead.authUin)) { - return@mapNotNull null - } - return@mapNotNull MemberJoinEvent.Active(group.newMember(msg.getNewMemberInfo()) - .also { group.members.delegate.addLast(it) }) - } // 732: 27 0B 60 E7 0C 01 3E 03 3F A2 5E 90 60 E2 00 01 44 71 47 90 00 00 02 58 else -> { bot.network.logger.debug { "unknown PbGetMsg type ${msg.msgHead.msgType}" }