1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-09-03 15:19:30 +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

@@ -30671,6 +30671,10 @@ public final class dev/inmo/tgbotapi/utils/ExtractDataAndJsonFromDecoderKt {
public static final fun decodeDataAndJson (Lkotlinx/serialization/encoding/Decoder;Lkotlinx/serialization/DeserializationStrategy;)Lkotlin/Pair;
}
public final class dev/inmo/tgbotapi/utils/FirstOfKt {
public static final fun firstOf (Lkotlinx/coroutines/CoroutineScope;[Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/utils/IntProgress100Serializer : kotlinx/serialization/KSerializer {
public static final field INSTANCE Ldev/inmo/tgbotapi/utils/IntProgress100Serializer;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;

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