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 {
|
contract {
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
val actionScope = currentCoroutineContext().LinkedSupervisorScope(Job())
|
val actionScope = currentCoroutineContext().LinkedSupervisorScope()
|
||||||
actionScope.launch {
|
actionScope.launch {
|
||||||
while (isActive) {
|
while (isActive) {
|
||||||
safelyWithoutExceptions {
|
runCatching {
|
||||||
execute(actionRequest)
|
execute(actionRequest)
|
||||||
}
|
}
|
||||||
delay(refreshTime)
|
delay(refreshTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val result = runCatchingSafely { block() }
|
val result = runCatchingSafely { block() }
|
||||||
actionScope.cancel()
|
actionScope.coroutineContext.job.cancel()
|
||||||
return result.getOrThrow()
|
return result.getOrThrow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user