From 87a6cab33e2f993f506da91d4ac5a2c9e91c6dbe Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 28 Mar 2021 15:18:11 +0600 Subject: [PATCH] fixes in simple captcha provider --- .../plugins/captcha/provider/CaptchaProvider.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/dev/inmo/plagubot/plugins/captcha/provider/CaptchaProvider.kt b/src/main/kotlin/dev/inmo/plagubot/plugins/captcha/provider/CaptchaProvider.kt index 8220566..250c27a 100644 --- a/src/main/kotlin/dev/inmo/plagubot/plugins/captcha/provider/CaptchaProvider.kt +++ b/src/main/kotlin/dev/inmo/plagubot/plugins/captcha/provider/CaptchaProvider.kt @@ -146,7 +146,7 @@ data class SimpleCaptchaProvider( newUsers.mapNotNull { safelyWithoutExceptions { launch { - doInSubContext { + doInSubContext(stopOnCompletion = false) { val callbackData = uuid4().toString() val sentMessage = sendTextMessage( chat, @@ -179,11 +179,14 @@ data class SimpleCaptchaProvider( stop() } - delay((userBanDateTime - eventDateTime).millisecondsLong) + launch { + delay((userBanDateTime - eventDateTime).millisecondsLong) - job.cancel() - if (kick) { - safelyWithoutExceptions { kickChatMember(chat, it) } + job.cancel() + if (kick) { + safelyWithoutExceptions { kickChatMember(chat, it) } + } + stop() } } }