Commit 719c4b40 authored by Him188's avatar Him188

Clear group members after Bot completion

parent b0888a27
......@@ -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 }
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment