diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt index 653d09f957..29ba40120d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.requests.abstracts -import dev.inmo.tgbotapi.types.InputMedia.toInputMediaFileAttachmentName import dev.inmo.tgbotapi.utils.StorageFile import kotlinx.serialization.* import kotlinx.serialization.descriptors.* @@ -12,6 +11,14 @@ sealed class InputFile { abstract val fileId: String } +internal inline val InputFile.attachFileId + get() = "attach://$fileId" +internal inline val InputFile.fileIdToSend + get() = when (this) { + is FileId -> fileId + is MultipartFile -> attachFileId + } + // TODO:: add checks for file url/file id regex /** * Contains file id or file url @@ -30,12 +37,6 @@ internal object InputFileSerializer : KSerializer { override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString()) } -internal val InputFile.asMediaData: String - get() = when (this) { - is FileId -> fileId - is MultipartFile -> fileId.toInputMediaFileAttachmentName() - } - // TODO:: add checks for files size /** * Contains info about file for sending diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAnimation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAnimation.kt index 6d96174261..c56a9044f3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAnimation.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAnimation.kt @@ -23,5 +23,5 @@ data class InputMediaAnimation( @SerialName(mediaField) override val media: String - init { media = file.fileId } // crutch until js compiling will be fixed + init { media = file.fileIdToSend } // crutch until js compiling will be fixed } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAudio.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAudio.kt index d5585c58f4..1c3b547428 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAudio.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaAudio.kt @@ -30,7 +30,7 @@ data class InputMediaAudio( @SerialName(mediaField) override val media: String - init { media = file.fileId } // crutch until js compiling will be fixed + init { media = file.fileIdToSend } // crutch until js compiling will be fixed } fun AudioFile.toInputMediaAudio( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt index e58029e6c2..465b630c6a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaDocument.kt @@ -24,7 +24,7 @@ data class InputMediaDocument( @SerialName(mediaField) override val media: String - init { media = file.fileId } // crutch until js compiling will be fixed + init { media = file.fileIdToSend } // crutch until js compiling will be fixed } fun DocumentFile.toInputMediaDocument( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaPhoto.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaPhoto.kt index 55aa777d6b..32a5c1b482 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaPhoto.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaPhoto.kt @@ -24,7 +24,7 @@ data class InputMediaPhoto( @SerialName(mediaField) override val media: String - init { media = file.fileId } // crutch until js compiling will be fixed + init { media = file.fileIdToSend } // crutch until js compiling will be fixed } fun PhotoSize.toInputMediaPhoto( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaVideo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaVideo.kt index 81e78aaa8f..302a1579d3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaVideo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InputMedia/InputMediaVideo.kt @@ -26,5 +26,5 @@ data class InputMediaVideo( @SerialName(mediaField) override val media: String - init { media = file.fileId } // crutch until js compiling will be fixed + init { media = file.fileIdToSend } // crutch until js compiling will be fixed }