mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-15 19:40:19 +00:00
add firstOf
This commit is contained in:
@@ -21,6 +21,7 @@ object DownloadFileRequestCallFactory : KtorCallFactory {
|
||||
jsonFormatter: Json,
|
||||
): T? = (request as? DownloadFile)?.let {
|
||||
resolveFile(it.filePath) ?.let {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return@makeCall it.bytes() as T // Always ByteArray
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.inmo.tgbotapi.utils
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.firstOf
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
||||
suspend fun <T> CoroutineScope.firstOf(
|
||||
vararg deferreds: suspend () -> T
|
||||
): T = firstOf {
|
||||
deferreds.forEach {
|
||||
add {
|
||||
it()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user