mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 19:48:43 +00:00
crutch for inputmediaphoto
This commit is contained in:
parent
6788c4d1dd
commit
6eaa9d699b
@ -28,6 +28,7 @@
|
|||||||
* `MultipartRequestCallFactory`
|
* `MultipartRequestCallFactory`
|
||||||
* `SimpleRequestCallFactory`
|
* `SimpleRequestCallFactory`
|
||||||
* `MediaGroupMemberInputMedia` members now will not have `arguments` property due to redundancy and buggy of that
|
* `MediaGroupMemberInputMedia` members now will not have `arguments` property due to redundancy and buggy of that
|
||||||
|
* Field `media` now is common for all `InputMedia` objects
|
||||||
* `TelegramBotAPI-extensions-api`:
|
* `TelegramBotAPI-extensions-api`:
|
||||||
* Extensions `TelegramBot#downloadFile` were added
|
* Extensions `TelegramBot#downloadFile` were added
|
||||||
* `TelegramBotAPI-extensions-utils`:
|
* `TelegramBotAPI-extensions-utils`:
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.toInputMediaFileAttachmentName
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.StorageFile
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.StorageFile
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.descriptors.*
|
import kotlinx.serialization.descriptors.*
|
||||||
@ -29,6 +30,12 @@ internal object InputFileSerializer : KSerializer<InputFile> {
|
|||||||
override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString())
|
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
|
// TODO:: add checks for files size
|
||||||
/**
|
/**
|
||||||
* Contains info about file for sending
|
* Contains info about file for sending
|
||||||
|
@ -9,4 +9,5 @@ fun String.toInputMediaFileAttachmentName() = "attach://$this"
|
|||||||
interface InputMedia {
|
interface InputMedia {
|
||||||
val type: String
|
val type: String
|
||||||
val file: InputFile
|
val file: InputFile
|
||||||
|
val media: String
|
||||||
}
|
}
|
@ -22,8 +22,6 @@ data class InputMediaAnimation(
|
|||||||
override val type: String = "animation"
|
override val type: String = "animation"
|
||||||
|
|
||||||
@SerialName(mediaField)
|
@SerialName(mediaField)
|
||||||
val media: String = when (file) {
|
override val media: String
|
||||||
is FileId -> file.fileId
|
init { media = file.fileId } // crutch until js compiling will be fixed
|
||||||
is MultipartFile -> file.fileId.toInputMediaFileAttachmentName()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,6 @@ data class InputMediaAudio(
|
|||||||
override val type: String = "audio"
|
override val type: String = "audio"
|
||||||
|
|
||||||
@SerialName(mediaField)
|
@SerialName(mediaField)
|
||||||
val media: String = when (file) {
|
override val media: String
|
||||||
is FileId -> file.fileId
|
init { media = file.fileId } // crutch until js compiling will be fixed
|
||||||
is MultipartFile -> file.fileId.toInputMediaFileAttachmentName()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,6 @@ data class InputMediaDocument(
|
|||||||
override val type: String = "document"
|
override val type: String = "document"
|
||||||
|
|
||||||
@SerialName(mediaField)
|
@SerialName(mediaField)
|
||||||
val media: String = when (file) {
|
override val media: String
|
||||||
is FileId -> file.fileId
|
init { media = file.fileId } // crutch until js compiling will be fixed
|
||||||
is MultipartFile -> file.fileId.toInputMediaFileAttachmentName()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,8 @@ data class InputMediaPhoto(
|
|||||||
override fun serialize(format: StringFormat): String = format.encodeToString(serializer(), this)
|
override fun serialize(format: StringFormat): String = format.encodeToString(serializer(), this)
|
||||||
|
|
||||||
@SerialName(mediaField)
|
@SerialName(mediaField)
|
||||||
val media: String = when (file) {
|
override val media: String
|
||||||
is FileId -> file.fileId
|
init { media = file.fileId } // crutch until js compiling will be fixed
|
||||||
is MultipartFile -> file.fileId.toInputMediaFileAttachmentName()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun PhotoSize.toInputMediaPhoto(
|
fun PhotoSize.toInputMediaPhoto(
|
||||||
|
@ -25,8 +25,6 @@ data class InputMediaVideo(
|
|||||||
override fun serialize(format: StringFormat): String = format.encodeToString(serializer(), this)
|
override fun serialize(format: StringFormat): String = format.encodeToString(serializer(), this)
|
||||||
|
|
||||||
@SerialName(mediaField)
|
@SerialName(mediaField)
|
||||||
val media: String = when (file) {
|
override val media: String
|
||||||
is FileId -> file.fileId
|
init { media = file.fileId } // crutch until js compiling will be fixed
|
||||||
is MultipartFile -> file.fileId.toInputMediaFileAttachmentName()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user