From c72f8e04ec43bf0813e4c3825ab81111793795a8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 15 Aug 2024 00:58:12 +0600 Subject: [PATCH] fixes in send action dsl --- .../dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt index 03550f4398..793a221fc0 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt @@ -24,17 +24,17 @@ public suspend fun TelegramBot.withAction( contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } - val actionScope = currentCoroutineContext().LinkedSupervisorScope(Job()) + val actionScope = currentCoroutineContext().LinkedSupervisorScope() actionScope.launch { while (isActive) { - safelyWithoutExceptions { + runCatching { execute(actionRequest) } delay(refreshTime) } } val result = runCatchingSafely { block() } - actionScope.cancel() + actionScope.coroutineContext.job.cancel() return result.getOrThrow() }