1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-11-15 19:40:19 +00:00

add firstOf

This commit is contained in:
2025-08-11 00:45:35 +06:00
parent b13f24153f
commit facecf35fb
3 changed files with 19 additions and 0 deletions

View File

@@ -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
}

View File

@@ -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()
}
}
}