mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-23 00:57:13 +00:00
commit
a501b7bba9
@ -22,6 +22,11 @@ must be regular text
|
||||
* Add `ResendableContent#createResends` which create adapted list of resends for content
|
||||
* Add `TextContent` own `createResends` realisation
|
||||
|
||||
### 0.9.2
|
||||
|
||||
* `RequestsExecutor#executeAsync(Request, CoroutineScope)` now will return `Deferred` for cases when you need result
|
||||
* `RequestsExecutor#executeUnsafe` will automatically retry request if it was unsuccessful and retries > 0
|
||||
|
||||
### 0.8.5
|
||||
|
||||
* Add extension `String#toMarkdown`
|
||||
|
@ -1,4 +1,4 @@
|
||||
project.version = "0.9.1"
|
||||
project.version = "0.9.2"
|
||||
project.group = "com.github.insanusmokrassar"
|
||||
|
||||
buildscript {
|
||||
|
@ -164,16 +164,23 @@ fun <T: Any> RequestsExecutor.executeAsync(
|
||||
fun <T: Any> RequestsExecutor.executeAsync(
|
||||
request: Request<T>,
|
||||
scope: CoroutineScope = GlobalScope
|
||||
): Job {
|
||||
): Deferred<T> {
|
||||
return scope.async { execute(request) }
|
||||
}
|
||||
|
||||
suspend fun <T: Any> RequestsExecutor.executeUnsafe(
|
||||
request: Request<T>
|
||||
request: Request<T>,
|
||||
retries: Int = 0,
|
||||
retriesDelay: Long = 1000L
|
||||
): T? {
|
||||
return try {
|
||||
execute(request)
|
||||
} catch (e: RequestException) {
|
||||
null
|
||||
if (retries > 0) {
|
||||
delay(retriesDelay)
|
||||
executeUnsafe(request, retries - 1, retriesDelay)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user