mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-20 15:49:15 +08:00
Clear group members after Bot completion
This commit is contained in:
parent
b0888a272e
commit
719c4b402d
@ -248,12 +248,17 @@ abstract class BotImpl<N : BotNetworkHandler> constructor(
|
||||
|
||||
init {
|
||||
coroutineContext[Job]!!.invokeOnCompletion { throwable ->
|
||||
instances.removeIf { it.get()?.id == this.id }
|
||||
|
||||
network.close(throwable)
|
||||
offlineListener.cancel(CancellationException("Bot cancelled", throwable))
|
||||
|
||||
// help GC release instances
|
||||
groups.forEach {
|
||||
it.members.delegate.clear()
|
||||
}
|
||||
groups.delegate.clear() // job is cancelled, so child jobs are to be cancelled
|
||||
friends.delegate.clear()
|
||||
instances.removeIf { it.get()?.id == this.id }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user