mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2026-10-28 15:33:51 +00:00
fix for media fields in input media
This commit is contained in:
1 parent
bbc56fe94c
commit
957649603b
6 files changed
+13
-12
No files matched your search
+8
-7
@@ -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<InputFile> {
|
||||
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
|
||||
|
||||
+1
-1
@@ -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
|
||||
}
|
||||
+1
-1
@@ -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(
|
||||
|
||||
+1
-1
@@ -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(
|
||||
|
||||
+1
-1
@@ -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(
|
||||
|
||||
+1
-1
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user