1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-22 16:47:13 +00:00

serializable subclasses of MessageContent

This commit is contained in:
InsanusMokrassar 2021-06-29 00:06:07 +06:00
parent c5e089a45d
commit 732e2a3906
17 changed files with 36 additions and 3 deletions

View File

@ -9,6 +9,7 @@
* `Core`:
* New interface `MyCommandsRequest` (also see `Bot API 5.3` below)
* New extensions `TextSourcesList#make*String` for all parse modes
* All `MessageContent` subclasses now serializable
* `Behaviour Builder`:
* ❗️ All triggers (`on*` extensions) have been modified to work in parallel by some marker by default (new parameter
`markerFactory`, in most cases will work async for different chats)

View File

@ -5,7 +5,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.Titled
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.files.AnimationFile
import dev.inmo.tgbotapi.types.files.Photo
import kotlinx.serialization.Serializable
@Serializable
data class Game(
override val title: String,
val description: String,

View File

@ -6,7 +6,9 @@ import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
import kotlinx.serialization.Serializable
@Serializable
data class ContactContent(
val contact: Contact
) : MessageContent {
@ -19,4 +21,4 @@ data class ContactContent(
): Request<ContentMessage<ContactContent>> = SendContact(
chatId, contact, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
}
}

View File

@ -8,7 +8,9 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.dice.Dice
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
import kotlinx.serialization.Serializable
@Serializable
data class DiceContent(
val dice: Dice
) : MessageContent {

View File

@ -8,7 +8,9 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.games.Game
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
import kotlinx.serialization.Serializable
@Serializable
data class GameContent(
val game: Game
) : MessageContent {
@ -26,4 +28,4 @@ data class GameContent(
allowSendingWithoutReply,
replyMarkup
)
}
}

View File

@ -8,7 +8,9 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
import dev.inmo.tgbotapi.types.polls.Poll
import kotlinx.serialization.Serializable
@Serializable
data class PollContent(
val poll: Poll
) : MessageContent {

View File

@ -9,7 +9,9 @@ import dev.inmo.tgbotapi.types.MessageIdentifier
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
import kotlinx.serialization.Serializable
@Serializable
data class TextContent(
override val text: String,
override val textSources: TextSourcesList = emptyList(),

View File

@ -8,7 +8,9 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
import dev.inmo.tgbotapi.types.venue.Venue
import kotlinx.serialization.Serializable
@Serializable
data class VenueContent(
val venue: Venue
) : MessageContent {
@ -21,4 +23,4 @@ data class VenueContent(
): Request<ContentMessage<VenueContent>> = SendVenue(
chatId, venue, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
}
}

View File

@ -12,7 +12,9 @@ import dev.inmo.tgbotapi.types.files.AnimationFile
import dev.inmo.tgbotapi.types.files.DocumentFile
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
import kotlinx.serialization.Serializable
@Serializable
data class AnimationContent(
override val media: AnimationFile,
val includedDocument: DocumentFile?,

View File

@ -11,7 +11,9 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.files.AudioFile
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.AudioMediaGroupContent
import kotlinx.serialization.Serializable
@Serializable
data class AudioContent(
override val media: AudioFile,
override val text: String? = null,

View File

@ -14,7 +14,9 @@ import dev.inmo.tgbotapi.types.files.asDocumentFile
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.DocumentMediaGroupContent
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
import kotlinx.serialization.Serializable
@Serializable
data class DocumentContent(
override val media: DocumentFile,
override val text: String? = null,

View File

@ -12,7 +12,9 @@ import dev.inmo.tgbotapi.types.files.*
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaCollectionContent
import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent
import kotlinx.serialization.Serializable
@Serializable
data class PhotoContent(
override val mediaCollection: Photo,
override val text: String? = null,

View File

@ -9,7 +9,9 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.files.Sticker
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
import kotlinx.serialization.Serializable
@Serializable
data class StickerContent(
override val media: Sticker
) : MediaContent {

View File

@ -11,7 +11,9 @@ import dev.inmo.tgbotapi.types.files.VideoFile
import dev.inmo.tgbotapi.types.files.toInputMediaVideo
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.VisualMediaGroupContent
import kotlinx.serialization.Serializable
@Serializable
data class VideoContent(
override val media: VideoFile,
override val text: String? = null,

View File

@ -9,7 +9,9 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.files.VideoNoteFile
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
import kotlinx.serialization.Serializable
@Serializable
data class VideoNoteContent(
override val media: VideoNoteFile
) : MediaContent {

View File

@ -11,7 +11,9 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.files.VoiceFile
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
import kotlinx.serialization.Serializable
@Serializable
data class VoiceContent(
override val media: VoiceFile,
override val text: String? = null,

View File

@ -7,7 +7,9 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
import dev.inmo.tgbotapi.types.payments.Invoice
import kotlinx.serialization.Serializable
@Serializable
data class InvoiceContent(
val invoice: Invoice
) : MessageContent {