mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2026-11-27 14:13:05 +00:00
fixes in send action dsl
This commit is contained in:
1 parent
a56ad7d671
commit
c72f8e04ec
1 file changed
+3
-3
+3
-3
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user