diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/MemberImpl.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/MemberImpl.kt index b967dba86..f6a416898 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/MemberImpl.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/MemberImpl.kt @@ -13,9 +13,7 @@ package net.mamoe.mirai.qqandroid.contact import kotlinx.atomicfu.AtomicInt import kotlinx.atomicfu.atomic -import kotlinx.coroutines.Job -import kotlinx.coroutines.SupervisorJob -import kotlinx.coroutines.launch +import kotlinx.coroutines.* import net.mamoe.mirai.LowLevelAPI import net.mamoe.mirai.contact.* import net.mamoe.mirai.data.MemberInfo @@ -210,6 +208,7 @@ internal class MemberImpl constructor( @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") group.members.delegate.removeIf { it.id == this@MemberImpl.id } + this.cancel(CancellationException("Kicked by bot")) MemberLeaveEvent.Kick(this@MemberImpl, null).broadcast() } } diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.PbPushTransMsg.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.PbPushTransMsg.kt index 1a472ec30..cdc881224 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.PbPushTransMsg.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.PbPushTransMsg.kt @@ -12,6 +12,8 @@ package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive +import kotlinx.coroutines.CancellationException +import kotlinx.coroutines.cancel import kotlinx.io.core.ByteReadPacket import kotlinx.io.core.discardExact import kotlinx.io.core.readUByte @@ -116,12 +118,14 @@ internal object OnlinePushPbPushTransMsg : 0x82 -> bot.getGroupByUinOrNull(groupUin)?.let { group -> val member = group.getOrNull(target) as? MemberImpl ?: return null return MemberLeaveEvent.Quit(member.also { + member.cancel(CancellationException("Leaved actively")) group.members.delegate.remove(member) }) } 0x83 -> bot.getGroupByUin(groupUin).let { group -> val member = group.getOrNull(target) as? MemberImpl ?: return null return MemberLeaveEvent.Kick(member.also { + member.cancel(CancellationException("Leaved actively")) group.members.delegate.remove(member) }, group.members[operator]) }