mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-22 16:47:13 +00:00
buildable except of jvm tests
This commit is contained in:
parent
72c3623d30
commit
5c0e58caec
1
.github/write-good.yml
vendored
1
.github/write-good.yml
vendored
@ -1 +0,0 @@
|
||||
spellchecker: true
|
@ -26,7 +26,7 @@ repositories {
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
js(BOTH) {
|
||||
js(IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
|
@ -29,10 +29,8 @@ repositories {
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
compilations.main.kotlinOptions.useIR = true
|
||||
}
|
||||
js(BOTH) {
|
||||
jvm()
|
||||
js(IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
|
@ -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.TextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.captionLength
|
||||
import dev.inmo.tgbotapi.types.textLength
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.makeString
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForCaption
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForMessage
|
||||
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 =
|
||||
"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")
|
||||
@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
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@ -40,7 +40,7 @@ inline operator fun dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@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(
|
||||
"Replaced",
|
||||
@ -49,13 +49,13 @@ inline operator fun List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextS
|
||||
typealias MultilevelTextSource = MultilevelTextSource
|
||||
|
||||
@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(
|
||||
"Replaced",
|
||||
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)
|
||||
|
||||
/**
|
||||
|
@ -8,9 +8,9 @@ interface 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 {
|
||||
@ -18,7 +18,7 @@ interface ParsableOutput : Texted {
|
||||
}
|
||||
|
||||
interface EntitiesOutput : TextedWithTextSources {
|
||||
val entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>?
|
||||
val entities: List<TextSource>?
|
||||
get() = textSources
|
||||
}
|
||||
|
||||
@ -26,11 +26,4 @@ interface TextedOutput : ParsableOutput, EntitiesOutput
|
||||
|
||||
interface TextedInput : TextedWithTextSources {
|
||||
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()
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.polls.Poll
|
||||
import dev.inmo.tgbotapi.types.polls.PollSerializer
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
@ -19,7 +20,7 @@ data class StopPoll(
|
||||
) : MessageAction, SimpleRequest<Poll>, ReplyMarkup {
|
||||
override fun method(): String = "stopPoll"
|
||||
override val resultDeserializer: DeserializationStrategy<Poll>
|
||||
get() = Poll.serializer()
|
||||
get() = PollSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.requests.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.StorageFile
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.*
|
||||
@ -30,8 +31,8 @@ data class FileId(
|
||||
|
||||
fun String.toInputFile() = FileId(this)
|
||||
|
||||
@Serializer(InputFile::class)
|
||||
internal object InputFileSerializer : KSerializer<InputFile> {
|
||||
@RiskFeature
|
||||
object InputFileSerializer : KSerializer<InputFile> {
|
||||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor(FileId::class.toString(), PrimitiveKind.STRING)
|
||||
override fun serialize(encoder: Encoder, value: InputFile) = encoder.encodeString(value.fileId)
|
||||
override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString())
|
||||
|
@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
||||
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.builtins.ListSerializer
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
@ -26,7 +26,7 @@ data class AnswerInlineQuery(
|
||||
val switchPmText: String? = null,
|
||||
@SerialName(switchPmParameterField)
|
||||
val switchPmParameter: String? = null
|
||||
): SimpleRequest<Boolean> {
|
||||
) : SimpleRequest<Boolean> {
|
||||
override fun method(): String = "answerInlineQuery"
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
@ -34,7 +34,7 @@ data class AnswerInlineQuery(
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
fun InlineQuery.createAnswer(
|
||||
fun dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery.createAnswer(
|
||||
results: List<InlineQueryResult> = emptyList(),
|
||||
cachedTime: Int? = null,
|
||||
isPersonal: Boolean? = null,
|
||||
@ -51,6 +51,7 @@ fun InlineQuery.createAnswer(
|
||||
switchPmParameter
|
||||
)
|
||||
|
||||
internal object InlineQueryAnswersResultsSerializer: KSerializer<List<InlineQueryResult>> by ListSerializer(
|
||||
@RiskFeature
|
||||
object InlineQueryAnswersResultsSerializer : KSerializer<List<InlineQueryResult>> by ListSerializer(
|
||||
InlineQueryResultSerializer
|
||||
)
|
||||
|
@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.requests.answers.payments.abstracts.AnswerShippingQuery
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.payments.ShippingOption
|
||||
import dev.inmo.tgbotapi.types.payments.ShippingQuery
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.ListSerializer
|
||||
|
||||
@ -21,7 +22,8 @@ data class AnswerShippingQueryOk(
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
internal object ShippingOptionsSerializer : KSerializer<List<ShippingOption>> by ListSerializer(
|
||||
@RiskFeature
|
||||
object ShippingOptionsSerializer : KSerializer<List<ShippingOption>> by ListSerializer(
|
||||
ShippingOption.serializer()
|
||||
)
|
||||
|
||||
|
@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.edit.abstracts.*
|
||||
import dev.inmo.tgbotapi.requests.edit.media.MediaContentMessageResultDeserializer
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@ -32,7 +33,7 @@ fun EditChatMessageCaption(
|
||||
fun EditChatMessageCaption(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = EditChatMessageCaption(
|
||||
chatId,
|
||||
@ -58,7 +59,7 @@ data class EditChatMessageCaption internal constructor(
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : 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)
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||
import dev.inmo.tgbotapi.requests.edit.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@ -24,7 +25,7 @@ fun EditInlineMessageCaption(
|
||||
|
||||
fun EditInlineMessageCaption(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = EditInlineMessageCaption(
|
||||
inlineMessageId,
|
||||
@ -47,7 +48,7 @@ data class EditInlineMessageCaption internal constructor(
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : 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)
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.edit.abstracts.*
|
||||
import dev.inmo.tgbotapi.requests.send.TextContentMessageResultDeserializer
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@ -34,7 +35,7 @@ fun EditChatMessageText(
|
||||
fun EditChatMessageText(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = EditChatMessageText(
|
||||
@ -64,7 +65,7 @@ data class EditChatMessageText internal constructor(
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : 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)
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||
import dev.inmo.tgbotapi.requests.edit.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@ -26,7 +27,7 @@ fun EditInlineMessageText(
|
||||
|
||||
fun EditInlineMessageText(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = EditInlineMessageText(
|
||||
@ -53,7 +54,7 @@ data class EditInlineMessageText internal constructor(
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : 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)
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.requests.games.abstracts
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.games.GameHighScore
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.builtins.ListSerializer
|
||||
@ -15,4 +16,5 @@ interface GetGameHighScores : SimpleRequest<List<GameHighScore>> {
|
||||
get() = GameHighScoresSerializer
|
||||
}
|
||||
|
||||
internal object GameHighScoresSerializer : KSerializer<List<GameHighScore>> by ListSerializer(GameHighScore.serializer())
|
||||
@RiskFeature
|
||||
object GameHighScoresSerializer : KSerializer<List<GameHighScore>> by ListSerializer(GameHighScore.serializer())
|
||||
|
@ -1,6 +1,7 @@
|
||||
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.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest
|
||||
@ -28,7 +29,7 @@ fun CopyMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: List<TextSource>,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
|
@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.types.DisableWebPagePreview
|
||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
@ -40,7 +41,7 @@ fun SendTextMessage(
|
||||
|
||||
fun SendTextMessage(
|
||||
chatId: ChatIdentifier,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
@ -83,7 +84,7 @@ data class SendTextMessage internal constructor(
|
||||
TextableSendMessageRequest<ContentMessage<TextContent>>,
|
||||
DisableWebPagePreview
|
||||
{
|
||||
override val textSources: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>? by lazy {
|
||||
override val textSources: TextSourcesList? by lazy {
|
||||
rawEntities ?.asTextSources(text)
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
@ -65,7 +66,7 @@ fun SendAnimation(
|
||||
chatId: ChatIdentifier,
|
||||
animation: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@ -144,7 +145,7 @@ data class SendAnimationData internal constructor(
|
||||
DuratedSendMessageRequest<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)
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
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.send.abstracts.*
|
||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||
@ -66,7 +67,7 @@ fun SendAudio(
|
||||
chatId: ChatIdentifier,
|
||||
audio: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: List<TextSource>,
|
||||
duration: Long? = null,
|
||||
performer: String? = null,
|
||||
title: String? = null,
|
||||
|
@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
@ -79,7 +80,7 @@ fun SendDocument(
|
||||
chatId: ChatIdentifier,
|
||||
document: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
@ -157,7 +158,7 @@ data class SendDocumentData internal constructor(
|
||||
TextableSendMessageRequest<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)
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
@ -47,7 +48,7 @@ fun SendPhoto(
|
||||
fun SendPhoto(
|
||||
chatId: ChatIdentifier,
|
||||
photo: InputFile,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
@ -100,7 +101,7 @@ data class SendPhotoData internal constructor(
|
||||
ReplyingMarkupSendMessageRequest<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)
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
@ -67,7 +68,7 @@ fun SendVideo(
|
||||
chatId: ChatIdentifier,
|
||||
video: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
@ -150,7 +151,7 @@ data class SendVideoData internal constructor(
|
||||
DuratedSendMessageRequest<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)
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
@ -56,7 +57,7 @@ fun SendVoice(
|
||||
fun SendVoice(
|
||||
chatId: ChatIdentifier,
|
||||
voice: InputFile,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
duration: Long? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
@ -120,7 +121,7 @@ data class SendVoiceData internal constructor(
|
||||
TextableSendMessageRequest<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)
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
package dev.inmo.tgbotapi.requests.send.polls
|
||||
|
||||
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.SendMessageRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
@ -268,7 +269,7 @@ fun SendQuizPoll(
|
||||
correctOptionId: Int,
|
||||
isAnonymous: Boolean = true,
|
||||
isClosed: Boolean = false,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: List<TextSource>,
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
|
@ -1,7 +1,9 @@
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import dev.inmo.micro_utils.common.Warning
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import kotlinx.serialization.json.JsonPrimitive
|
||||
@ -52,10 +54,12 @@ data class Username(
|
||||
|
||||
fun String.toUsername(): Username = Username(this)
|
||||
|
||||
@Serializer(ChatIdentifier::class)
|
||||
internal object ChatIdentifierSerializer : KSerializer<ChatIdentifier> {
|
||||
@RiskFeature
|
||||
object ChatIdentifierSerializer : KSerializer<ChatIdentifier> {
|
||||
private val internalSerializer = JsonPrimitive.serializer()
|
||||
override val descriptor: SerialDescriptor = internalSerializer.descriptor
|
||||
override fun deserialize(decoder: Decoder): ChatIdentifier {
|
||||
val id = JsonPrimitive.serializer().deserialize(decoder)
|
||||
val id = internalSerializer.deserialize(decoder)
|
||||
return id.longOrNull ?.let {
|
||||
ChatId(it)
|
||||
} ?: id.content.let {
|
||||
@ -73,4 +77,4 @@ internal object ChatIdentifierSerializer : KSerializer<ChatIdentifier> {
|
||||
is Username -> encoder.encodeString(value.username)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,6 @@ data class CommonInviteLink(
|
||||
get() = expireDate ?.asDate
|
||||
}
|
||||
|
||||
@Serializer(ChatInviteLink::class)
|
||||
object ChatInviteLinkSerializer : KSerializer<ChatInviteLink> {
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = RawChatInviteLink.serializer().descriptor
|
||||
|
@ -1,7 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.ChatMember
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember
|
||||
import dev.inmo.tgbotapi.types.ChatMember.abstracts.MemberChatMember
|
||||
import kotlinx.serialization.*
|
||||
|
||||
|
@ -20,7 +20,6 @@ interface AdministratorChatMember : SpecialRightsChatMember {
|
||||
val customTitle: String?
|
||||
}
|
||||
|
||||
@Serializer(AdministratorChatMember::class)
|
||||
@RiskFeature
|
||||
object AdministratorChatMemberSerializer : KSerializer<AdministratorChatMember> {
|
||||
override val descriptor: SerialDescriptor = ChatMemberSerializer.descriptor
|
||||
|
@ -17,7 +17,6 @@ sealed interface ChatMember {
|
||||
val user: User
|
||||
}
|
||||
|
||||
@Serializer(ChatMember::class)
|
||||
@RiskFeature
|
||||
object ChatMemberSerializer : KSerializer<ChatMember> {
|
||||
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")) {
|
||||
"creator" -> nonstrictJsonFormat.decodeFromJsonElement(CreatorChatMember.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)
|
||||
"left" -> nonstrictJsonFormat.decodeFromJsonElement(LeftChatMember.serializer(), json)
|
||||
"left" -> nonstrictJsonFormat.decodeFromJsonElement(LeftChatMemberImpl.serializer(), json)
|
||||
"kicked" -> nonstrictJsonFormat.decodeFromJsonElement(KickedChatMember.serializer(), json)
|
||||
else -> error("Unknown type of chat member in json: $json")
|
||||
}
|
||||
@ -39,9 +38,9 @@ object ChatMemberSerializer : KSerializer<ChatMember> {
|
||||
when (value) {
|
||||
is CreatorChatMember -> CreatorChatMember.serializer()
|
||||
is AdministratorChatMemberImpl -> AdministratorChatMemberImpl.serializer()
|
||||
is MemberChatMember -> MemberChatMember.serializer()
|
||||
is MemberChatMember -> MemberChatMemberImpl.serializer()
|
||||
is RestrictedChatMember -> RestrictedChatMember.serializer()
|
||||
is LeftChatMember -> LeftChatMember.serializer()
|
||||
is LeftChatMember -> LeftChatMemberImpl.serializer()
|
||||
is KickedChatMember -> KickedChatMember.serializer()
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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 kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
@ -36,4 +36,4 @@ class InlineQueryResultArticle(
|
||||
WithInputMessageContentInlineQueryResult,
|
||||
UrlInlineQueryResult {
|
||||
override val type: String = "article"
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,9 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
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.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.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@ -25,7 +26,7 @@ fun InlineQueryResultAudioCachedImpl(
|
||||
fun InlineQueryResultAudioCachedImpl(
|
||||
id: InlineQueryIdentifier,
|
||||
fileId: FileId,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
inputMessageContent: InputMessageContent? = null
|
||||
) = InlineQueryResultAudioCachedImpl(id, fileId, entities.makeString(), null, entities.toRawMessageEntities(), replyMarkup, inputMessageContent)
|
||||
@ -48,7 +49,7 @@ data class InlineQueryResultAudioCachedImpl internal constructor(
|
||||
override val inputMessageContent: InputMessageContent? = null
|
||||
) : InlineQueryResultAudioCached {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||
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.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.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@ -30,7 +31,7 @@ fun InlineQueryResultAudioImpl(
|
||||
title: String,
|
||||
performer: String? = null,
|
||||
duration: Int? = null,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
inputMessageContent: InputMessageContent? = null
|
||||
) = 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
|
||||
) : InlineQueryResultAudio {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.CommonContactData
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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 kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -5,8 +5,10 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
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.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.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@ -29,7 +31,7 @@ fun InlineQueryResultDocumentCachedImpl(
|
||||
fileId: FileId,
|
||||
title: String,
|
||||
description: String? = null,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
inputMessageContent: InputMessageContent? = null
|
||||
) = 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
|
||||
) : InlineQueryResultDocumentCached {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||
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.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.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@ -38,7 +39,7 @@ fun InlineQueryResultDocumentImpl(
|
||||
thumbWidth: Int? = null,
|
||||
thumbHeight: Int? = null,
|
||||
description: String? = null,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
inputMessageContent: InputMessageContent? = null
|
||||
) = 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
|
||||
) : InlineQueryResultDocument {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,9 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
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.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.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@ -27,7 +28,7 @@ fun InlineQueryResultGifCachedImpl(
|
||||
id: InlineQueryIdentifier,
|
||||
fileId: FileId,
|
||||
title: String? = null,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
inputMessageContent: InputMessageContent? = null
|
||||
) = 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
|
||||
) : InlineQueryResultGifCached {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||
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.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.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@ -37,7 +38,7 @@ fun InlineQueryResultGifImpl(
|
||||
height: Int? = null,
|
||||
duration: Int? = null,
|
||||
title: String? = null,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
inputMessageContent: InputMessageContent? = null
|
||||
) = 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
|
||||
) : InlineQueryResultGif {
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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 kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -5,8 +5,9 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
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.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.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@ -27,7 +28,7 @@ fun InlineQueryResultMpeg4GifCachedImpl(
|
||||
id: InlineQueryIdentifier,
|
||||
fileId: FileId,
|
||||
title: String? = null,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
inputMessageContent: InputMessageContent? = null
|
||||
) = 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
|
||||
) : InlineQueryResultMpeg4GifCached {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||
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.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.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@ -37,7 +38,7 @@ fun InlineQueryResultMpeg4GifImpl(
|
||||
height: Int? = null,
|
||||
duration: Int? = null,
|
||||
title: String? = null,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
inputMessageContent: InputMessageContent? = null
|
||||
) = 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
|
||||
) : InlineQueryResultMpeg4Gif {
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,9 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
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.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.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@ -29,7 +30,7 @@ fun InlineQueryResultPhotoCachedImpl(
|
||||
fileId: FileId,
|
||||
title: String? = null,
|
||||
description: String? = null,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
inputMessageContent: InputMessageContent? = null
|
||||
) = 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
|
||||
) : InlineQueryResultPhotoCached {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||
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.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.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@ -34,7 +35,7 @@ fun InlineQueryResultPhotoImpl(
|
||||
height: Int? = null,
|
||||
title: String? = null,
|
||||
description: String? = null,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
inputMessageContent: InputMessageContent? = null
|
||||
) = 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
|
||||
) : InlineQueryResultPhoto {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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 kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.CommonVenueData
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.Locationed
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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 kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -5,8 +5,9 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
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.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.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@ -29,7 +30,7 @@ fun InlineQueryResultVideoCachedImpl(
|
||||
fileId: FileId,
|
||||
title: String,
|
||||
description: String? = null,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
inputMessageContent: InputMessageContent? = null
|
||||
) = 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
|
||||
) : InlineQueryResultVideoCached {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,9 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||
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.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.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@ -40,7 +41,7 @@ fun InlineQueryResultVideoImpl(
|
||||
height: Int? = null,
|
||||
duration: Int? = null,
|
||||
description: String? = null,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: List<TextSource>,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
inputMessageContent: InputMessageContent? = null
|
||||
) = 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
|
||||
) : InlineQueryResultVideo {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,10 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
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.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.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@ -27,7 +29,7 @@ fun InlineQueryResultVoiceCachedImpl(
|
||||
id: InlineQueryIdentifier,
|
||||
fileId: FileId,
|
||||
title: String,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
inputMessageContent: InputMessageContent? = null
|
||||
) = 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
|
||||
) : InlineQueryResultVoiceCached {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,10 @@ import dev.inmo.tgbotapi.CommonAbstracts.makeString
|
||||
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.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.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.ParseMode.parseModeField
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@ -38,7 +40,7 @@ fun InlineQueryResultVoiceImpl(
|
||||
url: String,
|
||||
title: String,
|
||||
duration: Int? = null,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
inputMessageContent: InputMessageContent? = null
|
||||
) = 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
|
||||
) : InlineQueryResultVoice {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 {
|
||||
val inputMessageContent: InputMessageContent?
|
||||
|
@ -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.abstracts.InlineQueryResult
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.*
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@Serializer(InlineQueryResult::class)
|
||||
internal object InlineQueryResultSerializer : KSerializer<InlineQueryResult> {
|
||||
@RiskFeature
|
||||
object InlineQueryResultSerializer : KSerializer<InlineQueryResult> {
|
||||
@InternalSerializationApi
|
||||
override val descriptor: SerialDescriptor = buildSerialDescriptor(InlineQueryResult::class.toString(), PolymorphicKind.OPEN)
|
||||
override fun serialize(encoder: Encoder, value: InlineQueryResult) {
|
||||
@ -39,4 +40,4 @@ internal object InlineQueryResultSerializer : KSerializer<InlineQueryResult> {
|
||||
override fun deserialize(decoder: Decoder): InlineQueryResult {
|
||||
throw TODO()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
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.types.*
|
||||
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.parseModeField
|
||||
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.
|
||||
*/
|
||||
fun InputTextMessageContent(
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null
|
||||
) = InputTextMessageContent(entities.makeString(), null, entities.toRawMessageEntities(), disableWebPagePreview)
|
||||
|
||||
@ -38,7 +39,7 @@ data class InputTextMessageContent internal constructor(
|
||||
@SerialName(disableWebPagePreviewField)
|
||||
override val disableWebPagePreview: Boolean? = null
|
||||
) : TextedOutput, DisableWebPagePreview, InputMessageContent {
|
||||
override val textSources: List<TextSource>? by lazy {
|
||||
override val textSources: TextSourcesList? by lazy {
|
||||
rawEntities ?.asTextSources(text)
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
package dev.inmo.tgbotapi.types.InlineQueries
|
||||
|
||||
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.descriptors.*
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@Serializer(InputMessageContent::class)
|
||||
internal object InputMessageContentSerializer : KSerializer<InputMessageContent> {
|
||||
@RiskFeature
|
||||
object InputMessageContentSerializer : KSerializer<InputMessageContent> {
|
||||
@InternalSerializationApi
|
||||
override val descriptor: SerialDescriptor = buildSerialDescriptor(InputMessageContent::class.toString(), PolymorphicKind.OPEN)
|
||||
override fun serialize(encoder: Encoder, value: InputMessageContent) {
|
||||
|
@ -1,11 +1,13 @@
|
||||
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.fileIdToSend
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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.parseModeField
|
||||
import kotlinx.serialization.SerialName
|
||||
@ -23,7 +25,7 @@ fun InputMediaAnimation(
|
||||
|
||||
fun InputMediaAnimation(
|
||||
file: InputFile,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
duration: Long? = null,
|
||||
@ -45,7 +47,7 @@ data class InputMediaAnimation internal constructor(
|
||||
override val thumb: InputFile? = null
|
||||
) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, TextedOutput {
|
||||
override val type: String = "animation"
|
||||
override val textSources: List<TextSource>? by lazy {
|
||||
override val textSources: TextSourcesList? by lazy {
|
||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ internal const val audioInputMediaType = "audio"
|
||||
|
||||
fun InputMediaAudio(
|
||||
file: InputFile,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
duration: Long? = null,
|
||||
performer: String? = null,
|
||||
title: String? = null,
|
||||
@ -51,7 +51,7 @@ data class InputMediaAudio internal constructor(
|
||||
override val thumb: InputFile? = null
|
||||
) : InputMedia, AudioMediaGroupMemberInputMedia, DuratedInputMedia, ThumbedInputMedia, TitledInputMedia, Performerable {
|
||||
override val type: String = audioInputMediaType
|
||||
override val textSources: List<TextSource>? by lazy {
|
||||
override val textSources: TextSourcesList? by lazy {
|
||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
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.types.*
|
||||
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.parseModeField
|
||||
import dev.inmo.tgbotapi.types.files.DocumentFile
|
||||
@ -22,7 +23,7 @@ fun InputMediaDocument(
|
||||
|
||||
fun InputMediaDocument(
|
||||
file: InputFile,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
thumb: InputFile? = null,
|
||||
disableContentTypeDetection: Boolean? = null
|
||||
) = InputMediaDocument(file, entities.makeString(), null, entities.toRawMessageEntities(), thumb, disableContentTypeDetection)
|
||||
@ -51,7 +52,7 @@ data class InputMediaDocument internal constructor(
|
||||
val disableContentTypeDetection: Boolean? = null
|
||||
) : InputMedia, DocumentMediaGroupMemberInputMedia, ThumbedInputMedia {
|
||||
override val type: String = documentInputMediaType
|
||||
override val textSources: List<TextSource>? by lazy {
|
||||
override val textSources: TextSourcesList? by lazy {
|
||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
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.fileIdToSend
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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.parseModeField
|
||||
import dev.inmo.tgbotapi.types.files.PhotoSize
|
||||
@ -21,7 +22,7 @@ fun InputMediaPhoto(
|
||||
|
||||
fun InputMediaPhoto(
|
||||
file: InputFile,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>
|
||||
entities: TextSourcesList
|
||||
) = InputMediaPhoto(file, entities.makeString(), null, entities.toRawMessageEntities())
|
||||
|
||||
@Serializable
|
||||
@ -35,7 +36,7 @@ data class InputMediaPhoto internal constructor(
|
||||
private val rawEntities: List<RawMessageEntity>? = null
|
||||
) : InputMedia, VisualMediaGroupMemberInputMedia {
|
||||
override val type: String = photoInputMediaType
|
||||
override val textSources: List<TextSource>? by lazy {
|
||||
override val textSources: TextSourcesList? by lazy {
|
||||
rawEntities ?.asTextSources(text ?: return@lazy null)
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
package dev.inmo.tgbotapi.types.InputMedia
|
||||
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.*
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@Serializer(InputMedia::class)
|
||||
internal object InputMediaSerializer : KSerializer<InputMedia> {
|
||||
@RiskFeature
|
||||
object InputMediaSerializer : KSerializer<InputMedia> {
|
||||
@InternalSerializationApi
|
||||
override val descriptor: SerialDescriptor = buildSerialDescriptor(InputMedia::class.toString(), PolymorphicKind.OPEN)
|
||||
override fun serialize(encoder: Encoder, value: InputMedia) {
|
||||
|
@ -5,6 +5,8 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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.parseModeField
|
||||
import kotlinx.serialization.*
|
||||
@ -23,7 +25,7 @@ fun InputMediaVideo(
|
||||
|
||||
fun InputMediaVideo(
|
||||
file: InputFile,
|
||||
entities: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>,
|
||||
entities: TextSourcesList,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
duration: Long? = null,
|
||||
@ -45,7 +47,7 @@ data class InputMediaVideo internal constructor (
|
||||
override val thumb: InputFile? = null
|
||||
) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, VisualMediaGroupMemberInputMedia {
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.InputMedia
|
||||
|
||||
import dev.inmo.tgbotapi.types.typeField
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.*
|
||||
@ -8,8 +9,8 @@ import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import kotlinx.serialization.json.*
|
||||
|
||||
@Serializer(MediaGroupMemberInputMedia::class)
|
||||
internal object MediaGroupMemberInputMediaSerializer : KSerializer<MediaGroupMemberInputMedia> {
|
||||
@RiskFeature
|
||||
object MediaGroupMemberInputMediaSerializer : KSerializer<MediaGroupMemberInputMedia> {
|
||||
@InternalSerializationApi
|
||||
override val descriptor: SerialDescriptor = buildSerialDescriptor(MediaGroupMemberInputMedia::class.toString(), PolymorphicKind.OPEN)
|
||||
override fun serialize(encoder: Encoder, value: MediaGroupMemberInputMedia) {
|
||||
@ -32,4 +33,4 @@ internal object MediaGroupMemberInputMediaSerializer : KSerializer<MediaGroupMem
|
||||
else -> error("Illegal type of incoming MediaGroupMemberInputMedia")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package dev.inmo.tgbotapi.types.MessageEntity
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.MultilevelTextSource
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.*
|
||||
import dev.inmo.tgbotapi.types.User
|
||||
import kotlinx.serialization.Serializable
|
||||
@ -21,8 +20,8 @@ internal data class RawMessageEntity(
|
||||
|
||||
internal fun RawMessageEntity.asTextSource(
|
||||
source: String,
|
||||
subParts: List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>
|
||||
): dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource {
|
||||
subParts: TextSourcesList
|
||||
): TextSource {
|
||||
val sourceSubstring: String = source.substring(range)
|
||||
val subPartsWithRegulars by lazy {
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
val result = mutableListOf<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>()
|
||||
val result = mutableListOf<TextSource>()
|
||||
for (i in 0 until size) {
|
||||
val textSource = get(i)
|
||||
val thisSourceInStart = source.startsWith(textSource.source, index)
|
||||
@ -83,9 +82,9 @@ internal fun List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>.
|
||||
private fun createTextSources(
|
||||
originalFullString: String,
|
||||
entities: RawMessageEntities
|
||||
): List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource> {
|
||||
): TextSourcesList {
|
||||
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()) {
|
||||
var parent = mutableEntities.removeFirst()
|
||||
@ -139,7 +138,7 @@ private fun createTextSources(
|
||||
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 length = source.length
|
||||
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
|
||||
return flatMap { textSource ->
|
||||
textSource.toRawMessageEntities(i).also {
|
||||
@ -184,9 +183,9 @@ fun String.removeLeading(word: String) = if (startsWith(word)) {
|
||||
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)
|
||||
|
||||
internal typealias RawMessageEntities = List<RawMessageEntity>
|
||||
|
@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class BoldTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
|
||||
override val source: String,
|
||||
override val subsources: List<TextSource>
|
||||
override val subsources: TextSourcesList
|
||||
) : MultilevelTextSource {
|
||||
override val markdown: String by lazy { source.boldMarkdown() }
|
||||
override val markdownV2: String by lazy { boldMarkdownV2() }
|
||||
@ -18,7 +18,7 @@ data class BoldTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor)
|
||||
}
|
||||
|
||||
@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")
|
||||
inline fun bold(vararg parts: TextSource) = bold(parts.toList())
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
|
@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class CashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
|
||||
override val source: String,
|
||||
override val subsources: List<TextSource>
|
||||
override val subsources: TextSourcesList
|
||||
) : MultilevelTextSource {
|
||||
override val markdown: String by lazy { source.cashTagMarkdown() }
|
||||
override val markdownV2: String by lazy { cashTagMarkdownV2() }
|
||||
@ -18,7 +18,7 @@ data class CashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo
|
||||
}
|
||||
|
||||
@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")
|
||||
inline fun cashTag(vararg parts: TextSource) = cashTag(parts.toList())
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
|
@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class EMailTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
|
||||
override val source: String,
|
||||
override val subsources: List<TextSource>
|
||||
override val subsources: TextSourcesList
|
||||
) : MultilevelTextSource {
|
||||
override val markdown: String by lazy { source.emailMarkdown() }
|
||||
override val markdownV2: String by lazy { emailMarkdownV2(source) }
|
||||
@ -18,7 +18,7 @@ data class EMailTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor)
|
||||
}
|
||||
|
||||
@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")
|
||||
inline fun email(vararg parts: TextSource) = email(parts.toList())
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
|
@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class HashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
|
||||
override val source: String,
|
||||
override val subsources: List<TextSource>
|
||||
override val subsources: TextSourcesList
|
||||
) : MultilevelTextSource {
|
||||
override val markdown: String by lazy { source.hashTagMarkdown() }
|
||||
override val markdownV2: String by lazy { hashTagMarkdownV2() }
|
||||
@ -24,7 +24,7 @@ data class HashTagTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo
|
||||
}
|
||||
|
||||
@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")
|
||||
inline fun hashtag(vararg parts: TextSource) = hashtag(parts.toList())
|
||||
/**
|
||||
|
@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class ItalicTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
|
||||
override val source: String,
|
||||
override val subsources: List<TextSource>
|
||||
override val subsources: TextSourcesList
|
||||
) : MultilevelTextSource {
|
||||
override val markdown: String by lazy { source.italicMarkdown() }
|
||||
override val markdownV2: String by lazy { italicMarkdownV2() }
|
||||
@ -18,7 +18,7 @@ data class ItalicTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor
|
||||
}
|
||||
|
||||
@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")
|
||||
inline fun italic(vararg parts: TextSource) = italic(parts.toList())
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
|
@ -17,7 +17,7 @@ private val String.withoutCommercialAt
|
||||
@Serializable
|
||||
data class MentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
|
||||
override val source: String,
|
||||
override val subsources: List<TextSource>
|
||||
override val subsources: TextSourcesList
|
||||
) : MultilevelTextSource {
|
||||
override val markdown: String by lazy { source.mentionMarkdown() }
|
||||
override val markdownV2: String by lazy { mentionMarkdownV2() }
|
||||
@ -31,7 +31,7 @@ data class MentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo
|
||||
}
|
||||
|
||||
@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")
|
||||
inline fun mention(vararg parts: TextSource) = mention(parts.toList())
|
||||
|
||||
|
@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class PhoneNumberTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
|
||||
override val source: String,
|
||||
override val subsources: List<TextSource>
|
||||
override val subsources: TextSourcesList
|
||||
) : MultilevelTextSource {
|
||||
override val markdown: String by lazy { source.phoneMarkdown() }
|
||||
override val markdownV2: String by lazy { phoneMarkdownV2() }
|
||||
@ -18,7 +18,7 @@ data class PhoneNumberTextSource @RiskFeature(DirectInvocationOfTextSourceConstr
|
||||
}
|
||||
|
||||
@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")
|
||||
inline fun phone(vararg parts: TextSource) = phone(parts.toList())
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
|
@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class StrikethroughTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
|
||||
override val source: String,
|
||||
override val subsources: List<TextSource>
|
||||
override val subsources: TextSourcesList
|
||||
) : MultilevelTextSource {
|
||||
override val html: String by lazy { strikethroughHTML() }
|
||||
override val markdownV2: String by lazy { strikethroughMarkdownV2() }
|
||||
@ -18,7 +18,7 @@ data class StrikethroughTextSource @RiskFeature(DirectInvocationOfTextSourceCons
|
||||
}
|
||||
|
||||
@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")
|
||||
inline fun strikethrough(vararg parts: TextSource) = strikethrough(parts.toList())
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
|
@ -12,7 +12,7 @@ import kotlinx.serialization.Serializable
|
||||
data class TextMentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
|
||||
override val source: String,
|
||||
val user: User,
|
||||
override val subsources: List<TextSource>
|
||||
override val subsources: TextSourcesList
|
||||
) : MultilevelTextSource {
|
||||
override val markdown: String by lazy { source.textMentionMarkdown(user.id) }
|
||||
override val markdownV2: String by lazy { textMentionMarkdownV2(user.id) }
|
||||
@ -20,17 +20,17 @@ data class TextMentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstr
|
||||
}
|
||||
|
||||
@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")
|
||||
inline fun User.mention(parts: List<TextSource>) = mention(parts, this)
|
||||
inline fun User.mention(parts: TextSourcesList) = mention(parts, this)
|
||||
@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")
|
||||
inline fun UserId.mention(parts: List<TextSource>) = mention(parts, this)
|
||||
inline fun UserId.mention(parts: TextSourcesList) = mention(parts, this)
|
||||
@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")
|
||||
inline fun Identifier.mention(parts: List<TextSource>) = mention(parts, this)
|
||||
inline fun Identifier.mention(parts: TextSourcesList) = mention(parts, this)
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun mention(user: User, vararg parts: TextSource) = mention(parts.toList(), user)
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
|
@ -7,6 +7,7 @@ import kotlinx.serialization.Serializable
|
||||
const val DirectInvocationOfTextSourceConstructor = "It is strongly not recommended to use constructors directly instead of factory methods"
|
||||
|
||||
typealias TextSourcesList = List<TextSource>
|
||||
typealias MutableTextSourcesList = MutableList<TextSource>
|
||||
|
||||
@Serializable(TextSourceSerializer::class)
|
||||
sealed interface TextSource {
|
||||
|
@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class UnderlineTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
|
||||
override val source: String,
|
||||
override val subsources: List<TextSource>
|
||||
override val subsources: TextSourcesList
|
||||
) : MultilevelTextSource {
|
||||
override val markdown: String by lazy { source.underlineMarkdown() }
|
||||
override val markdownV2: String by lazy { underlineMarkdownV2() }
|
||||
@ -18,7 +18,7 @@ data class UnderlineTextSource @RiskFeature(DirectInvocationOfTextSourceConstruc
|
||||
}
|
||||
|
||||
@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")
|
||||
inline fun underline(vararg parts: TextSource) = underline(parts.toList())
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
|
@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.ParseMode
|
||||
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
@ -45,8 +46,8 @@ typealias HTML = HTMLParseMode
|
||||
*/
|
||||
var defaultParseMode: ParseMode = HTML
|
||||
|
||||
@Serializer(ParseMode::class)
|
||||
internal object ParseModeSerializerObject : KSerializer<ParseMode> {
|
||||
@RiskFeature
|
||||
object ParseModeSerializerObject : KSerializer<ParseMode> {
|
||||
override val descriptor: SerialDescriptor = String.serializer().descriptor
|
||||
override fun deserialize(decoder: Decoder): ParseMode {
|
||||
return when (decoder.decodeString()) {
|
||||
|
@ -1,9 +1,13 @@
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import kotlinx.serialization.json.JsonPrimitive
|
||||
|
||||
@Serializable(TelegramDateSerializer::class)
|
||||
data class TelegramDate(
|
||||
@ -24,8 +28,10 @@ data class TelegramDate(
|
||||
|
||||
fun DateTime.toTelegramDate(): TelegramDate = TelegramDate(this)
|
||||
|
||||
@Serializer(TelegramDate::class)
|
||||
internal object TelegramDateSerializer : KSerializer<TelegramDate> {
|
||||
@RiskFeature
|
||||
object TelegramDateSerializer : KSerializer<TelegramDate> {
|
||||
override val descriptor: SerialDescriptor = Long.serializer().descriptor
|
||||
|
||||
override fun serialize(encoder: Encoder, value: TelegramDate) {
|
||||
encoder.encodeLong(
|
||||
value.date
|
||||
|
@ -2,9 +2,10 @@ package dev.inmo.tgbotapi.types
|
||||
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PrivateChat
|
||||
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 kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import kotlinx.serialization.json.*
|
||||
@ -68,10 +69,12 @@ data class ExtendedBot(
|
||||
}
|
||||
|
||||
|
||||
@Serializer(User::class)
|
||||
internal object UserSerializer : KSerializer<User> {
|
||||
@RiskFeature
|
||||
object UserSerializer : KSerializer<User> {
|
||||
private val internalSerializer = JsonObject.serializer()
|
||||
override val descriptor: SerialDescriptor = internalSerializer.descriptor
|
||||
override fun deserialize(decoder: Decoder): User {
|
||||
val asJson = JsonObject.serializer().deserialize(decoder)
|
||||
val asJson = internalSerializer.deserialize(decoder)
|
||||
|
||||
return when {
|
||||
asJson[isBotField] ?.jsonPrimitive ?.booleanOrNull != true -> nonstrictJsonFormat.decodeFromJsonElement(
|
||||
|
@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types
|
||||
|
||||
import dev.inmo.tgbotapi.types.files.Photo
|
||||
import dev.inmo.tgbotapi.types.files.PhotoSerializer
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.ListSerializer
|
||||
|
||||
@ -13,6 +14,7 @@ data class UserProfilePhotos (
|
||||
val photos: List<Photo>
|
||||
)
|
||||
|
||||
internal object UserProfilePhotosPhotosSerializer : KSerializer<List<Photo>> by ListSerializer(
|
||||
@RiskFeature
|
||||
object UserProfilePhotosPhotosSerializer : KSerializer<List<Photo>> by ListSerializer(
|
||||
PhotoSerializer
|
||||
)
|
||||
|
@ -14,8 +14,7 @@ sealed interface BotAction {
|
||||
val actionName: String
|
||||
}
|
||||
|
||||
@Serializer(BotAction::class)
|
||||
internal object BotActionSerializer: KSerializer<BotAction> {
|
||||
object BotActionSerializer: KSerializer<BotAction> {
|
||||
override val descriptor: SerialDescriptor = String.serializer().descriptor
|
||||
|
||||
override fun serialize(encoder: Encoder, value: BotAction) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||
import kotlinx.serialization.InternalSerializationApi
|
||||
import kotlinx.serialization.KSerializer
|
||||
@ -10,7 +11,8 @@ import kotlinx.serialization.encoding.Encoder
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
internal object InlineKeyboardButtonSerializer : KSerializer<InlineKeyboardButton> {
|
||||
@RiskFeature
|
||||
object InlineKeyboardButtonSerializer : KSerializer<InlineKeyboardButton> {
|
||||
@InternalSerializationApi
|
||||
override val descriptor: SerialDescriptor = buildSerialDescriptor(
|
||||
"dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton",
|
||||
|
@ -1,6 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.buttons
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
@ -47,8 +48,8 @@ data class RequestPollKeyboardButton(
|
||||
val requestPoll: KeyboardButtonPollType
|
||||
) : KeyboardButton
|
||||
|
||||
@Serializer(KeyboardButton::class)
|
||||
internal object KeyboardButtonSerializer : KSerializer<KeyboardButton> {
|
||||
@RiskFeature
|
||||
object KeyboardButtonSerializer : KSerializer<KeyboardButton> {
|
||||
private val internalSerializer = JsonElement.serializer()
|
||||
override val descriptor: SerialDescriptor = internalSerializer.descriptor
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.buttons
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
@ -25,8 +26,8 @@ object QuizKeyboardButtonPollType : KeyboardButtonPollType {
|
||||
override val type: String = quizPollType
|
||||
}
|
||||
|
||||
@Serializer(KeyboardButtonPollType::class)
|
||||
internal object KeyboardButtonPollTypeSerializer : KSerializer<KeyboardButtonPollType> {
|
||||
@RiskFeature
|
||||
object KeyboardButtonPollTypeSerializer : KSerializer<KeyboardButtonPollType> {
|
||||
private val internalSerializer = JsonElement.serializer()
|
||||
override val descriptor: SerialDescriptor = internalSerializer.descriptor
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
package dev.inmo.tgbotapi.types.buttons
|
||||
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.*
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@Serializer(KeyboardMarkup::class)
|
||||
internal object KeyboardMarkupSerializer : KSerializer<KeyboardMarkup> {
|
||||
@RiskFeature
|
||||
object KeyboardMarkupSerializer : KSerializer<KeyboardMarkup> {
|
||||
@InternalSerializationApi
|
||||
override val descriptor: SerialDescriptor = buildSerialDescriptor(
|
||||
KeyboardMarkup::class.toString(),
|
||||
|
@ -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.UnknownExtendedChat
|
||||
import dev.inmo.tgbotapi.types.chat.extended.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
@ -39,7 +40,6 @@ val String.asChatType
|
||||
ChatType.ChannelChatType.stringified -> ChatType.ChannelChatType
|
||||
else -> ChatType.UnknownChatType(this)
|
||||
}
|
||||
@Serializer(ChatType::class)
|
||||
object ChatTypeSerializer : KSerializer<ChatType> {
|
||||
override val descriptor: SerialDescriptor = String.serializer().descriptor
|
||||
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
|
||||
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
|
||||
override val descriptor: SerialDescriptor = buildSerialDescriptor("PreviewChatSerializer", PolymorphicKind.OPEN)
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.dice
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.*
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
@ -55,8 +56,8 @@ data class CustomDiceAnimationType(
|
||||
get() = error("Custom dice animation type have unknown value limits")
|
||||
}
|
||||
|
||||
@Serializer(DiceAnimationType::class)
|
||||
internal object DiceAnimationTypeSerializer : KSerializer<DiceAnimationType> {
|
||||
@RiskFeature
|
||||
object DiceAnimationTypeSerializer : KSerializer<DiceAnimationType> {
|
||||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("DiceAnimationType", PrimitiveKind.STRING)
|
||||
override fun deserialize(decoder: Decoder): DiceAnimationType {
|
||||
return when (val type = decoder.decodeString()) {
|
||||
|
@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.types.FileUniqueId
|
||||
import dev.inmo.tgbotapi.types.fileUniqueIdField
|
||||
import dev.inmo.tgbotapi.types.files.abstracts.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.ListSerializer
|
||||
|
||||
@ -13,7 +14,8 @@ fun Photo.biggest(): PhotoSize? = maxByOrNull {
|
||||
it.resolution
|
||||
}
|
||||
|
||||
internal object PhotoSerializer : KSerializer<Photo> by ListSerializer(
|
||||
@RiskFeature
|
||||
object PhotoSerializer : KSerializer<Photo> by ListSerializer(
|
||||
PhotoSize.serializer()
|
||||
)
|
||||
|
||||
|
@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.types.files
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
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.files.abstracts.*
|
||||
import dev.inmo.tgbotapi.utils.MimeType
|
||||
|
@ -1,6 +1,7 @@
|
||||
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.files.AnimationFile
|
||||
import dev.inmo.tgbotapi.types.files.Photo
|
||||
|
@ -39,7 +39,6 @@ data class LiveLocation(
|
||||
override val proximityAlertRadius: Meters? = null
|
||||
) : Location, Livable, ProximityAlertable, Headed
|
||||
|
||||
@Serializer(Location::class)
|
||||
object LocationSerializer : KSerializer<Location> {
|
||||
private val internalSerializer = JsonObject.serializer()
|
||||
override val descriptor: SerialDescriptor = internalSerializer.descriptor
|
||||
|
@ -31,8 +31,6 @@ internal class TelegramBotAPIMessageDeserializationStrategyClass<T> : Deserializ
|
||||
return RawMessage.serializer().deserialize(decoder).asMessage as T
|
||||
}
|
||||
}
|
||||
internal object TelegramBotAPIMessageDeserializationStrategy
|
||||
: DeserializationStrategy<Message> by TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
internal class TelegramBotAPIMessageDeserializeOnlySerializerClass<T : Message> : KSerializer<T> {
|
||||
private val deserializer = TelegramBotAPIMessageDeserializationStrategyClass<T>()
|
||||
|
@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.CommonAbstracts.TextedInput
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.requests.send.SendTextMessage
|
||||
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.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
|
@ -1,6 +1,5 @@
|
||||
package dev.inmo.tgbotapi.types.message.content.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedInput
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.TextedInput
|
||||
import dev.inmo.tgbotapi.types.InputMedia.*
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
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.send.media.SendAnimation
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
|
@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.send.media.SendAudio
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.InputMedia.InputMediaAudio
|
||||
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.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.files.AudioFile
|
||||
|
@ -1,6 +1,6 @@
|
||||
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.send.media.SendVoice
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
|
@ -35,7 +35,6 @@ val encryptedElementsClassesByTypes = mapOf(
|
||||
val EncryptedPassportElement.type: String
|
||||
get() = encryptedElementsClassesByTypes.keys.firstOrNull { encryptedElementsClassesByTypes.getValue(it).klass.isInstance(this) } ?: "unknown"
|
||||
|
||||
@Serializer(EncryptedPassportElement::class)
|
||||
object EncryptedElementSerializer : KSerializer<EncryptedPassportElement> {
|
||||
private val jsonSerializer = JsonObject.serializer()
|
||||
override val descriptor: SerialDescriptor = jsonSerializer.descriptor
|
||||
|
@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.payments
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.payments.abstracts.Priced
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.ListSerializer
|
||||
|
||||
@ -16,6 +17,7 @@ data class ShippingOption(
|
||||
override val prices: List<LabeledPrice>
|
||||
) : Priced
|
||||
|
||||
internal object LabeledPricesSerializer : KSerializer<List<LabeledPrice>> by ListSerializer(
|
||||
@RiskFeature
|
||||
object LabeledPricesSerializer : KSerializer<List<LabeledPrice>> by ListSerializer(
|
||||
LabeledPrice.serializer()
|
||||
)
|
||||
|
@ -2,10 +2,11 @@ package dev.inmo.tgbotapi.types.polls
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
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.MessageEntity.*
|
||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
@ -142,8 +143,8 @@ data class QuizPoll(
|
||||
override val scheduledCloseInfo: ScheduledCloseInfo? = null
|
||||
) : Poll, TextedInput
|
||||
|
||||
@Serializer(Poll::class)
|
||||
internal object PollSerializer : KSerializer<Poll> {
|
||||
@RiskFeature
|
||||
object PollSerializer : KSerializer<Poll> {
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = RawPoll.serializer().descriptor
|
||||
|
||||
|
@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.polls
|
||||
|
||||
import dev.inmo.tgbotapi.types.textField
|
||||
import dev.inmo.tgbotapi.types.votesCountField
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
@ -21,7 +22,8 @@ data class SimplePollOption (
|
||||
override val votes: Int
|
||||
) : PollOption()
|
||||
|
||||
internal object PollOptionSerializer : KSerializer<PollOption> {
|
||||
@RiskFeature
|
||||
object PollOptionSerializer : KSerializer<PollOption> {
|
||||
override val descriptor: SerialDescriptor = SimplePollOption.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): PollOption = SimplePollOption.serializer().deserialize(
|
||||
|
@ -1,6 +1,6 @@
|
||||
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.update.abstracts.Update
|
||||
|
||||
|
@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.update.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||
import dev.inmo.tgbotapi.types.update.RawUpdate
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
@ -20,7 +21,8 @@ data class UnknownUpdate(
|
||||
val rawJson: JsonElement
|
||||
) : Update
|
||||
|
||||
internal object UpdateSerializerWithoutSerialization : KSerializer<Update> {
|
||||
@RiskFeature
|
||||
object UpdateSerializerWithoutSerialization : KSerializer<Update> {
|
||||
override val descriptor: SerialDescriptor = JsonElement.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): Update = UpdateDeserializationStrategy.deserialize(decoder)
|
||||
|
@ -19,8 +19,8 @@ fun buildMimeType(raw: String): MimeType = mimesCache.getOrPut(raw) {
|
||||
createMimeType(raw)
|
||||
}
|
||||
|
||||
@Serializer(MimeType::class)
|
||||
internal object MimeTypeSerializer : KSerializer<MimeType> {
|
||||
@RiskFeature
|
||||
object MimeTypeSerializer : KSerializer<MimeType> {
|
||||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("mimeType", PrimitiveKind.STRING)
|
||||
|
||||
override fun deserialize(decoder: Decoder): MimeType {
|
||||
|
@ -1,16 +1,16 @@
|
||||
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.link
|
||||
import dev.inmo.tgbotapi.utils.extensions.escapeMarkdownV2Link
|
||||
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
|
||||
}
|
||||
|
||||
private fun List<dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource>.joinSubSourcesHtml() = joinToString("") {
|
||||
private fun TextSourcesList.joinSubSourcesHtml() = joinToString("") {
|
||||
it.html
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import kotlin.test.assertEquals
|
||||
class BotActionTests {
|
||||
@Serializable
|
||||
data class Example(
|
||||
@Serializable(BotActionSerializer::class)
|
||||
val botAction: BotAction
|
||||
)
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user