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