From 109d2ee6cf99e85e32c37b11a86b4db0a502d970 Mon Sep 17 00:00:00 2001 From: cssxsh Date: Sun, 1 May 2022 17:51:39 +0800 Subject: [PATCH] fix: empty contacts task --- .../io/github/gnuf0rce/mirai/plugin/GitHubSubscriber.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/io/github/gnuf0rce/mirai/plugin/GitHubSubscriber.kt b/src/main/kotlin/io/github/gnuf0rce/mirai/plugin/GitHubSubscriber.kt index fd49d46..1a305ac 100644 --- a/src/main/kotlin/io/github/gnuf0rce/mirai/plugin/GitHubSubscriber.kt +++ b/src/main/kotlin/io/github/gnuf0rce/mirai/plugin/GitHubSubscriber.kt @@ -102,7 +102,11 @@ abstract class GitHubSubscriber(private val name: String, parent: CoroutineSc } } - private fun task(id: String) = synchronized(jobs) { tasks[id] }?.takeIf { it.contacts.isNotEmpty() } + private fun task(id: String): GitHubTask? = synchronized(jobs) { + tasks.compute(id) { _, old -> + old?.takeIf { it.contacts.isNotEmpty() } + } + } private fun launch(id: String) = launch(SupervisorJob()) { logger.info { "$name with $id run start" }