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

buildable except of jvm tests

This commit is contained in:
InsanusMokrassar 2021-05-29 15:34:14 +06:00
parent 72c3623d30
commit 5c0e58caec
128 changed files with 1481 additions and 579 deletions

View File

@ -1 +0,0 @@
spellchecker: true

View File

@ -26,7 +26,7 @@ repositories {
kotlin { kotlin {
jvm() jvm()
js(BOTH) { js(IR) {
browser() browser()
nodejs() nodejs()
} }

View File

@ -29,10 +29,8 @@ repositories {
} }
kotlin { kotlin {
jvm { jvm()
compilations.main.kotlinOptions.useIR = true js(IR) {
}
js(BOTH) {
browser() browser()
nodejs() nodejs()
} }

View File

@ -4,12 +4,12 @@ import dev.inmo.tgbotapi.types.MessageEntity.textsources.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.MultilevelTextSource import dev.inmo.tgbotapi.types.MessageEntity.textsources.MultilevelTextSource
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.captionLength import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString
import dev.inmo.tgbotapi.types.textLength
import dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForCaption import dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForCaption
import dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForMessage import dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForMessage
import dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForText import dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForText
import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString import dev.inmo.tgbotapi.types.captionLength
import dev.inmo.tgbotapi.types.textLength
const val DirectInvocationOfTextSourceConstructor = const val DirectInvocationOfTextSourceConstructor =
"It is strongly not recommended to use constructors directly instead of factory methods" "It is strongly not recommended to use constructors directly instead of factory methods"
@ -30,7 +30,7 @@ inline operator fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
@Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.MessageEntity.textsources.plus")) @Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.MessageEntity.textsources.plus"))
inline operator fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource.plus(other: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>) = inline operator fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource.plus(other: List<TextSource>) =
listOf(this) + other listOf(this) + other
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
@ -40,7 +40,7 @@ inline operator fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
@Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.MessageEntity.textsources.plus")) @Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.MessageEntity.textsources.plus"))
inline operator fun List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>.plus(text: String) = this + regular(text) inline operator fun List<TextSource>.plus(text: String) = this + regular(text)
@Deprecated( @Deprecated(
"Replaced", "Replaced",
@ -49,13 +49,13 @@ inline operator fun List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextS
typealias MultilevelTextSource = MultilevelTextSource typealias MultilevelTextSource = MultilevelTextSource
@Deprecated("Replaced", ReplaceWith("makeString", "dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString")) @Deprecated("Replaced", ReplaceWith("makeString", "dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString"))
fun List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>.makeString() = makeString() fun List<TextSource>.makeString() = makeString()
@Deprecated( @Deprecated(
"Replaced", "Replaced",
ReplaceWith("separateForMessage", "dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForMessage") ReplaceWith("separateForMessage", "dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForMessage")
) )
fun List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>.separateForMessage(limit: IntRange, numberOfParts: Int? = null) = fun List<TextSource>.separateForMessage(limit: IntRange, numberOfParts: Int? = null) =
separateForMessage(limit, numberOfParts) separateForMessage(limit, numberOfParts)
/** /**

View File

@ -8,9 +8,9 @@ interface Texted {
} }
interface TextedWithTextSources : Texted { interface TextedWithTextSources : Texted {
/** /**
* Full list of [TextSource] built from source[TextedInput.textEntities] * Full list of [TextSource]s
*/ */
val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? val textSources: List<TextSource>?
} }
interface ParsableOutput : Texted { interface ParsableOutput : Texted {
@ -18,7 +18,7 @@ interface ParsableOutput : Texted {
} }
interface EntitiesOutput : TextedWithTextSources { interface EntitiesOutput : TextedWithTextSources {
val entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? val entities: List<TextSource>?
get() = textSources get() = textSources
} }
@ -26,11 +26,4 @@ interface TextedOutput : ParsableOutput, EntitiesOutput
interface TextedInput : TextedWithTextSources { interface TextedInput : TextedWithTextSources {
override val textSources: List<TextSource> override val textSources: List<TextSource>
/**
* Here must be full list of entities. This list must contains [TextPart]s with
* [dev.inmo.tgbotapi.types.MessageEntity.textsources.RegularTextSource] in case if source text contains parts of
* regular text
*/
val textEntities: List<TextPart>
get() = textSources.toTextParts()
} }

View File

@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.polls.Poll import dev.inmo.tgbotapi.types.polls.Poll
import dev.inmo.tgbotapi.types.polls.PollSerializer
import kotlinx.serialization.* import kotlinx.serialization.*
@Serializable @Serializable
@ -19,7 +20,7 @@ data class StopPoll(
) : MessageAction, SimpleRequest<Poll>, ReplyMarkup { ) : MessageAction, SimpleRequest<Poll>, ReplyMarkup {
override fun method(): String = "stopPoll" override fun method(): String = "stopPoll"
override val resultDeserializer: DeserializationStrategy<Poll> override val resultDeserializer: DeserializationStrategy<Poll>
get() = Poll.serializer() get() = PollSerializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.requests.abstracts package dev.inmo.tgbotapi.requests.abstracts
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.StorageFile import dev.inmo.tgbotapi.utils.StorageFile
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.descriptors.* import kotlinx.serialization.descriptors.*
@ -30,8 +31,8 @@ data class FileId(
fun String.toInputFile() = FileId(this) fun String.toInputFile() = FileId(this)
@Serializer(InputFile::class) @RiskFeature
internal object InputFileSerializer : KSerializer<InputFile> { object InputFileSerializer : KSerializer<InputFile> {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor(FileId::class.toString(), PrimitiveKind.STRING) override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor(FileId::class.toString(), PrimitiveKind.STRING)
override fun serialize(encoder: Encoder, value: InputFile) = encoder.encodeString(value.fileId) override fun serialize(encoder: Encoder, value: InputFile) = encoder.encodeString(value.fileId)
override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString()) override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString())

View File

@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.serializers.InlineQueryResultSerializer import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.serializers.InlineQueryResultSerializer
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.builtins.serializer import kotlinx.serialization.builtins.serializer
@ -26,7 +26,7 @@ data class AnswerInlineQuery(
val switchPmText: String? = null, val switchPmText: String? = null,
@SerialName(switchPmParameterField) @SerialName(switchPmParameterField)
val switchPmParameter: String? = null val switchPmParameter: String? = null
): SimpleRequest<Boolean> { ) : SimpleRequest<Boolean> {
override fun method(): String = "answerInlineQuery" override fun method(): String = "answerInlineQuery"
override val resultDeserializer: DeserializationStrategy<Boolean> override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer() get() = Boolean.serializer()
@ -34,7 +34,7 @@ data class AnswerInlineQuery(
get() = serializer() get() = serializer()
} }
fun InlineQuery.createAnswer( fun dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery.createAnswer(
results: List<InlineQueryResult> = emptyList(), results: List<InlineQueryResult> = emptyList(),
cachedTime: Int? = null, cachedTime: Int? = null,
isPersonal: Boolean? = null, isPersonal: Boolean? = null,
@ -51,6 +51,7 @@ fun InlineQuery.createAnswer(
switchPmParameter switchPmParameter
) )
internal object InlineQueryAnswersResultsSerializer: KSerializer<List<InlineQueryResult>> by ListSerializer( @RiskFeature
object InlineQueryAnswersResultsSerializer : KSerializer<List<InlineQueryResult>> by ListSerializer(
InlineQueryResultSerializer InlineQueryResultSerializer
) )

View File

@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.requests.answers.payments.abstracts.AnswerShippingQuery
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.payments.ShippingOption import dev.inmo.tgbotapi.types.payments.ShippingOption
import dev.inmo.tgbotapi.types.payments.ShippingQuery import dev.inmo.tgbotapi.types.payments.ShippingQuery
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.builtins.ListSerializer
@ -21,7 +22,8 @@ data class AnswerShippingQueryOk(
get() = serializer() get() = serializer()
} }
internal object ShippingOptionsSerializer : KSerializer<List<ShippingOption>> by ListSerializer( @RiskFeature
object ShippingOptionsSerializer : KSerializer<List<ShippingOption>> by ListSerializer(
ShippingOption.serializer() ShippingOption.serializer()
) )

View File

@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.edit.abstracts.*
import dev.inmo.tgbotapi.requests.edit.media.MediaContentMessageResultDeserializer import dev.inmo.tgbotapi.requests.edit.media.MediaContentMessageResultDeserializer
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -32,7 +33,7 @@ fun EditChatMessageCaption(
fun EditChatMessageCaption( fun EditChatMessageCaption(
chatId: ChatIdentifier, chatId: ChatIdentifier,
messageId: MessageIdentifier, messageId: MessageIdentifier,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = EditChatMessageCaption( ) = EditChatMessageCaption(
chatId, chatId,
@ -58,7 +59,7 @@ data class EditChatMessageCaption internal constructor(
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditChatMessage<MediaContent>, EditTextChatMessage, EditReplyMessage { ) : EditChatMessage<MediaContent>, EditTextChatMessage, EditReplyMessage {
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text) rawEntities ?.asTextSources(text)
} }

View File

@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString
import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.requests.edit.abstracts.*
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -24,7 +25,7 @@ fun EditInlineMessageCaption(
fun EditInlineMessageCaption( fun EditInlineMessageCaption(
inlineMessageId: InlineMessageIdentifier, inlineMessageId: InlineMessageIdentifier,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = EditInlineMessageCaption( ) = EditInlineMessageCaption(
inlineMessageId, inlineMessageId,
@ -47,7 +48,7 @@ data class EditInlineMessageCaption internal constructor(
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage { ) : EditInlineMessage, EditTextChatMessage, EditReplyMessage {
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text) rawEntities ?.asTextSources(text)
} }

View File

@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.edit.abstracts.*
import dev.inmo.tgbotapi.requests.send.TextContentMessageResultDeserializer import dev.inmo.tgbotapi.requests.send.TextContentMessageResultDeserializer
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -34,7 +35,7 @@ fun EditChatMessageText(
fun EditChatMessageText( fun EditChatMessageText(
chatId: ChatIdentifier, chatId: ChatIdentifier,
messageId: MessageIdentifier, messageId: MessageIdentifier,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
disableWebPagePreview: Boolean? = null, disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = EditChatMessageText( ) = EditChatMessageText(
@ -64,7 +65,7 @@ data class EditChatMessageText internal constructor(
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditChatMessage<TextContent>, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage { ) : EditChatMessage<TextContent>, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text) rawEntities ?.asTextSources(text)
} }

View File

@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString
import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.requests.edit.abstracts.*
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -26,7 +27,7 @@ fun EditInlineMessageText(
fun EditInlineMessageText( fun EditInlineMessageText(
inlineMessageId: InlineMessageIdentifier, inlineMessageId: InlineMessageIdentifier,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
disableWebPagePreview: Boolean? = null, disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = EditInlineMessageText( ) = EditInlineMessageText(
@ -53,7 +54,7 @@ data class EditInlineMessageText internal constructor(
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage { ) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text) rawEntities ?.asTextSources(text)
} }

View File

@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.requests.games.abstracts
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.games.GameHighScore import dev.inmo.tgbotapi.types.games.GameHighScore
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.DeserializationStrategy import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.KSerializer import kotlinx.serialization.KSerializer
import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.builtins.ListSerializer
@ -15,4 +16,5 @@ interface GetGameHighScores : SimpleRequest<List<GameHighScore>> {
get() = GameHighScoresSerializer get() = GameHighScoresSerializer
} }
internal object GameHighScoresSerializer : KSerializer<List<GameHighScore>> by ListSerializer(GameHighScore.serializer()) @RiskFeature
object GameHighScoresSerializer : KSerializer<List<GameHighScore>> by ListSerializer(GameHighScore.serializer())

View File

@ -1,6 +1,7 @@
package dev.inmo.tgbotapi.requests.send package dev.inmo.tgbotapi.requests.send
import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
import dev.inmo.tgbotapi.CommonAbstracts.makeString
import dev.inmo.tgbotapi.CommonAbstracts.types.MessageAction import dev.inmo.tgbotapi.CommonAbstracts.types.MessageAction
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest
@ -28,7 +29,7 @@ fun CopyMessage(
fromChatId: ChatIdentifier, fromChatId: ChatIdentifier,
toChatId: ChatIdentifier, toChatId: ChatIdentifier,
messageId: MessageIdentifier, messageId: MessageIdentifier,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: List<TextSource>,
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,

View File

@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.types.DisableWebPagePreview
import dev.inmo.tgbotapi.requests.send.abstracts.* import dev.inmo.tgbotapi.requests.send.abstracts.*
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
@ -40,7 +41,7 @@ fun SendTextMessage(
fun SendTextMessage( fun SendTextMessage(
chatId: ChatIdentifier, chatId: ChatIdentifier,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
disableWebPagePreview: Boolean? = null, disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
@ -83,7 +84,7 @@ data class SendTextMessage internal constructor(
TextableSendMessageRequest<ContentMessage<TextContent>>, TextableSendMessageRequest<ContentMessage<TextContent>>,
DisableWebPagePreview DisableWebPagePreview
{ {
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text) rawEntities ?.asTextSources(text)
} }

View File

@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.abstracts.*
import dev.inmo.tgbotapi.requests.send.media.base.* import dev.inmo.tgbotapi.requests.send.media.base.*
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
@ -65,7 +66,7 @@ fun SendAnimation(
chatId: ChatIdentifier, chatId: ChatIdentifier,
animation: InputFile, animation: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
duration: Long? = null, duration: Long? = null,
width: Int? = null, width: Int? = null,
height: Int? = null, height: Int? = null,
@ -144,7 +145,7 @@ data class SendAnimationData internal constructor(
DuratedSendMessageRequest<ContentMessage<AnimationContent>>, DuratedSendMessageRequest<ContentMessage<AnimationContent>>,
SizedSendMessageRequest<ContentMessage<AnimationContent>> SizedSendMessageRequest<ContentMessage<AnimationContent>>
{ {
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }

View File

@ -1,6 +1,7 @@
package dev.inmo.tgbotapi.requests.send.media package dev.inmo.tgbotapi.requests.send.media
import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.CommonAbstracts.Performerable
import dev.inmo.tgbotapi.CommonAbstracts.makeString
import dev.inmo.tgbotapi.requests.abstracts.* import dev.inmo.tgbotapi.requests.abstracts.*
import dev.inmo.tgbotapi.requests.send.abstracts.* import dev.inmo.tgbotapi.requests.send.abstracts.*
import dev.inmo.tgbotapi.requests.send.media.base.* import dev.inmo.tgbotapi.requests.send.media.base.*
@ -66,7 +67,7 @@ fun SendAudio(
chatId: ChatIdentifier, chatId: ChatIdentifier,
audio: InputFile, audio: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: List<TextSource>,
duration: Long? = null, duration: Long? = null,
performer: String? = null, performer: String? = null,
title: String? = null, title: String? = null,

View File

@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.abstracts.*
import dev.inmo.tgbotapi.requests.send.media.base.* import dev.inmo.tgbotapi.requests.send.media.base.*
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
@ -79,7 +80,7 @@ fun SendDocument(
chatId: ChatIdentifier, chatId: ChatIdentifier,
document: InputFile, document: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
@ -157,7 +158,7 @@ data class SendDocumentData internal constructor(
TextableSendMessageRequest<ContentMessage<DocumentContent>>, TextableSendMessageRequest<ContentMessage<DocumentContent>>,
ThumbedSendMessageRequest<ContentMessage<DocumentContent>> ThumbedSendMessageRequest<ContentMessage<DocumentContent>>
{ {
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }

View File

@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.abstracts.*
import dev.inmo.tgbotapi.requests.send.media.base.* import dev.inmo.tgbotapi.requests.send.media.base.*
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
@ -47,7 +48,7 @@ fun SendPhoto(
fun SendPhoto( fun SendPhoto(
chatId: ChatIdentifier, chatId: ChatIdentifier,
photo: InputFile, photo: InputFile,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
@ -100,7 +101,7 @@ data class SendPhotoData internal constructor(
ReplyingMarkupSendMessageRequest<ContentMessage<PhotoContent>>, ReplyingMarkupSendMessageRequest<ContentMessage<PhotoContent>>,
TextableSendMessageRequest<ContentMessage<PhotoContent>> TextableSendMessageRequest<ContentMessage<PhotoContent>>
{ {
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }

View File

@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.abstracts.*
import dev.inmo.tgbotapi.requests.send.media.base.* import dev.inmo.tgbotapi.requests.send.media.base.*
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
@ -67,7 +68,7 @@ fun SendVideo(
chatId: ChatIdentifier, chatId: ChatIdentifier,
video: InputFile, video: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
duration: Long? = null, duration: Long? = null,
width: Int? = null, width: Int? = null,
height: Int? = null, height: Int? = null,
@ -150,7 +151,7 @@ data class SendVideoData internal constructor(
DuratedSendMessageRequest<ContentMessage<VideoContent>>, DuratedSendMessageRequest<ContentMessage<VideoContent>>,
SizedSendMessageRequest<ContentMessage<VideoContent>> SizedSendMessageRequest<ContentMessage<VideoContent>>
{ {
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }

View File

@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.abstracts.*
import dev.inmo.tgbotapi.requests.send.media.base.* import dev.inmo.tgbotapi.requests.send.media.base.*
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
@ -56,7 +57,7 @@ fun SendVoice(
fun SendVoice( fun SendVoice(
chatId: ChatIdentifier, chatId: ChatIdentifier,
voice: InputFile, voice: InputFile,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
duration: Long? = null, duration: Long? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
@ -120,7 +121,7 @@ data class SendVoiceData internal constructor(
TextableSendMessageRequest<ContentMessage<VoiceContent>>, TextableSendMessageRequest<ContentMessage<VoiceContent>>,
DuratedSendMessageRequest<ContentMessage<VoiceContent>> DuratedSendMessageRequest<ContentMessage<VoiceContent>>
{ {
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }

View File

@ -1,7 +1,8 @@
package dev.inmo.tgbotapi.requests.send.polls package dev.inmo.tgbotapi.requests.send.polls
import com.soywiz.klock.DateTime import com.soywiz.klock.DateTime
import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
import dev.inmo.tgbotapi.CommonAbstracts.makeString
import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
@ -268,7 +269,7 @@ fun SendQuizPoll(
correctOptionId: Int, correctOptionId: Int,
isAnonymous: Boolean = true, isAnonymous: Boolean = true,
isClosed: Boolean = false, isClosed: Boolean = false,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: List<TextSource>,
closeInfo: ScheduledCloseInfo? = null, closeInfo: ScheduledCloseInfo? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,

View File

@ -1,7 +1,9 @@
package dev.inmo.tgbotapi.types package dev.inmo.tgbotapi.types
import dev.inmo.micro_utils.common.Warning import dev.inmo.micro_utils.common.Warning
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.JsonPrimitive import kotlinx.serialization.json.JsonPrimitive
@ -52,10 +54,12 @@ data class Username(
fun String.toUsername(): Username = Username(this) fun String.toUsername(): Username = Username(this)
@Serializer(ChatIdentifier::class) @RiskFeature
internal object ChatIdentifierSerializer : KSerializer<ChatIdentifier> { object ChatIdentifierSerializer : KSerializer<ChatIdentifier> {
private val internalSerializer = JsonPrimitive.serializer()
override val descriptor: SerialDescriptor = internalSerializer.descriptor
override fun deserialize(decoder: Decoder): ChatIdentifier { override fun deserialize(decoder: Decoder): ChatIdentifier {
val id = JsonPrimitive.serializer().deserialize(decoder) val id = internalSerializer.deserialize(decoder)
return id.longOrNull ?.let { return id.longOrNull ?.let {
ChatId(it) ChatId(it)
} ?: id.content.let { } ?: id.content.let {
@ -73,4 +77,4 @@ internal object ChatIdentifierSerializer : KSerializer<ChatIdentifier> {
is Username -> encoder.encodeString(value.username) is Username -> encoder.encodeString(value.username)
} }
} }
} }

View File

@ -79,7 +79,6 @@ data class CommonInviteLink(
get() = expireDate ?.asDate get() = expireDate ?.asDate
} }
@Serializer(ChatInviteLink::class)
object ChatInviteLinkSerializer : KSerializer<ChatInviteLink> { object ChatInviteLinkSerializer : KSerializer<ChatInviteLink> {
override val descriptor: SerialDescriptor override val descriptor: SerialDescriptor
get() = RawChatInviteLink.serializer().descriptor get() = RawChatInviteLink.serializer().descriptor

View File

@ -1,7 +1,6 @@
package dev.inmo.tgbotapi.types.ChatMember package dev.inmo.tgbotapi.types.ChatMember
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember
import dev.inmo.tgbotapi.types.ChatMember.abstracts.MemberChatMember import dev.inmo.tgbotapi.types.ChatMember.abstracts.MemberChatMember
import kotlinx.serialization.* import kotlinx.serialization.*

View File

@ -20,7 +20,6 @@ interface AdministratorChatMember : SpecialRightsChatMember {
val customTitle: String? val customTitle: String?
} }
@Serializer(AdministratorChatMember::class)
@RiskFeature @RiskFeature
object AdministratorChatMemberSerializer : KSerializer<AdministratorChatMember> { object AdministratorChatMemberSerializer : KSerializer<AdministratorChatMember> {
override val descriptor: SerialDescriptor = ChatMemberSerializer.descriptor override val descriptor: SerialDescriptor = ChatMemberSerializer.descriptor

View File

@ -17,7 +17,6 @@ sealed interface ChatMember {
val user: User val user: User
} }
@Serializer(ChatMember::class)
@RiskFeature @RiskFeature
object ChatMemberSerializer : KSerializer<ChatMember> { object ChatMemberSerializer : KSerializer<ChatMember> {
override val descriptor: SerialDescriptor = JsonObject.serializer().descriptor override val descriptor: SerialDescriptor = JsonObject.serializer().descriptor
@ -27,9 +26,9 @@ object ChatMemberSerializer : KSerializer<ChatMember> {
return when (json[statusField] ?.jsonPrimitive ?.content ?: error("Status field of chat member must be specified, but incoming json contains next: $json")) { return when (json[statusField] ?.jsonPrimitive ?.content ?: error("Status field of chat member must be specified, but incoming json contains next: $json")) {
"creator" -> nonstrictJsonFormat.decodeFromJsonElement(CreatorChatMember.serializer(), json) "creator" -> nonstrictJsonFormat.decodeFromJsonElement(CreatorChatMember.serializer(), json)
"administrator" -> nonstrictJsonFormat.decodeFromJsonElement(AdministratorChatMemberImpl.serializer(), json) "administrator" -> nonstrictJsonFormat.decodeFromJsonElement(AdministratorChatMemberImpl.serializer(), json)
"member" -> nonstrictJsonFormat.decodeFromJsonElement(MemberChatMember.serializer(), json) "member" -> nonstrictJsonFormat.decodeFromJsonElement(MemberChatMemberImpl.serializer(), json)
"restricted" -> nonstrictJsonFormat.decodeFromJsonElement(RestrictedChatMember.serializer(), json) "restricted" -> nonstrictJsonFormat.decodeFromJsonElement(RestrictedChatMember.serializer(), json)
"left" -> nonstrictJsonFormat.decodeFromJsonElement(LeftChatMember.serializer(), json) "left" -> nonstrictJsonFormat.decodeFromJsonElement(LeftChatMemberImpl.serializer(), json)
"kicked" -> nonstrictJsonFormat.decodeFromJsonElement(KickedChatMember.serializer(), json) "kicked" -> nonstrictJsonFormat.decodeFromJsonElement(KickedChatMember.serializer(), json)
else -> error("Unknown type of chat member in json: $json") else -> error("Unknown type of chat member in json: $json")
} }
@ -39,9 +38,9 @@ object ChatMemberSerializer : KSerializer<ChatMember> {
when (value) { when (value) {
is CreatorChatMember -> CreatorChatMember.serializer() is CreatorChatMember -> CreatorChatMember.serializer()
is AdministratorChatMemberImpl -> AdministratorChatMemberImpl.serializer() is AdministratorChatMemberImpl -> AdministratorChatMemberImpl.serializer()
is MemberChatMember -> MemberChatMember.serializer() is MemberChatMember -> MemberChatMemberImpl.serializer()
is RestrictedChatMember -> RestrictedChatMember.serializer() is RestrictedChatMember -> RestrictedChatMember.serializer()
is LeftChatMember -> LeftChatMember.serializer() is LeftChatMember -> LeftChatMemberImpl.serializer()
is KickedChatMember -> KickedChatMember.serializer() is KickedChatMember -> KickedChatMember.serializer()
} }
} }

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@ -36,4 +36,4 @@ class InlineQueryResultArticle(
WithInputMessageContentInlineQueryResult, WithInputMessageContentInlineQueryResult,
UrlInlineQueryResult { UrlInlineQueryResult {
override val type: String = "article" override val type: String = "article"
} }

View File

@ -5,8 +5,9 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudioCached import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudioCached
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.inlineQueryResultAudioType import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.inlineQueryResultAudioType
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -25,7 +26,7 @@ fun InlineQueryResultAudioCachedImpl(
fun InlineQueryResultAudioCachedImpl( fun InlineQueryResultAudioCachedImpl(
id: InlineQueryIdentifier, id: InlineQueryIdentifier,
fileId: FileId, fileId: FileId,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
replyMarkup: InlineKeyboardMarkup? = null, replyMarkup: InlineKeyboardMarkup? = null,
inputMessageContent: InputMessageContent? = null inputMessageContent: InputMessageContent? = null
) = InlineQueryResultAudioCachedImpl(id, fileId, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) ) = InlineQueryResultAudioCachedImpl(id, fileId, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent)
@ -48,7 +49,7 @@ data class InlineQueryResultAudioCachedImpl internal constructor(
override val inputMessageContent: InputMessageContent? = null override val inputMessageContent: InputMessageContent? = null
) : InlineQueryResultAudioCached { ) : InlineQueryResultAudioCached {
override val type: String = inlineQueryResultAudioType override val type: String = inlineQueryResultAudioType
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }
} }

View File

@ -4,8 +4,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudio import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.InlineQueryResultAudio
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.inlineQueryResultAudioType import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.inlineQueryResultAudioType
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -30,7 +31,7 @@ fun InlineQueryResultAudioImpl(
title: String, title: String,
performer: String? = null, performer: String? = null,
duration: Int? = null, duration: Int? = null,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
replyMarkup: InlineKeyboardMarkup? = null, replyMarkup: InlineKeyboardMarkup? = null,
inputMessageContent: InputMessageContent? = null inputMessageContent: InputMessageContent? = null
) = InlineQueryResultAudioImpl(id, url, title, performer, duration, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) ) = InlineQueryResultAudioImpl(id, url, title, performer, duration, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent)
@ -59,7 +60,7 @@ data class InlineQueryResultAudioImpl internal constructor(
override val inputMessageContent: InputMessageContent? = null override val inputMessageContent: InputMessageContent? = null
) : InlineQueryResultAudio { ) : InlineQueryResultAudio {
override val type: String = inlineQueryResultAudioType override val type: String = inlineQueryResultAudioType
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }
} }

View File

@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
import dev.inmo.tgbotapi.CommonAbstracts.CommonContactData import dev.inmo.tgbotapi.CommonAbstracts.CommonContactData
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable

View File

@ -5,8 +5,10 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocumentCached import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocumentCached
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.inlineQueryResultDocumentType import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.inlineQueryResultDocumentType
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -29,7 +31,7 @@ fun InlineQueryResultDocumentCachedImpl(
fileId: FileId, fileId: FileId,
title: String, title: String,
description: String? = null, description: String? = null,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
replyMarkup: InlineKeyboardMarkup? = null, replyMarkup: InlineKeyboardMarkup? = null,
inputMessageContent: InputMessageContent? = null inputMessageContent: InputMessageContent? = null
) = InlineQueryResultDocumentCachedImpl(id, fileId, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) ) = InlineQueryResultDocumentCachedImpl(id, fileId, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent)
@ -56,7 +58,7 @@ data class InlineQueryResultDocumentCachedImpl internal constructor(
override val inputMessageContent: InputMessageContent? = null override val inputMessageContent: InputMessageContent? = null
) : InlineQueryResultDocumentCached { ) : InlineQueryResultDocumentCached {
override val type: String = inlineQueryResultDocumentType override val type: String = inlineQueryResultDocumentType
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }
} }

View File

@ -4,8 +4,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocument import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.InlineQueryResultDocument
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.inlineQueryResultDocumentType import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.inlineQueryResultDocumentType
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -38,7 +39,7 @@ fun InlineQueryResultDocumentImpl(
thumbWidth: Int? = null, thumbWidth: Int? = null,
thumbHeight: Int? = null, thumbHeight: Int? = null,
description: String? = null, description: String? = null,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
replyMarkup: InlineKeyboardMarkup? = null, replyMarkup: InlineKeyboardMarkup? = null,
inputMessageContent: InputMessageContent? = null inputMessageContent: InputMessageContent? = null
) = InlineQueryResultDocumentImpl(id, url, title, mimeType, thumbUrl, thumbWidth, thumbHeight, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) ) = InlineQueryResultDocumentImpl(id, url, title, mimeType, thumbUrl, thumbWidth, thumbHeight, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent)
@ -73,7 +74,7 @@ data class InlineQueryResultDocumentImpl internal constructor(
override val inputMessageContent: InputMessageContent? = null override val inputMessageContent: InputMessageContent? = null
) : InlineQueryResultDocument { ) : InlineQueryResultDocument {
override val type: String = inlineQueryResultDocumentType override val type: String = inlineQueryResultDocumentType
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }
} }

View File

@ -5,8 +5,9 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGifCached import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGifCached
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.inlineQueryResultGifType import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.inlineQueryResultGifType
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -27,7 +28,7 @@ fun InlineQueryResultGifCachedImpl(
id: InlineQueryIdentifier, id: InlineQueryIdentifier,
fileId: FileId, fileId: FileId,
title: String? = null, title: String? = null,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
replyMarkup: InlineKeyboardMarkup? = null, replyMarkup: InlineKeyboardMarkup? = null,
inputMessageContent: InputMessageContent? = null inputMessageContent: InputMessageContent? = null
) = InlineQueryResultGifCachedImpl(id, fileId, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) ) = InlineQueryResultGifCachedImpl(id, fileId, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent)
@ -52,7 +53,7 @@ data class InlineQueryResultGifCachedImpl internal constructor(
override val inputMessageContent: InputMessageContent? = null override val inputMessageContent: InputMessageContent? = null
) : InlineQueryResultGifCached { ) : InlineQueryResultGifCached {
override val type: String = inlineQueryResultGifType override val type: String = inlineQueryResultGifType
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }
} }

View File

@ -4,8 +4,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGif import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.InlineQueryResultGif
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.inlineQueryResultGifType import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.inlineQueryResultGifType
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -37,7 +38,7 @@ fun InlineQueryResultGifImpl(
height: Int? = null, height: Int? = null,
duration: Int? = null, duration: Int? = null,
title: String? = null, title: String? = null,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
replyMarkup: InlineKeyboardMarkup? = null, replyMarkup: InlineKeyboardMarkup? = null,
inputMessageContent: InputMessageContent? = null inputMessageContent: InputMessageContent? = null
) = InlineQueryResultGifImpl(id, url, thumbUrl, thumbMimeType, width, height, duration, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) ) = InlineQueryResultGifImpl(id, url, thumbUrl, thumbMimeType, width, height, duration, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent)
@ -72,7 +73,7 @@ data class InlineQueryResultGifImpl internal constructor(
override val inputMessageContent: InputMessageContent? = null override val inputMessageContent: InputMessageContent? = null
) : InlineQueryResultGif { ) : InlineQueryResultGif {
override val type: String = inlineQueryResultGifType override val type: String = inlineQueryResultGifType
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }

View File

@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.CommonAbstracts.*
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable

View File

@ -5,8 +5,9 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4GifCached import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4GifCached
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.inlineQueryResultMpeg4GifType import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.inlineQueryResultMpeg4GifType
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -27,7 +28,7 @@ fun InlineQueryResultMpeg4GifCachedImpl(
id: InlineQueryIdentifier, id: InlineQueryIdentifier,
fileId: FileId, fileId: FileId,
title: String? = null, title: String? = null,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
replyMarkup: InlineKeyboardMarkup? = null, replyMarkup: InlineKeyboardMarkup? = null,
inputMessageContent: InputMessageContent? = null inputMessageContent: InputMessageContent? = null
) = InlineQueryResultMpeg4GifCachedImpl(id, fileId, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) ) = InlineQueryResultMpeg4GifCachedImpl(id, fileId, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent)
@ -52,7 +53,7 @@ data class InlineQueryResultMpeg4GifCachedImpl internal constructor(
override val inputMessageContent: InputMessageContent? = null override val inputMessageContent: InputMessageContent? = null
) : InlineQueryResultMpeg4GifCached { ) : InlineQueryResultMpeg4GifCached {
override val type: String = inlineQueryResultMpeg4GifType override val type: String = inlineQueryResultMpeg4GifType
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }
} }

View File

@ -4,8 +4,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4Gif import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.InlineQueryResultMpeg4Gif
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.inlineQueryResultMpeg4GifType import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.inlineQueryResultMpeg4GifType
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -37,7 +38,7 @@ fun InlineQueryResultMpeg4GifImpl(
height: Int? = null, height: Int? = null,
duration: Int? = null, duration: Int? = null,
title: String? = null, title: String? = null,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
replyMarkup: InlineKeyboardMarkup? = null, replyMarkup: InlineKeyboardMarkup? = null,
inputMessageContent: InputMessageContent? = null inputMessageContent: InputMessageContent? = null
) = InlineQueryResultMpeg4GifImpl(id, url, thumbUrl, thumbMimeType, width, height, duration, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) ) = InlineQueryResultMpeg4GifImpl(id, url, thumbUrl, thumbMimeType, width, height, duration, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent)
@ -72,7 +73,7 @@ data class InlineQueryResultMpeg4GifImpl internal constructor(
override val inputMessageContent: InputMessageContent? = null override val inputMessageContent: InputMessageContent? = null
) : InlineQueryResultMpeg4Gif { ) : InlineQueryResultMpeg4Gif {
override val type: String = inlineQueryResultMpeg4GifType override val type: String = inlineQueryResultMpeg4GifType
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }

View File

@ -5,8 +5,9 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhotoCached import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhotoCached
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.inlineQueryResultPhotoType import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.inlineQueryResultPhotoType
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -29,7 +30,7 @@ fun InlineQueryResultPhotoCachedImpl(
fileId: FileId, fileId: FileId,
title: String? = null, title: String? = null,
description: String? = null, description: String? = null,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
replyMarkup: InlineKeyboardMarkup? = null, replyMarkup: InlineKeyboardMarkup? = null,
inputMessageContent: InputMessageContent? = null inputMessageContent: InputMessageContent? = null
) = InlineQueryResultPhotoCachedImpl(id, fileId, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) ) = InlineQueryResultPhotoCachedImpl(id, fileId, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent)
@ -56,7 +57,7 @@ data class InlineQueryResultPhotoCachedImpl internal constructor(
override val inputMessageContent: InputMessageContent? = null override val inputMessageContent: InputMessageContent? = null
) : InlineQueryResultPhotoCached { ) : InlineQueryResultPhotoCached {
override val type: String = inlineQueryResultPhotoType override val type: String = inlineQueryResultPhotoType
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }
} }

View File

@ -4,8 +4,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhoto import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.InlineQueryResultPhoto
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.inlineQueryResultPhotoType import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.inlineQueryResultPhotoType
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -34,7 +35,7 @@ fun InlineQueryResultPhotoImpl(
height: Int? = null, height: Int? = null,
title: String? = null, title: String? = null,
description: String? = null, description: String? = null,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
replyMarkup: InlineKeyboardMarkup? = null, replyMarkup: InlineKeyboardMarkup? = null,
inputMessageContent: InputMessageContent? = null inputMessageContent: InputMessageContent? = null
) = InlineQueryResultPhotoImpl(id, url, thumbUrl, width, height, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) ) = InlineQueryResultPhotoImpl(id, url, thumbUrl, width, height, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent)
@ -67,7 +68,7 @@ data class InlineQueryResultPhotoImpl internal constructor(
override val inputMessageContent: InputMessageContent? = null override val inputMessageContent: InputMessageContent? = null
) : InlineQueryResultPhoto { ) : InlineQueryResultPhoto {
override val type: String = inlineQueryResultPhotoType override val type: String = inlineQueryResultPhotoType
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }
} }

View File

@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable

View File

@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.CommonVenueData
import dev.inmo.tgbotapi.CommonAbstracts.Locationed import dev.inmo.tgbotapi.CommonAbstracts.Locationed
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable

View File

@ -5,8 +5,9 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideoCached import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideoCached
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.inlineQueryResultVideoType import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.inlineQueryResultVideoType
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -29,7 +30,7 @@ fun InlineQueryResultVideoCachedImpl(
fileId: FileId, fileId: FileId,
title: String, title: String,
description: String? = null, description: String? = null,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
replyMarkup: InlineKeyboardMarkup? = null, replyMarkup: InlineKeyboardMarkup? = null,
inputMessageContent: InputMessageContent? = null inputMessageContent: InputMessageContent? = null
) = InlineQueryResultVideoCachedImpl(id, fileId, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) ) = InlineQueryResultVideoCachedImpl(id, fileId, title, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent)
@ -56,7 +57,7 @@ data class InlineQueryResultVideoCachedImpl internal constructor(
override val inputMessageContent: InputMessageContent? = null override val inputMessageContent: InputMessageContent? = null
) : InlineQueryResultVideoCached { ) : InlineQueryResultVideoCached {
override val type: String = inlineQueryResultVideoType override val type: String = inlineQueryResultVideoType
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }
} }

View File

@ -4,8 +4,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideo import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.InlineQueryResultVideo
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.inlineQueryResultVideoType import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.inlineQueryResultVideoType
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -40,7 +41,7 @@ fun InlineQueryResultVideoImpl(
height: Int? = null, height: Int? = null,
duration: Int? = null, duration: Int? = null,
description: String? = null, description: String? = null,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: List<TextSource>,
replyMarkup: InlineKeyboardMarkup? = null, replyMarkup: InlineKeyboardMarkup? = null,
inputMessageContent: InputMessageContent? = null inputMessageContent: InputMessageContent? = null
) = InlineQueryResultVideoImpl(id, url, thumbUrl, mimeType, title, width, height, duration, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) ) = InlineQueryResultVideoImpl(id, url, thumbUrl, mimeType, title, width, height, duration, description, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent)
@ -77,7 +78,7 @@ data class InlineQueryResultVideoImpl internal constructor(
override val inputMessageContent: InputMessageContent? = null override val inputMessageContent: InputMessageContent? = null
) : InlineQueryResultVideo { ) : InlineQueryResultVideo {
override val type: String = inlineQueryResultVideoType override val type: String = inlineQueryResultVideoType
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: List<TextSource>? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }
} }

View File

@ -5,8 +5,10 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoiceCached import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoiceCached
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.inlineQueryResultVoiceType import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.inlineQueryResultVoiceType
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -27,7 +29,7 @@ fun InlineQueryResultVoiceCachedImpl(
id: InlineQueryIdentifier, id: InlineQueryIdentifier,
fileId: FileId, fileId: FileId,
title: String, title: String,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
replyMarkup: InlineKeyboardMarkup? = null, replyMarkup: InlineKeyboardMarkup? = null,
inputMessageContent: InputMessageContent? = null inputMessageContent: InputMessageContent? = null
) = InlineQueryResultVoiceCachedImpl(id, fileId, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) ) = InlineQueryResultVoiceCachedImpl(id, fileId, title, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent)
@ -52,7 +54,7 @@ data class InlineQueryResultVoiceCachedImpl internal constructor(
override val inputMessageContent: InputMessageContent? = null override val inputMessageContent: InputMessageContent? = null
) : InlineQueryResultVoiceCached { ) : InlineQueryResultVoiceCached {
override val type: String = inlineQueryResultVoiceType override val type: String = inlineQueryResultVoiceType
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }
} }

View File

@ -4,8 +4,10 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoice import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.InlineQueryResultVoice
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.inlineQueryResultVoiceType import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.inlineQueryResultVoiceType
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -38,7 +40,7 @@ fun InlineQueryResultVoiceImpl(
url: String, url: String,
title: String, title: String,
duration: Int? = null, duration: Int? = null,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
replyMarkup: InlineKeyboardMarkup? = null, replyMarkup: InlineKeyboardMarkup? = null,
inputMessageContent: InputMessageContent? = null inputMessageContent: InputMessageContent? = null
) = InlineQueryResultVoiceImpl(id, url, title, duration, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent) ) = InlineQueryResultVoiceImpl(id, url, title, duration, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent)
@ -65,7 +67,7 @@ data class InlineQueryResultVoiceImpl internal constructor(
override val inputMessageContent: InputMessageContent? = null override val inputMessageContent: InputMessageContent? = null
) : InlineQueryResultVoice { ) : InlineQueryResultVoice {
override val type: String = inlineQueryResultVoiceType override val type: String = inlineQueryResultVoiceType
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }
} }

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent
interface WithInputMessageContentInlineQueryResult : InlineQueryResult { interface WithInputMessageContentInlineQueryResult : InlineQueryResult {
val inputMessageContent: InputMessageContent? val inputMessageContent: InputMessageContent?

View File

@ -2,13 +2,14 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.serializers
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.* import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.descriptors.* import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.encoding.Encoder
@Serializer(InlineQueryResult::class) @RiskFeature
internal object InlineQueryResultSerializer : KSerializer<InlineQueryResult> { object InlineQueryResultSerializer : KSerializer<InlineQueryResult> {
@InternalSerializationApi @InternalSerializationApi
override val descriptor: SerialDescriptor = buildSerialDescriptor(InlineQueryResult::class.toString(), PolymorphicKind.OPEN) override val descriptor: SerialDescriptor = buildSerialDescriptor(InlineQueryResult::class.toString(), PolymorphicKind.OPEN)
override fun serialize(encoder: Encoder, value: InlineQueryResult) { override fun serialize(encoder: Encoder, value: InlineQueryResult) {
@ -39,4 +40,4 @@ internal object InlineQueryResultSerializer : KSerializer<InlineQueryResult> {
override fun deserialize(decoder: Decoder): InlineQueryResult { override fun deserialize(decoder: Decoder): InlineQueryResult {
throw TODO() throw TODO()
} }
} }

View File

@ -1,10 +1,11 @@
package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent
import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
import dev.inmo.tgbotapi.CommonAbstracts.types.DisableWebPagePreview import dev.inmo.tgbotapi.CommonAbstracts.types.DisableWebPagePreview
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
@ -23,7 +24,7 @@ fun InputTextMessageContent(
* Represents the [InputMessageContent] of a text message to be sent as the result of an inline query. * Represents the [InputMessageContent] of a text message to be sent as the result of an inline query.
*/ */
fun InputTextMessageContent( fun InputTextMessageContent(
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
disableWebPagePreview: Boolean? = null disableWebPagePreview: Boolean? = null
) = InputTextMessageContent(entities.makeString(), null, entities.toRawMessageEntities(), disableWebPagePreview) ) = InputTextMessageContent(entities.makeString(), null, entities.toRawMessageEntities(), disableWebPagePreview)
@ -38,7 +39,7 @@ data class InputTextMessageContent internal constructor(
@SerialName(disableWebPagePreviewField) @SerialName(disableWebPagePreviewField)
override val disableWebPagePreview: Boolean? = null override val disableWebPagePreview: Boolean? = null
) : TextedOutput, DisableWebPagePreview, InputMessageContent { ) : TextedOutput, DisableWebPagePreview, InputMessageContent {
override val textSources: List<TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text) rawEntities ?.asTextSources(text)
} }
} }

View File

@ -1,14 +1,14 @@
package dev.inmo.tgbotapi.types.InlineQueries package dev.inmo.tgbotapi.types.InlineQueries
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.* import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.*
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InputMessageContent import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.descriptors.* import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.encoding.Encoder
@Serializer(InputMessageContent::class) @RiskFeature
internal object InputMessageContentSerializer : KSerializer<InputMessageContent> { object InputMessageContentSerializer : KSerializer<InputMessageContent> {
@InternalSerializationApi @InternalSerializationApi
override val descriptor: SerialDescriptor = buildSerialDescriptor(InputMessageContent::class.toString(), PolymorphicKind.OPEN) override val descriptor: SerialDescriptor = buildSerialDescriptor(InputMessageContent::class.toString(), PolymorphicKind.OPEN)
override fun serialize(encoder: Encoder, value: InputMessageContent) { override fun serialize(encoder: Encoder, value: InputMessageContent) {

View File

@ -1,11 +1,13 @@
package dev.inmo.tgbotapi.types.InputMedia package dev.inmo.tgbotapi.types.InputMedia
import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.CommonAbstracts.TextedOutput
import dev.inmo.tgbotapi.CommonAbstracts.makeString
import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.abstracts.InputFile
import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
@ -23,7 +25,7 @@ fun InputMediaAnimation(
fun InputMediaAnimation( fun InputMediaAnimation(
file: InputFile, file: InputFile,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
width: Int? = null, width: Int? = null,
height: Int? = null, height: Int? = null,
duration: Long? = null, duration: Long? = null,
@ -45,7 +47,7 @@ data class InputMediaAnimation internal constructor(
override val thumb: InputFile? = null override val thumb: InputFile? = null
) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, TextedOutput { ) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, TextedOutput {
override val type: String = "animation" override val type: String = "animation"
override val textSources: List<TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }

View File

@ -15,7 +15,7 @@ internal const val audioInputMediaType = "audio"
fun InputMediaAudio( fun InputMediaAudio(
file: InputFile, file: InputFile,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
duration: Long? = null, duration: Long? = null,
performer: String? = null, performer: String? = null,
title: String? = null, title: String? = null,
@ -51,7 +51,7 @@ data class InputMediaAudio internal constructor(
override val thumb: InputFile? = null override val thumb: InputFile? = null
) : InputMedia, AudioMediaGroupMemberInputMedia, DuratedInputMedia, ThumbedInputMedia, TitledInputMedia, Performerable { ) : InputMedia, AudioMediaGroupMemberInputMedia, DuratedInputMedia, ThumbedInputMedia, TitledInputMedia, Performerable {
override val type: String = audioInputMediaType override val type: String = audioInputMediaType
override val textSources: List<TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }

View File

@ -1,10 +1,11 @@
package dev.inmo.tgbotapi.types.InputMedia package dev.inmo.tgbotapi.types.InputMedia
import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.CommonAbstracts.makeString
import dev.inmo.tgbotapi.requests.abstracts.* import dev.inmo.tgbotapi.requests.abstracts.*
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.files.DocumentFile import dev.inmo.tgbotapi.types.files.DocumentFile
@ -22,7 +23,7 @@ fun InputMediaDocument(
fun InputMediaDocument( fun InputMediaDocument(
file: InputFile, file: InputFile,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
thumb: InputFile? = null, thumb: InputFile? = null,
disableContentTypeDetection: Boolean? = null disableContentTypeDetection: Boolean? = null
) = InputMediaDocument(file, entities.makeString(), null, entities.toRawMessageEntities(), thumb, disableContentTypeDetection) ) = InputMediaDocument(file, entities.makeString(), null, entities.toRawMessageEntities(), thumb, disableContentTypeDetection)
@ -51,7 +52,7 @@ data class InputMediaDocument internal constructor(
val disableContentTypeDetection: Boolean? = null val disableContentTypeDetection: Boolean? = null
) : InputMedia, DocumentMediaGroupMemberInputMedia, ThumbedInputMedia { ) : InputMedia, DocumentMediaGroupMemberInputMedia, ThumbedInputMedia {
override val type: String = documentInputMediaType override val type: String = documentInputMediaType
override val textSources: List<TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }

View File

@ -1,11 +1,12 @@
package dev.inmo.tgbotapi.types.InputMedia package dev.inmo.tgbotapi.types.InputMedia
import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.CommonAbstracts.makeString
import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.abstracts.InputFile
import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import dev.inmo.tgbotapi.types.files.PhotoSize import dev.inmo.tgbotapi.types.files.PhotoSize
@ -21,7 +22,7 @@ fun InputMediaPhoto(
fun InputMediaPhoto( fun InputMediaPhoto(
file: InputFile, file: InputFile,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource> entities: TextSourcesList
) = InputMediaPhoto(file, entities.makeString(), null, entities.toRawMessageEntities()) ) = InputMediaPhoto(file, entities.makeString(), null, entities.toRawMessageEntities())
@Serializable @Serializable
@ -35,7 +36,7 @@ data class InputMediaPhoto internal constructor(
private val rawEntities: List<RawMessageEntity>? = null private val rawEntities: List<RawMessageEntity>? = null
) : InputMedia, VisualMediaGroupMemberInputMedia { ) : InputMedia, VisualMediaGroupMemberInputMedia {
override val type: String = photoInputMediaType override val type: String = photoInputMediaType
override val textSources: List<TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }

View File

@ -1,12 +1,13 @@
package dev.inmo.tgbotapi.types.InputMedia package dev.inmo.tgbotapi.types.InputMedia
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.descriptors.* import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.encoding.Encoder
@Serializer(InputMedia::class) @RiskFeature
internal object InputMediaSerializer : KSerializer<InputMedia> { object InputMediaSerializer : KSerializer<InputMedia> {
@InternalSerializationApi @InternalSerializationApi
override val descriptor: SerialDescriptor = buildSerialDescriptor(InputMedia::class.toString(), PolymorphicKind.OPEN) override val descriptor: SerialDescriptor = buildSerialDescriptor(InputMedia::class.toString(), PolymorphicKind.OPEN)
override fun serialize(encoder: Encoder, value: InputMedia) { override fun serialize(encoder: Encoder, value: InputMedia) {

View File

@ -5,6 +5,8 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile
import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.ParseMode.parseModeField import dev.inmo.tgbotapi.types.ParseMode.parseModeField
import kotlinx.serialization.* import kotlinx.serialization.*
@ -23,7 +25,7 @@ fun InputMediaVideo(
fun InputMediaVideo( fun InputMediaVideo(
file: InputFile, file: InputFile,
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>, entities: TextSourcesList,
width: Int? = null, width: Int? = null,
height: Int? = null, height: Int? = null,
duration: Long? = null, duration: Long? = null,
@ -45,7 +47,7 @@ data class InputMediaVideo internal constructor (
override val thumb: InputFile? = null override val thumb: InputFile? = null
) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, VisualMediaGroupMemberInputMedia { ) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, VisualMediaGroupMemberInputMedia {
override val type: String = videoInputMediaType override val type: String = videoInputMediaType
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)
} }

View File

@ -1,6 +1,7 @@
package dev.inmo.tgbotapi.types.InputMedia package dev.inmo.tgbotapi.types.InputMedia
import dev.inmo.tgbotapi.types.typeField import dev.inmo.tgbotapi.types.typeField
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.descriptors.* import kotlinx.serialization.descriptors.*
@ -8,8 +9,8 @@ import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.* import kotlinx.serialization.json.*
@Serializer(MediaGroupMemberInputMedia::class) @RiskFeature
internal object MediaGroupMemberInputMediaSerializer : KSerializer<MediaGroupMemberInputMedia> { object MediaGroupMemberInputMediaSerializer : KSerializer<MediaGroupMemberInputMedia> {
@InternalSerializationApi @InternalSerializationApi
override val descriptor: SerialDescriptor = buildSerialDescriptor(MediaGroupMemberInputMedia::class.toString(), PolymorphicKind.OPEN) override val descriptor: SerialDescriptor = buildSerialDescriptor(MediaGroupMemberInputMedia::class.toString(), PolymorphicKind.OPEN)
override fun serialize(encoder: Encoder, value: MediaGroupMemberInputMedia) { override fun serialize(encoder: Encoder, value: MediaGroupMemberInputMedia) {
@ -32,4 +33,4 @@ internal object MediaGroupMemberInputMediaSerializer : KSerializer<MediaGroupMem
else -> error("Illegal type of incoming MediaGroupMemberInputMedia") else -> error("Illegal type of incoming MediaGroupMemberInputMedia")
} }
} }
} }

View File

@ -1,6 +1,5 @@
package dev.inmo.tgbotapi.types.MessageEntity package dev.inmo.tgbotapi.types.MessageEntity
import dev.inmo.tgbotapi.CommonAbstracts.MultilevelTextSource
import dev.inmo.tgbotapi.types.MessageEntity.textsources.* import dev.inmo.tgbotapi.types.MessageEntity.textsources.*
import dev.inmo.tgbotapi.types.User import dev.inmo.tgbotapi.types.User
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@ -21,8 +20,8 @@ internal data class RawMessageEntity(
internal fun RawMessageEntity.asTextSource( internal fun RawMessageEntity.asTextSource(
source: String, source: String,
subParts: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource> subParts: TextSourcesList
): dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource { ): TextSource {
val sourceSubstring: String = source.substring(range) val sourceSubstring: String = source.substring(range)
val subPartsWithRegulars by lazy { val subPartsWithRegulars by lazy {
subParts.fillWithRegulars(sourceSubstring) subParts.fillWithRegulars(sourceSubstring)
@ -58,9 +57,9 @@ private inline operator fun <T : Comparable<T>> ClosedRange<T>.contains(other: C
return start <= other.start && endInclusive >= other.endInclusive return start <= other.start && endInclusive >= other.endInclusive
} }
internal fun List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>.fillWithRegulars(source: String): List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource> { internal fun TextSourcesList.fillWithRegulars(source: String): TextSourcesList {
var index = 0 var index = 0
val result = mutableListOf<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>() val result = mutableListOf<TextSource>()
for (i in 0 until size) { for (i in 0 until size) {
val textSource = get(i) val textSource = get(i)
val thisSourceInStart = source.startsWith(textSource.source, index) val thisSourceInStart = source.startsWith(textSource.source, index)
@ -83,9 +82,9 @@ internal fun List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>.
private fun createTextSources( private fun createTextSources(
originalFullString: String, originalFullString: String,
entities: RawMessageEntities entities: RawMessageEntities
): List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource> { ): TextSourcesList {
val mutableEntities = entities.toMutableList().apply { sortBy { it.offset } } val mutableEntities = entities.toMutableList().apply { sortBy { it.offset } }
val resultList = mutableListOf<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>() val resultList = mutableListOf<TextSource>()
while (mutableEntities.isNotEmpty()) { while (mutableEntities.isNotEmpty()) {
var parent = mutableEntities.removeFirst() var parent = mutableEntities.removeFirst()
@ -139,7 +138,7 @@ private fun createTextSources(
return resultList return resultList
} }
internal fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource.toRawMessageEntities(offset: Int = 0): List<RawMessageEntity> { internal fun TextSource.toRawMessageEntities(offset: Int = 0): List<RawMessageEntity> {
val source = source val source = source
val length = source.length val length = source.length
return listOfNotNull( return listOfNotNull(
@ -169,7 +168,7 @@ internal fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource.toRawM
} }
internal fun List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>.toRawMessageEntities(preOffset: Int = 0): List<RawMessageEntity> { internal fun TextSourcesList.toRawMessageEntities(preOffset: Int = 0): List<RawMessageEntity> {
var i = preOffset var i = preOffset
return flatMap { textSource -> return flatMap { textSource ->
textSource.toRawMessageEntities(i).also { textSource.toRawMessageEntities(i).also {
@ -184,9 +183,9 @@ fun String.removeLeading(word: String) = if (startsWith(word)) {
this this
} }
internal fun List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>.toRawMessageEntities(): List<RawMessageEntity> = toRawMessageEntities(0) internal fun TextSourcesList.toRawMessageEntities(): List<RawMessageEntity> = toRawMessageEntities(0)
internal fun RawMessageEntities.asTextSources(sourceString: String): List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource> = internal fun RawMessageEntities.asTextSources(sourceString: String): TextSourcesList =
createTextSources(sourceString, this).fillWithRegulars(sourceString) createTextSources(sourceString, this).fillWithRegulars(sourceString)
internal typealias RawMessageEntities = List<RawMessageEntity> internal typealias RawMessageEntities = List<RawMessageEntity>

View File

@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class BoldTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class BoldTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
override val source: String, override val source: String,
override val subsources: List<TextSource> override val subsources: TextSourcesList
) : MultilevelTextSource { ) : MultilevelTextSource {
override val markdown: String by lazy { source.boldMarkdown() } override val markdown: String by lazy { source.boldMarkdown() }
override val markdownV2: String by lazy { boldMarkdownV2() } override val markdownV2: String by lazy { boldMarkdownV2() }
@ -18,7 +18,7 @@ data class BoldTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor)
} }
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun bold(parts: List<TextSource>) = BoldTextSource(parts.makeString(), parts) inline fun bold(parts: TextSourcesList) = BoldTextSource(parts.makeString(), parts)
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun bold(vararg parts: TextSource) = bold(parts.toList()) inline fun bold(vararg parts: TextSource) = bold(parts.toList())
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")

View File

@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class CashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class CashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
override val source: String, override val source: String,
override val subsources: List<TextSource> override val subsources: TextSourcesList
) : MultilevelTextSource { ) : MultilevelTextSource {
override val markdown: String by lazy { source.cashTagMarkdown() } override val markdown: String by lazy { source.cashTagMarkdown() }
override val markdownV2: String by lazy { cashTagMarkdownV2() } override val markdownV2: String by lazy { cashTagMarkdownV2() }
@ -18,7 +18,7 @@ data class CashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo
} }
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun cashTag(parts: List<TextSource>) = CashTagTextSource(parts.makeString(), parts) inline fun cashTag(parts: TextSourcesList) = CashTagTextSource(parts.makeString(), parts)
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun cashTag(vararg parts: TextSource) = cashTag(parts.toList()) inline fun cashTag(vararg parts: TextSource) = cashTag(parts.toList())
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")

View File

@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class EMailTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class EMailTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
override val source: String, override val source: String,
override val subsources: List<TextSource> override val subsources: TextSourcesList
) : MultilevelTextSource { ) : MultilevelTextSource {
override val markdown: String by lazy { source.emailMarkdown() } override val markdown: String by lazy { source.emailMarkdown() }
override val markdownV2: String by lazy { emailMarkdownV2(source) } override val markdownV2: String by lazy { emailMarkdownV2(source) }
@ -18,7 +18,7 @@ data class EMailTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor)
} }
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun email(parts: List<TextSource>) = EMailTextSource(parts.makeString(), parts) inline fun email(parts: TextSourcesList) = EMailTextSource(parts.makeString(), parts)
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun email(vararg parts: TextSource) = email(parts.toList()) inline fun email(vararg parts: TextSource) = email(parts.toList())
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")

View File

@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class HashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class HashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
override val source: String, override val source: String,
override val subsources: List<TextSource> override val subsources: TextSourcesList
) : MultilevelTextSource { ) : MultilevelTextSource {
override val markdown: String by lazy { source.hashTagMarkdown() } override val markdown: String by lazy { source.hashTagMarkdown() }
override val markdownV2: String by lazy { hashTagMarkdownV2() } override val markdownV2: String by lazy { hashTagMarkdownV2() }
@ -24,7 +24,7 @@ data class HashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo
} }
@Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_API_USAGE") @Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_API_USAGE")
inline fun hashtag(parts: List<TextSource>) = (regular("#") + parts).let { HashTagTextSource(it.makeString(), it) } inline fun hashtag(parts: TextSourcesList) = (regular("#") + parts).let { HashTagTextSource(it.makeString(), it) }
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun hashtag(vararg parts: TextSource) = hashtag(parts.toList()) inline fun hashtag(vararg parts: TextSource) = hashtag(parts.toList())
/** /**

View File

@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class ItalicTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class ItalicTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
override val source: String, override val source: String,
override val subsources: List<TextSource> override val subsources: TextSourcesList
) : MultilevelTextSource { ) : MultilevelTextSource {
override val markdown: String by lazy { source.italicMarkdown() } override val markdown: String by lazy { source.italicMarkdown() }
override val markdownV2: String by lazy { italicMarkdownV2() } override val markdownV2: String by lazy { italicMarkdownV2() }
@ -18,7 +18,7 @@ data class ItalicTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor
} }
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun italic(parts: List<TextSource>) = ItalicTextSource(parts.makeString(), parts) inline fun italic(parts: TextSourcesList) = ItalicTextSource(parts.makeString(), parts)
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun italic(vararg parts: TextSource) = italic(parts.toList()) inline fun italic(vararg parts: TextSource) = italic(parts.toList())
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")

View File

@ -17,7 +17,7 @@ private val String.withoutCommercialAt
@Serializable @Serializable
data class MentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class MentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
override val source: String, override val source: String,
override val subsources: List<TextSource> override val subsources: TextSourcesList
) : MultilevelTextSource { ) : MultilevelTextSource {
override val markdown: String by lazy { source.mentionMarkdown() } override val markdown: String by lazy { source.mentionMarkdown() }
override val markdownV2: String by lazy { mentionMarkdownV2() } override val markdownV2: String by lazy { mentionMarkdownV2() }
@ -31,7 +31,7 @@ data class MentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo
} }
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun mention(parts: List<TextSource>) = (regular("@") + parts).let { MentionTextSource(it.makeString(), it) } inline fun mention(parts: TextSourcesList) = (regular("@") + parts).let { MentionTextSource(it.makeString(), it) }
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun mention(vararg parts: TextSource) = mention(parts.toList()) inline fun mention(vararg parts: TextSource) = mention(parts.toList())

View File

@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class PhoneNumberTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class PhoneNumberTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
override val source: String, override val source: String,
override val subsources: List<TextSource> override val subsources: TextSourcesList
) : MultilevelTextSource { ) : MultilevelTextSource {
override val markdown: String by lazy { source.phoneMarkdown() } override val markdown: String by lazy { source.phoneMarkdown() }
override val markdownV2: String by lazy { phoneMarkdownV2() } override val markdownV2: String by lazy { phoneMarkdownV2() }
@ -18,7 +18,7 @@ data class PhoneNumberTextSource @RiskFeature(DirectInvocationOfTextSourceConstr
} }
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun phone(parts: List<TextSource>) = PhoneNumberTextSource(parts.makeString(), parts) inline fun phone(parts: TextSourcesList) = PhoneNumberTextSource(parts.makeString(), parts)
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun phone(vararg parts: TextSource) = phone(parts.toList()) inline fun phone(vararg parts: TextSource) = phone(parts.toList())
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")

View File

@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class StrikethroughTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class StrikethroughTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
override val source: String, override val source: String,
override val subsources: List<TextSource> override val subsources: TextSourcesList
) : MultilevelTextSource { ) : MultilevelTextSource {
override val html: String by lazy { strikethroughHTML() } override val html: String by lazy { strikethroughHTML() }
override val markdownV2: String by lazy { strikethroughMarkdownV2() } override val markdownV2: String by lazy { strikethroughMarkdownV2() }
@ -18,7 +18,7 @@ data class StrikethroughTextSource @RiskFeature(DirectInvocationOfTextSourceCons
} }
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun strikethrough(parts: List<TextSource>) = StrikethroughTextSource(parts.makeString(), parts) inline fun strikethrough(parts: TextSourcesList) = StrikethroughTextSource(parts.makeString(), parts)
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun strikethrough(vararg parts: TextSource) = strikethrough(parts.toList()) inline fun strikethrough(vararg parts: TextSource) = strikethrough(parts.toList())
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")

View File

@ -12,7 +12,7 @@ import kotlinx.serialization.Serializable
data class TextMentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class TextMentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
override val source: String, override val source: String,
val user: User, val user: User,
override val subsources: List<TextSource> override val subsources: TextSourcesList
) : MultilevelTextSource { ) : MultilevelTextSource {
override val markdown: String by lazy { source.textMentionMarkdown(user.id) } override val markdown: String by lazy { source.textMentionMarkdown(user.id) }
override val markdownV2: String by lazy { textMentionMarkdownV2(user.id) } override val markdownV2: String by lazy { textMentionMarkdownV2(user.id) }
@ -20,17 +20,17 @@ data class TextMentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstr
} }
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun mention(parts: List<TextSource>, user: User) = TextMentionTextSource(parts.makeString(), user, parts) inline fun mention(parts: TextSourcesList, user: User) = TextMentionTextSource(parts.makeString(), user, parts)
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun User.mention(parts: List<TextSource>) = mention(parts, this) inline fun User.mention(parts: TextSourcesList) = mention(parts, this)
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun mention(parts: List<TextSource>, userId: UserId) = mention(parts, CommonUser(userId, "")) inline fun mention(parts: TextSourcesList, userId: UserId) = mention(parts, CommonUser(userId, ""))
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun UserId.mention(parts: List<TextSource>) = mention(parts, this) inline fun UserId.mention(parts: TextSourcesList) = mention(parts, this)
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun mention(parts: List<TextSource>, id: Identifier) = mention(parts, UserId(id)) inline fun mention(parts: TextSourcesList, id: Identifier) = mention(parts, UserId(id))
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun Identifier.mention(parts: List<TextSource>) = mention(parts, this) inline fun Identifier.mention(parts: TextSourcesList) = mention(parts, this)
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun mention(user: User, vararg parts: TextSource) = mention(parts.toList(), user) inline fun mention(user: User, vararg parts: TextSource) = mention(parts.toList(), user)
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")

View File

@ -7,6 +7,7 @@ import kotlinx.serialization.Serializable
const val DirectInvocationOfTextSourceConstructor = "It is strongly not recommended to use constructors directly instead of factory methods" const val DirectInvocationOfTextSourceConstructor = "It is strongly not recommended to use constructors directly instead of factory methods"
typealias TextSourcesList = List<TextSource> typealias TextSourcesList = List<TextSource>
typealias MutableTextSourcesList = MutableList<TextSource>
@Serializable(TextSourceSerializer::class) @Serializable(TextSourceSerializer::class)
sealed interface TextSource { sealed interface TextSource {

View File

@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class UnderlineTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor ( data class UnderlineTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
override val source: String, override val source: String,
override val subsources: List<TextSource> override val subsources: TextSourcesList
) : MultilevelTextSource { ) : MultilevelTextSource {
override val markdown: String by lazy { source.underlineMarkdown() } override val markdown: String by lazy { source.underlineMarkdown() }
override val markdownV2: String by lazy { underlineMarkdownV2() } override val markdownV2: String by lazy { underlineMarkdownV2() }
@ -18,7 +18,7 @@ data class UnderlineTextSource @RiskFeature(DirectInvocationOfTextSourceConstruc
} }
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun underline(parts: List<TextSource>) = UnderlineTextSource(parts.makeString(), parts) inline fun underline(parts: TextSourcesList) = UnderlineTextSource(parts.makeString(), parts)
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun underline(vararg parts: TextSource) = underline(parts.toList()) inline fun underline(vararg parts: TextSource) = underline(parts.toList())
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")

View File

@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.ParseMode package dev.inmo.tgbotapi.types.ParseMode
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.descriptors.SerialDescriptor
@ -45,8 +46,8 @@ typealias HTML = HTMLParseMode
*/ */
var defaultParseMode: ParseMode = HTML var defaultParseMode: ParseMode = HTML
@Serializer(ParseMode::class) @RiskFeature
internal object ParseModeSerializerObject : KSerializer<ParseMode> { object ParseModeSerializerObject : KSerializer<ParseMode> {
override val descriptor: SerialDescriptor = String.serializer().descriptor override val descriptor: SerialDescriptor = String.serializer().descriptor
override fun deserialize(decoder: Decoder): ParseMode { override fun deserialize(decoder: Decoder): ParseMode {
return when (decoder.decodeString()) { return when (decoder.decodeString()) {

View File

@ -1,9 +1,13 @@
package dev.inmo.tgbotapi.types package dev.inmo.tgbotapi.types
import com.soywiz.klock.DateTime import com.soywiz.klock.DateTime
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.JsonPrimitive
@Serializable(TelegramDateSerializer::class) @Serializable(TelegramDateSerializer::class)
data class TelegramDate( data class TelegramDate(
@ -24,8 +28,10 @@ data class TelegramDate(
fun DateTime.toTelegramDate(): TelegramDate = TelegramDate(this) fun DateTime.toTelegramDate(): TelegramDate = TelegramDate(this)
@Serializer(TelegramDate::class) @RiskFeature
internal object TelegramDateSerializer : KSerializer<TelegramDate> { object TelegramDateSerializer : KSerializer<TelegramDate> {
override val descriptor: SerialDescriptor = Long.serializer().descriptor
override fun serialize(encoder: Encoder, value: TelegramDate) { override fun serialize(encoder: Encoder, value: TelegramDate) {
encoder.encodeLong( encoder.encodeLong(
value.date value.date

View File

@ -2,9 +2,10 @@ package dev.inmo.tgbotapi.types
import dev.inmo.tgbotapi.types.chat.abstracts.PrivateChat import dev.inmo.tgbotapi.types.chat.abstracts.PrivateChat
import dev.inmo.tgbotapi.types.chat.extended.ExtendedPrivateChatImpl import dev.inmo.tgbotapi.types.chat.extended.ExtendedPrivateChatImpl
import dev.inmo.tgbotapi.utils.PreviewFeature import dev.inmo.tgbotapi.utils.*
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.* import kotlinx.serialization.json.*
@ -68,10 +69,12 @@ data class ExtendedBot(
} }
@Serializer(User::class) @RiskFeature
internal object UserSerializer : KSerializer<User> { object UserSerializer : KSerializer<User> {
private val internalSerializer = JsonObject.serializer()
override val descriptor: SerialDescriptor = internalSerializer.descriptor
override fun deserialize(decoder: Decoder): User { override fun deserialize(decoder: Decoder): User {
val asJson = JsonObject.serializer().deserialize(decoder) val asJson = internalSerializer.deserialize(decoder)
return when { return when {
asJson[isBotField] ?.jsonPrimitive ?.booleanOrNull != true -> nonstrictJsonFormat.decodeFromJsonElement( asJson[isBotField] ?.jsonPrimitive ?.booleanOrNull != true -> nonstrictJsonFormat.decodeFromJsonElement(

View File

@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types
import dev.inmo.tgbotapi.types.files.Photo import dev.inmo.tgbotapi.types.files.Photo
import dev.inmo.tgbotapi.types.files.PhotoSerializer import dev.inmo.tgbotapi.types.files.PhotoSerializer
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.builtins.ListSerializer
@ -13,6 +14,7 @@ data class UserProfilePhotos (
val photos: List<Photo> val photos: List<Photo>
) )
internal object UserProfilePhotosPhotosSerializer : KSerializer<List<Photo>> by ListSerializer( @RiskFeature
object UserProfilePhotosPhotosSerializer : KSerializer<List<Photo>> by ListSerializer(
PhotoSerializer PhotoSerializer
) )

View File

@ -14,8 +14,7 @@ sealed interface BotAction {
val actionName: String val actionName: String
} }
@Serializer(BotAction::class) object BotActionSerializer: KSerializer<BotAction> {
internal object BotActionSerializer: KSerializer<BotAction> {
override val descriptor: SerialDescriptor = String.serializer().descriptor override val descriptor: SerialDescriptor = String.serializer().descriptor
override fun serialize(encoder: Encoder, value: BotAction) { override fun serialize(encoder: Encoder, value: BotAction) {

View File

@ -1,6 +1,7 @@
package dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons package dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
import kotlinx.serialization.InternalSerializationApi import kotlinx.serialization.InternalSerializationApi
import kotlinx.serialization.KSerializer import kotlinx.serialization.KSerializer
@ -10,7 +11,8 @@ import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonObject
internal object InlineKeyboardButtonSerializer : KSerializer<InlineKeyboardButton> { @RiskFeature
object InlineKeyboardButtonSerializer : KSerializer<InlineKeyboardButton> {
@InternalSerializationApi @InternalSerializationApi
override val descriptor: SerialDescriptor = buildSerialDescriptor( override val descriptor: SerialDescriptor = buildSerialDescriptor(
"dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton", "dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton",

View File

@ -1,6 +1,7 @@
package dev.inmo.tgbotapi.types.buttons package dev.inmo.tgbotapi.types.buttons
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.descriptors.SerialDescriptor
@ -47,8 +48,8 @@ data class RequestPollKeyboardButton(
val requestPoll: KeyboardButtonPollType val requestPoll: KeyboardButtonPollType
) : KeyboardButton ) : KeyboardButton
@Serializer(KeyboardButton::class) @RiskFeature
internal object KeyboardButtonSerializer : KSerializer<KeyboardButton> { object KeyboardButtonSerializer : KSerializer<KeyboardButton> {
private val internalSerializer = JsonElement.serializer() private val internalSerializer = JsonElement.serializer()
override val descriptor: SerialDescriptor = internalSerializer.descriptor override val descriptor: SerialDescriptor = internalSerializer.descriptor

View File

@ -1,6 +1,7 @@
package dev.inmo.tgbotapi.types.buttons package dev.inmo.tgbotapi.types.buttons
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Decoder
@ -25,8 +26,8 @@ object QuizKeyboardButtonPollType : KeyboardButtonPollType {
override val type: String = quizPollType override val type: String = quizPollType
} }
@Serializer(KeyboardButtonPollType::class) @RiskFeature
internal object KeyboardButtonPollTypeSerializer : KSerializer<KeyboardButtonPollType> { object KeyboardButtonPollTypeSerializer : KSerializer<KeyboardButtonPollType> {
private val internalSerializer = JsonElement.serializer() private val internalSerializer = JsonElement.serializer()
override val descriptor: SerialDescriptor = internalSerializer.descriptor override val descriptor: SerialDescriptor = internalSerializer.descriptor

View File

@ -1,12 +1,13 @@
package dev.inmo.tgbotapi.types.buttons package dev.inmo.tgbotapi.types.buttons
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.descriptors.* import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.encoding.Encoder
@Serializer(KeyboardMarkup::class) @RiskFeature
internal object KeyboardMarkupSerializer : KSerializer<KeyboardMarkup> { object KeyboardMarkupSerializer : KSerializer<KeyboardMarkup> {
@InternalSerializationApi @InternalSerializationApi
override val descriptor: SerialDescriptor = buildSerialDescriptor( override val descriptor: SerialDescriptor = buildSerialDescriptor(
KeyboardMarkup::class.toString(), KeyboardMarkup::class.toString(),

View File

@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.types.chat.abstracts.UnknownChatType
import dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat import dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat
import dev.inmo.tgbotapi.types.chat.abstracts.extended.UnknownExtendedChat import dev.inmo.tgbotapi.types.chat.abstracts.extended.UnknownExtendedChat
import dev.inmo.tgbotapi.types.chat.extended.* import dev.inmo.tgbotapi.types.chat.extended.*
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer import kotlinx.serialization.builtins.serializer
@ -39,7 +40,6 @@ val String.asChatType
ChatType.ChannelChatType.stringified -> ChatType.ChannelChatType ChatType.ChannelChatType.stringified -> ChatType.ChannelChatType
else -> ChatType.UnknownChatType(this) else -> ChatType.UnknownChatType(this)
} }
@Serializer(ChatType::class)
object ChatTypeSerializer : KSerializer<ChatType> { object ChatTypeSerializer : KSerializer<ChatType> {
override val descriptor: SerialDescriptor = String.serializer().descriptor override val descriptor: SerialDescriptor = String.serializer().descriptor
override fun deserialize(decoder: Decoder): ChatType { override fun deserialize(decoder: Decoder): ChatType {
@ -51,7 +51,8 @@ object ChatTypeSerializer : KSerializer<ChatType> {
} }
} }
internal object PreviewChatSerializer : KSerializer<Chat> { @RiskFeature
object PreviewChatSerializer : KSerializer<Chat> {
@InternalSerializationApi @InternalSerializationApi
override val descriptor: SerialDescriptor = buildSerialDescriptor("PreviewChatSerializer", PolymorphicKind.OPEN) override val descriptor: SerialDescriptor = buildSerialDescriptor("PreviewChatSerializer", PolymorphicKind.OPEN)
@ -83,7 +84,8 @@ internal object PreviewChatSerializer : KSerializer<Chat> {
} }
} }
internal object ExtendedChatSerializer : KSerializer<ExtendedChat> { @RiskFeature
object ExtendedChatSerializer : KSerializer<ExtendedChat> {
@InternalSerializationApi @InternalSerializationApi
override val descriptor: SerialDescriptor = buildSerialDescriptor("PreviewChatSerializer", PolymorphicKind.OPEN) override val descriptor: SerialDescriptor = buildSerialDescriptor("PreviewChatSerializer", PolymorphicKind.OPEN)

View File

@ -1,6 +1,7 @@
package dev.inmo.tgbotapi.types.dice package dev.inmo.tgbotapi.types.dice
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.descriptors.* import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Decoder
@ -55,8 +56,8 @@ data class CustomDiceAnimationType(
get() = error("Custom dice animation type have unknown value limits") get() = error("Custom dice animation type have unknown value limits")
} }
@Serializer(DiceAnimationType::class) @RiskFeature
internal object DiceAnimationTypeSerializer : KSerializer<DiceAnimationType> { object DiceAnimationTypeSerializer : KSerializer<DiceAnimationType> {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("DiceAnimationType", PrimitiveKind.STRING) override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("DiceAnimationType", PrimitiveKind.STRING)
override fun deserialize(decoder: Decoder): DiceAnimationType { override fun deserialize(decoder: Decoder): DiceAnimationType {
return when (val type = decoder.decodeString()) { return when (val type = decoder.decodeString()) {

View File

@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.FileUniqueId import dev.inmo.tgbotapi.types.FileUniqueId
import dev.inmo.tgbotapi.types.fileUniqueIdField import dev.inmo.tgbotapi.types.fileUniqueIdField
import dev.inmo.tgbotapi.types.files.abstracts.* import dev.inmo.tgbotapi.types.files.abstracts.*
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.builtins.ListSerializer
@ -13,7 +14,8 @@ fun Photo.biggest(): PhotoSize? = maxByOrNull {
it.resolution it.resolution
} }
internal object PhotoSerializer : KSerializer<Photo> by ListSerializer( @RiskFeature
object PhotoSerializer : KSerializer<Photo> by ListSerializer(
PhotoSize.serializer() PhotoSize.serializer()
) )

View File

@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InputMedia.InputMediaVideo import dev.inmo.tgbotapi.types.InputMedia.InputMediaVideo
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.ParseMode.ParseMode
import dev.inmo.tgbotapi.types.files.abstracts.* import dev.inmo.tgbotapi.types.files.abstracts.*
import dev.inmo.tgbotapi.utils.MimeType import dev.inmo.tgbotapi.utils.MimeType

View File

@ -1,6 +1,7 @@
package dev.inmo.tgbotapi.types.games package dev.inmo.tgbotapi.types.games
import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.CommonAbstracts.TextedInput
import dev.inmo.tgbotapi.CommonAbstracts.Titled
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.files.AnimationFile import dev.inmo.tgbotapi.types.files.AnimationFile
import dev.inmo.tgbotapi.types.files.Photo import dev.inmo.tgbotapi.types.files.Photo

View File

@ -39,7 +39,6 @@ data class LiveLocation(
override val proximityAlertRadius: Meters? = null override val proximityAlertRadius: Meters? = null
) : Location, Livable, ProximityAlertable, Headed ) : Location, Livable, ProximityAlertable, Headed
@Serializer(Location::class)
object LocationSerializer : KSerializer<Location> { object LocationSerializer : KSerializer<Location> {
private val internalSerializer = JsonObject.serializer() private val internalSerializer = JsonObject.serializer()
override val descriptor: SerialDescriptor = internalSerializer.descriptor override val descriptor: SerialDescriptor = internalSerializer.descriptor

View File

@ -31,8 +31,6 @@ internal class TelegramBotAPIMessageDeserializationStrategyClass<T> : Deserializ
return RawMessage.serializer().deserialize(decoder).asMessage as T return RawMessage.serializer().deserialize(decoder).asMessage as T
} }
} }
internal object TelegramBotAPIMessageDeserializationStrategy
: DeserializationStrategy<Message> by TelegramBotAPIMessageDeserializationStrategyClass()
internal class TelegramBotAPIMessageDeserializeOnlySerializerClass<T : Message> : KSerializer<T> { internal class TelegramBotAPIMessageDeserializeOnlySerializerClass<T : Message> : KSerializer<T> {
private val deserializer = TelegramBotAPIMessageDeserializationStrategyClass<T>() private val deserializer = TelegramBotAPIMessageDeserializationStrategyClass<T>()

View File

@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.TextedInput
import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.requests.send.SendTextMessage import dev.inmo.tgbotapi.requests.send.SendTextMessage
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.MessageIdentifier
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage

View File

@ -1,6 +1,5 @@
package dev.inmo.tgbotapi.types.message.content.abstracts package dev.inmo.tgbotapi.types.message.content.abstracts
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedInput
import dev.inmo.tgbotapi.CommonAbstracts.TextedInput import dev.inmo.tgbotapi.CommonAbstracts.TextedInput
import dev.inmo.tgbotapi.types.InputMedia.* import dev.inmo.tgbotapi.types.InputMedia.*

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.message.content.media package dev.inmo.tgbotapi.types.message.content.media
import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.CommonAbstracts.TextedInput
import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.requests.send.media.SendAnimation import dev.inmo.tgbotapi.requests.send.media.SendAnimation
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier

View File

@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.send.media.SendAudio
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.InputMedia.InputMediaAudio import dev.inmo.tgbotapi.types.InputMedia.InputMediaAudio
import dev.inmo.tgbotapi.types.InputMedia.toInputMediaAudio import dev.inmo.tgbotapi.types.InputMedia.toInputMediaAudio
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.MessageIdentifier
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.files.AudioFile import dev.inmo.tgbotapi.types.files.AudioFile

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.message.content.media package dev.inmo.tgbotapi.types.message.content.media
import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.CommonAbstracts.TextedInput
import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.requests.send.media.SendVoice import dev.inmo.tgbotapi.requests.send.media.SendVoice
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier

View File

@ -35,7 +35,6 @@ val encryptedElementsClassesByTypes = mapOf(
val EncryptedPassportElement.type: String val EncryptedPassportElement.type: String
get() = encryptedElementsClassesByTypes.keys.firstOrNull { encryptedElementsClassesByTypes.getValue(it).klass.isInstance(this) } ?: "unknown" get() = encryptedElementsClassesByTypes.keys.firstOrNull { encryptedElementsClassesByTypes.getValue(it).klass.isInstance(this) } ?: "unknown"
@Serializer(EncryptedPassportElement::class)
object EncryptedElementSerializer : KSerializer<EncryptedPassportElement> { object EncryptedElementSerializer : KSerializer<EncryptedPassportElement> {
private val jsonSerializer = JsonObject.serializer() private val jsonSerializer = JsonObject.serializer()
override val descriptor: SerialDescriptor = jsonSerializer.descriptor override val descriptor: SerialDescriptor = jsonSerializer.descriptor

View File

@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.payments
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.payments.abstracts.Priced import dev.inmo.tgbotapi.types.payments.abstracts.Priced
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.builtins.ListSerializer
@ -16,6 +17,7 @@ data class ShippingOption(
override val prices: List<LabeledPrice> override val prices: List<LabeledPrice>
) : Priced ) : Priced
internal object LabeledPricesSerializer : KSerializer<List<LabeledPrice>> by ListSerializer( @RiskFeature
object LabeledPricesSerializer : KSerializer<List<LabeledPrice>> by ListSerializer(
LabeledPrice.serializer() LabeledPrice.serializer()
) )

View File

@ -2,10 +2,11 @@ package dev.inmo.tgbotapi.types.polls
import com.soywiz.klock.DateTime import com.soywiz.klock.DateTime
import com.soywiz.klock.TimeSpan import com.soywiz.klock.TimeSpan
import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.CommonAbstracts.TextedInput
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.* import dev.inmo.tgbotapi.types.MessageEntity.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.descriptors.SerialDescriptor
@ -142,8 +143,8 @@ data class QuizPoll(
override val scheduledCloseInfo: ScheduledCloseInfo? = null override val scheduledCloseInfo: ScheduledCloseInfo? = null
) : Poll, TextedInput ) : Poll, TextedInput
@Serializer(Poll::class) @RiskFeature
internal object PollSerializer : KSerializer<Poll> { object PollSerializer : KSerializer<Poll> {
override val descriptor: SerialDescriptor override val descriptor: SerialDescriptor
get() = RawPoll.serializer().descriptor get() = RawPoll.serializer().descriptor

View File

@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.polls
import dev.inmo.tgbotapi.types.textField import dev.inmo.tgbotapi.types.textField
import dev.inmo.tgbotapi.types.votesCountField import dev.inmo.tgbotapi.types.votesCountField
import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Decoder
@ -21,7 +22,8 @@ data class SimplePollOption (
override val votes: Int override val votes: Int
) : PollOption() ) : PollOption()
internal object PollOptionSerializer : KSerializer<PollOption> { @RiskFeature
object PollOptionSerializer : KSerializer<PollOption> {
override val descriptor: SerialDescriptor = SimplePollOption.serializer().descriptor override val descriptor: SerialDescriptor = SimplePollOption.serializer().descriptor
override fun deserialize(decoder: Decoder): PollOption = SimplePollOption.serializer().deserialize( override fun deserialize(decoder: Decoder): PollOption = SimplePollOption.serializer().deserialize(

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types.update package dev.inmo.tgbotapi.types.update
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery
import dev.inmo.tgbotapi.types.UpdateIdentifier import dev.inmo.tgbotapi.types.UpdateIdentifier
import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.types.update.abstracts.Update

View File

@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.update.abstracts
import dev.inmo.tgbotapi.types.UpdateIdentifier import dev.inmo.tgbotapi.types.UpdateIdentifier
import dev.inmo.tgbotapi.types.update.RawUpdate import dev.inmo.tgbotapi.types.update.RawUpdate
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.descriptors.SerialDescriptor
@ -20,7 +21,8 @@ data class UnknownUpdate(
val rawJson: JsonElement val rawJson: JsonElement
) : Update ) : Update
internal object UpdateSerializerWithoutSerialization : KSerializer<Update> { @RiskFeature
object UpdateSerializerWithoutSerialization : KSerializer<Update> {
override val descriptor: SerialDescriptor = JsonElement.serializer().descriptor override val descriptor: SerialDescriptor = JsonElement.serializer().descriptor
override fun deserialize(decoder: Decoder): Update = UpdateDeserializationStrategy.deserialize(decoder) override fun deserialize(decoder: Decoder): Update = UpdateDeserializationStrategy.deserialize(decoder)

View File

@ -19,8 +19,8 @@ fun buildMimeType(raw: String): MimeType = mimesCache.getOrPut(raw) {
createMimeType(raw) createMimeType(raw)
} }
@Serializer(MimeType::class) @RiskFeature
internal object MimeTypeSerializer : KSerializer<MimeType> { object MimeTypeSerializer : KSerializer<MimeType> {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("mimeType", PrimitiveKind.STRING) override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("mimeType", PrimitiveKind.STRING)
override fun deserialize(decoder: Decoder): MimeType { override fun deserialize(decoder: Decoder): MimeType {

View File

@ -1,16 +1,16 @@
package dev.inmo.tgbotapi.utils.internal package dev.inmo.tgbotapi.utils.internal
import dev.inmo.tgbotapi.CommonAbstracts.MultilevelTextSource import dev.inmo.tgbotapi.types.MessageEntity.textsources.*
import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.link import dev.inmo.tgbotapi.types.link
import dev.inmo.tgbotapi.utils.extensions.escapeMarkdownV2Link import dev.inmo.tgbotapi.utils.extensions.escapeMarkdownV2Link
import dev.inmo.tgbotapi.utils.extensions.toHtml import dev.inmo.tgbotapi.utils.extensions.toHtml
private fun List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>.joinSubSourcesMarkdownV2() = joinToString("") { private fun TextSourcesList.joinSubSourcesMarkdownV2() = joinToString("") {
it.markdownV2 it.markdownV2
} }
private fun List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>.joinSubSourcesHtml() = joinToString("") { private fun TextSourcesList.joinSubSourcesHtml() = joinToString("") {
it.html it.html
} }

View File

@ -9,6 +9,7 @@ import kotlin.test.assertEquals
class BotActionTests { class BotActionTests {
@Serializable @Serializable
data class Example( data class Example(
@Serializable(BotActionSerializer::class)
val botAction: BotAction val botAction: BotAction
) )

Some files were not shown because too many files have changed in this diff Show More