1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

add MessageContent.Companion#serializationModule

This commit is contained in:
InsanusMokrassar 2022-03-20 11:52:29 +06:00
parent d3d5f7f2e6
commit 36f22579b2
2 changed files with 40 additions and 1 deletions

View File

@ -2,6 +2,9 @@
## 0.38.9 ## 0.38.9
* `Core`:
* New function `MessageContent.Companion#serializationModule`
## 0.38.8 ## 0.38.8
* `Common`: * `Common`:

View File

@ -1,3 +1,39 @@
package dev.inmo.tgbotapi.types.message.content.abstracts package dev.inmo.tgbotapi.types.message.content.abstracts
interface MessageContent: ResendableContent import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.message.content.media.*
import dev.inmo.tgbotapi.types.message.payments.InvoiceContent
import kotlinx.serialization.modules.*
interface MessageContent: ResendableContent {
companion object {
fun serializationModule(
additionalBuilder: PolymorphicModuleBuilder<MessageContent>.() -> Unit = {}
) = SerializersModule {
polymorphic(MessageContent::class) {
subclass(ContactContent::class)
subclass(VenueContent::class)
subclass(PollContent::class)
subclass(DiceContent::class)
subclass(TextContent::class)
subclass(LiveLocationContent::class)
subclass(StaticLocationContent::class)
subclass(PhotoContent::class)
subclass(VideoContent::class)
subclass(AudioContent::class)
subclass(DocumentContent::class)
subclass(VoiceContent::class)
subclass(VideoNoteContent::class)
subclass(AnimationContent::class)
subclass(StickerContent::class)
subclass(InvoiceContent::class)
additionalBuilder()
}
}
}
}