From a74e895c41ad2ed21906daf408e5d784c3f186e7 Mon Sep 17 00:00:00 2001 From: ryoii Date: Wed, 8 Jul 2020 13:11:32 +0800 Subject: [PATCH] Fix #404, #410: Bot join group from other client --- .../packet/chat/receive/MessageSvc.PbGetMsg.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PbGetMsg.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PbGetMsg.kt index 33baf8fdd..6bf941e3e 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PbGetMsg.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PbGetMsg.kt @@ -44,6 +44,7 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.buildOutgoingUniPacket 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.toByteArray import net.mamoe.mirai.qqandroid.utils.io.serialization.writeProtoBuf @@ -190,6 +191,20 @@ internal object MessageSvcPbGetMsg : OutgoingPacketFactory { // 与 33 重复 return@mapNotNull null } + + 85 -> bot.groupListModifyLock.withLock { // 其他客户端入群 + val group = bot.getGroupByUinOrNull(msg.msgHead.fromUin) + if (msg.msgHead.toUin == bot.id && group == null) { + + val newGroup = bot.getNewGroup(Group.calculateGroupCodeByGroupUin(msg.msgHead.fromUin)) + ?: return@mapNotNull null + bot.groups.delegate.addLast(newGroup) + return@mapNotNull BotJoinGroupEvent.Active(newGroup) + } else { + // unknown + return@mapNotNull null + } + } /* 34 -> { // 主动入群