1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-25 03:28:44 +00:00

fixes in send action dsl

This commit is contained in:
InsanusMokrassar 2024-08-15 00:58:12 +06:00
parent a56ad7d671
commit c72f8e04ec

View File

@ -24,17 +24,17 @@ public suspend fun <T> 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()
}