Fix #404, #410: Bot join group from other client

This commit is contained in:
ryoii 2020-07-08 13:11:32 +08:00
parent 07d9365d70
commit a74e895c41

View File

@ -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.GroupInfoImpl
import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.NewContact 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.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.readProtoBuf
import net.mamoe.mirai.qqandroid.utils.io.serialization.toByteArray import net.mamoe.mirai.qqandroid.utils.io.serialization.toByteArray
import net.mamoe.mirai.qqandroid.utils.io.serialization.writeProtoBuf import net.mamoe.mirai.qqandroid.utils.io.serialization.writeProtoBuf
@ -190,6 +191,20 @@ internal object MessageSvcPbGetMsg : OutgoingPacketFactory<MessageSvcPbGetMsg.Re
34 -> { // 与 33 重复 34 -> { // 与 33 重复
return@mapNotNull null 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 -> { // 主动入群 34 -> { // 主动入群