mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-09 09:53:47 +00:00
fixes in send action dsl
This commit is contained in:
parent
a56ad7d671
commit
c72f8e04ec
@ -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()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user