diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f5379f8392..d74dbce62c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,7 +13,7 @@ ktor = "2.2.4" ksp = "1.8.10-1.0.9" kotlin-poet = "1.12.0" -microutils = "0.17.5" +microutils = "0.17.6-branch_0.17.6-build419" github-release-plugin = "2.4.1" dokka = "1.8.10" diff --git a/mppProjectWithSerialization.gradle b/mppProjectWithSerialization.gradle index b5b1d0585b..3a858f7e9a 100644 --- a/mppProjectWithSerialization.gradle +++ b/mppProjectWithSerialization.gradle @@ -13,6 +13,8 @@ kotlin { browser() nodejs() } + linuxX64() + mingwX64() sourceSets { commonMain { diff --git a/tgbotapi.behaviour_builder/src/linuxX64Main/kotlin/ActualDefaultCoroutineScopeProvider.kt b/tgbotapi.behaviour_builder/src/linuxX64Main/kotlin/ActualDefaultCoroutineScopeProvider.kt new file mode 100644 index 0000000000..57f3662698 --- /dev/null +++ b/tgbotapi.behaviour_builder/src/linuxX64Main/kotlin/ActualDefaultCoroutineScopeProvider.kt @@ -0,0 +1,6 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers + +actual var defaultCoroutineScopeProvider: () -> CoroutineScope = { CoroutineScope(Dispatchers.Default) } diff --git a/tgbotapi.behaviour_builder/src/mingwX64Main/kotlin/ActualDefaultCoroutineScopeProvider.kt b/tgbotapi.behaviour_builder/src/mingwX64Main/kotlin/ActualDefaultCoroutineScopeProvider.kt new file mode 100644 index 0000000000..57f3662698 --- /dev/null +++ b/tgbotapi.behaviour_builder/src/mingwX64Main/kotlin/ActualDefaultCoroutineScopeProvider.kt @@ -0,0 +1,6 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers + +actual var defaultCoroutineScopeProvider: () -> CoroutineScope = { CoroutineScope(Dispatchers.Default) } diff --git a/tgbotapi.core/src/linuxX64Main/kotlin/requests/abstracts/ActualMPPFileAsMultipartFile.kt b/tgbotapi.core/src/linuxX64Main/kotlin/requests/abstracts/ActualMPPFileAsMultipartFile.kt new file mode 100644 index 0000000000..942cbfddf2 --- /dev/null +++ b/tgbotapi.core/src/linuxX64Main/kotlin/requests/abstracts/ActualMPPFileAsMultipartFile.kt @@ -0,0 +1,9 @@ +package dev.inmo.tgbotapi.requests.abstracts + +import dev.inmo.micro_utils.common.MPPFile +import dev.inmo.micro_utils.ktor.common.input +import dev.inmo.tgbotapi.requests.abstracts.MultipartFile + +actual fun MPPFile.asMultipartFile(): MultipartFile = MultipartFile(this.name) { + input() +} diff --git a/tgbotapi.core/src/linuxX64Main/kotlin/utils/ActualByteReadChannelAsInput.kt b/tgbotapi.core/src/linuxX64Main/kotlin/utils/ActualByteReadChannelAsInput.kt new file mode 100644 index 0000000000..8f52f52a4e --- /dev/null +++ b/tgbotapi.core/src/linuxX64Main/kotlin/utils/ActualByteReadChannelAsInput.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.utils + +import io.ktor.utils.io.ByteReadChannel +import io.ktor.utils.io.core.Input +import io.ktor.utils.io.readRemaining + +actual suspend fun ByteReadChannel.asInput(): Input = readRemaining() diff --git a/tgbotapi.core/src/linuxX64Main/kotlin/utils/ActualMimeType.kt b/tgbotapi.core/src/linuxX64Main/kotlin/utils/ActualMimeType.kt new file mode 100644 index 0000000000..4158408546 --- /dev/null +++ b/tgbotapi.core/src/linuxX64Main/kotlin/utils/ActualMimeType.kt @@ -0,0 +1,11 @@ +package dev.inmo.tgbotapi.utils + +import kotlinx.serialization.Serializable + +//actual typealias MimeType = MimeType + +@Serializable(MimeTypeSerializer::class) +actual data class MimeType( + actual val raw: String +) +internal actual fun createMimeType(raw: String): MimeType = MimeType(raw) diff --git a/tgbotapi.core/src/mingwX64Main/kotlin/requests/abstracts/ActualMPPFileAsMultipartFile.kt b/tgbotapi.core/src/mingwX64Main/kotlin/requests/abstracts/ActualMPPFileAsMultipartFile.kt new file mode 100644 index 0000000000..942cbfddf2 --- /dev/null +++ b/tgbotapi.core/src/mingwX64Main/kotlin/requests/abstracts/ActualMPPFileAsMultipartFile.kt @@ -0,0 +1,9 @@ +package dev.inmo.tgbotapi.requests.abstracts + +import dev.inmo.micro_utils.common.MPPFile +import dev.inmo.micro_utils.ktor.common.input +import dev.inmo.tgbotapi.requests.abstracts.MultipartFile + +actual fun MPPFile.asMultipartFile(): MultipartFile = MultipartFile(this.name) { + input() +} diff --git a/tgbotapi.core/src/mingwX64Main/kotlin/utils/ActualByteReadChannelAsInput.kt b/tgbotapi.core/src/mingwX64Main/kotlin/utils/ActualByteReadChannelAsInput.kt new file mode 100644 index 0000000000..8f52f52a4e --- /dev/null +++ b/tgbotapi.core/src/mingwX64Main/kotlin/utils/ActualByteReadChannelAsInput.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.utils + +import io.ktor.utils.io.ByteReadChannel +import io.ktor.utils.io.core.Input +import io.ktor.utils.io.readRemaining + +actual suspend fun ByteReadChannel.asInput(): Input = readRemaining() diff --git a/tgbotapi.core/src/mingwX64Main/kotlin/utils/ActualMimeType.kt b/tgbotapi.core/src/mingwX64Main/kotlin/utils/ActualMimeType.kt new file mode 100644 index 0000000000..4158408546 --- /dev/null +++ b/tgbotapi.core/src/mingwX64Main/kotlin/utils/ActualMimeType.kt @@ -0,0 +1,11 @@ +package dev.inmo.tgbotapi.utils + +import kotlinx.serialization.Serializable + +//actual typealias MimeType = MimeType + +@Serializable(MimeTypeSerializer::class) +actual data class MimeType( + actual val raw: String +) +internal actual fun createMimeType(raw: String): MimeType = MimeType(raw) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt index 7010113283..b8f5a82e4f 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt @@ -160,6 +160,7 @@ import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMemberImpl import dev.inmo.tgbotapi.types.chat.member.BannedChatMember import dev.inmo.tgbotapi.types.chat.member.ChatMember +import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated import dev.inmo.tgbotapi.types.chat.member.KickedChatMember import dev.inmo.tgbotapi.types.chat.member.LeftChatMember import dev.inmo.tgbotapi.types.chat.member.LeftChatMemberImpl @@ -659,6 +660,15 @@ public inline fun WithUser.chatMemberOrThrow(): ChatMember = this as public inline fun WithUser.ifChatMember(block: (ChatMember) -> T): T? = chatMemberOrNull() ?.let(block) +public inline fun WithUser.chatMemberUpdatedOrNull(): ChatMemberUpdated? = this as? + dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated + +public inline fun WithUser.chatMemberUpdatedOrThrow(): ChatMemberUpdated = this as + dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated + +public inline fun WithUser.ifChatMemberUpdated(block: (ChatMemberUpdated) -> T): T? = + chatMemberUpdatedOrNull() ?.let(block) + public inline fun WithUser.kickedChatMemberOrNull(): KickedChatMember? = this as? dev.inmo.tgbotapi.types.chat.member.KickedChatMember