mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-26 12:08:43 +00:00
new libraries versions adaptation
This commit is contained in:
parent
574ffbc44d
commit
6b3f836096
@ -39,6 +39,7 @@ kotlin {
|
|||||||
implementation kotlin('stdlib')
|
implementation kotlin('stdlib')
|
||||||
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$kotlin_coroutines_version"
|
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$kotlin_coroutines_version"
|
||||||
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$kotlin_serialisation_runtime_version"
|
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$kotlin_serialisation_runtime_version"
|
||||||
|
api "org.jetbrains.kotlinx:kotlinx-serialization-properties-common:$kotlin_serialisation_runtime_version"
|
||||||
|
|
||||||
api "com.soywiz.korlibs.klock:klock:$klock_version"
|
api "com.soywiz.korlibs.klock:klock:$klock_version"
|
||||||
api "com.benasher44:uuid:$uuid_version"
|
api "com.benasher44:uuid:$uuid_version"
|
||||||
@ -56,6 +57,7 @@ kotlin {
|
|||||||
jvmMain {
|
jvmMain {
|
||||||
dependencies {
|
dependencies {
|
||||||
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlin_serialisation_runtime_version"
|
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlin_serialisation_runtime_version"
|
||||||
|
api "org.jetbrains.kotlinx:kotlinx-serialization-properties:$kotlin_serialisation_runtime_version"
|
||||||
|
|
||||||
api "io.ktor:ktor-client:$ktor_version"
|
api "io.ktor:ktor-client:$ktor_version"
|
||||||
api "io.ktor:ktor-server:$ktor_version"
|
api "io.ktor:ktor-server:$ktor_version"
|
||||||
@ -73,6 +75,7 @@ kotlin {
|
|||||||
jsMain {
|
jsMain {
|
||||||
dependencies {
|
dependencies {
|
||||||
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$kotlin_serialisation_runtime_version"
|
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$kotlin_serialisation_runtime_version"
|
||||||
|
api "org.jetbrains.kotlinx:kotlinx-serialization-properties-js:$kotlin_serialisation_runtime_version"
|
||||||
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$kotlin_coroutines_version"
|
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$kotlin_coroutines_version"
|
||||||
api "io.ktor:ktor-client-js:$ktor_version"
|
api "io.ktor:ktor-client-js:$ktor_version"
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.RetryAfterError
|
import com.github.insanusmokrassar.TelegramBotAPI.types.RetryAfterError
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.call.receive
|
import io.ktor.client.call.receive
|
||||||
import io.ktor.client.features.*
|
import io.ktor.client.features.*
|
||||||
@ -25,7 +26,7 @@ class KtorRequestsExecutor(
|
|||||||
callsFactories: List<KtorCallFactory> = emptyList(),
|
callsFactories: List<KtorCallFactory> = emptyList(),
|
||||||
excludeDefaultFactories: Boolean = false,
|
excludeDefaultFactories: Boolean = false,
|
||||||
private val requestsLimiter: RequestLimiter = EmptyLimiter,
|
private val requestsLimiter: RequestLimiter = EmptyLimiter,
|
||||||
private val jsonFormatter: Json = Json.nonstrict
|
private val jsonFormatter: Json = nonstrictJsonFormat
|
||||||
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
||||||
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
||||||
if (!excludeDefaultFactories) {
|
if (!excludeDefaultFactories) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions
|
package com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||||
import kotlinx.io.IOException
|
import io.ktor.utils.io.errors.IOException
|
||||||
|
|
||||||
fun newRequestException(
|
fun newRequestException(
|
||||||
response: Response,
|
response: Response,
|
||||||
|
@ -7,7 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class DeleteMessage(
|
data class DeleteMessage(
|
||||||
@ -19,7 +19,7 @@ data class DeleteMessage(
|
|||||||
override fun method(): String = "deleteMessage"
|
override fun method(): String = "deleteMessage"
|
||||||
|
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UpdateSerializerWithoutDeserialization
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UpdateSerializerWithoutDeserialization
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.ArrayListSerializer
|
import kotlinx.serialization.builtins.ListSerializer
|
||||||
|
|
||||||
private val updatesListSerializer = ArrayListSerializer(
|
private val updatesListSerializer = ListSerializer(
|
||||||
UpdateSerializerWithoutDeserialization
|
UpdateSerializerWithoutDeserialization
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ fun String.toInputFile() = FileId(this)
|
|||||||
|
|
||||||
@Serializer(InputFile::class)
|
@Serializer(InputFile::class)
|
||||||
internal object InputFileSerializer : KSerializer<InputFile> {
|
internal object InputFileSerializer : KSerializer<InputFile> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName(FileId::class.toString())
|
override val descriptor: SerialDescriptor = PrimitiveDescriptor(FileId::class.toString(), PrimitiveKind.STRING)
|
||||||
override fun serialize(encoder: Encoder, obj: InputFile) = encoder.encodeString(obj.fileId)
|
override fun serialize(encoder: Encoder, value: InputFile) = encoder.encodeString(value.fileId)
|
||||||
override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString())
|
override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleReque
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery.CallbackQuery
|
import com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery.CallbackQuery
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class AnswerCallbackQuery(
|
data class AnswerCallbackQuery(
|
||||||
@ -22,7 +22,7 @@ data class AnswerCallbackQuery(
|
|||||||
) : SimpleRequest<Boolean> {
|
) : SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "answerCallbackQuery"
|
override fun method(): String = "answerCallbackQuery"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.serializers.InlineQueryResultSerializer
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.serializers.InlineQueryResultSerializer
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InlineQuery
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InlineQuery
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.ArrayListSerializer
|
import kotlinx.serialization.builtins.ListSerializer
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class AnswerInlineQuery(
|
data class AnswerInlineQuery(
|
||||||
@ -30,7 +29,7 @@ data class AnswerInlineQuery(
|
|||||||
): SimpleRequest<Boolean> {
|
): SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "answerInlineQuery"
|
override fun method(): String = "answerInlineQuery"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
@ -52,6 +51,6 @@ fun InlineQuery.createAnswer(
|
|||||||
switchPmParameter
|
switchPmParameter
|
||||||
)
|
)
|
||||||
|
|
||||||
internal object InlineQueryAnswersResultsSerializer: KSerializer<List<InlineQueryResult>> by ArrayListSerializer(
|
internal object InlineQueryAnswersResultsSerializer: KSerializer<List<InlineQueryResult>> by ListSerializer(
|
||||||
InlineQueryResultSerializer
|
InlineQueryResultSerializer
|
||||||
)
|
)
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abstracts.AnswerShippingQuery
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abstracts.AnswerShippingQuery
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingOption
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingOption
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.ArrayListSerializer
|
import kotlinx.serialization.builtins.ListSerializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class AnswerShippingQueryOk(
|
data class AnswerShippingQueryOk(
|
||||||
@ -22,7 +21,7 @@ data class AnswerShippingQueryOk(
|
|||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal object ShippingOptionsSerializer : KSerializer<List<ShippingOption>> by ArrayListSerializer(
|
internal object ShippingOptionsSerializer : KSerializer<List<ShippingOption>> by ListSerializer(
|
||||||
ShippingOption.serializer()
|
ShippingOption.serializer()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3,12 +3,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abs
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.PreCheckoutQueryId
|
import com.github.insanusmokrassar.TelegramBotAPI.types.PreCheckoutQueryId
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
interface AnswerPreCheckoutQuery : SimpleRequest<Boolean> {
|
interface AnswerPreCheckoutQuery : SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "answerPreCheckoutQuery"
|
override fun method(): String = "answerPreCheckoutQuery"
|
||||||
override val resultDeserializer: KSerializer<Boolean>
|
override val resultDeserializer: KSerializer<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
|
|
||||||
val preCheckoutQueryId: PreCheckoutQueryId
|
val preCheckoutQueryId: PreCheckoutQueryId
|
||||||
val isOk: Boolean
|
val isOk: Boolean
|
||||||
|
@ -3,12 +3,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abs
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ShippingQueryIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ShippingQueryIdentifier
|
||||||
import kotlinx.serialization.DeserializationStrategy
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
interface AnswerShippingQuery : SimpleRequest<Boolean> {
|
interface AnswerShippingQuery : SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "answerShippingQuery"
|
override fun method(): String = "answerShippingQuery"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
|
|
||||||
val shippingQueryId: ShippingQueryIdentifier
|
val shippingQueryId: ShippingQueryIdentifier
|
||||||
val isOk: Boolean
|
val isOk: Boolean
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.StringSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class ExportChatInviteLink(
|
data class ExportChatInviteLink(
|
||||||
@ -16,7 +14,7 @@ data class ExportChatInviteLink(
|
|||||||
): ChatRequest, SimpleRequest<String> {
|
): ChatRequest, SimpleRequest<String> {
|
||||||
override fun method(): String = "exportChatInviteLink"
|
override fun method(): String = "exportChatInviteLink"
|
||||||
override val resultDeserializer: DeserializationStrategy<String>
|
override val resultDeserializer: DeserializationStrategy<String>
|
||||||
get() = StringSerializer
|
get() = String.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class LeaveChat(
|
data class LeaveChat(
|
||||||
@ -16,7 +16,7 @@ data class LeaveChat(
|
|||||||
): ChatRequest, SimpleRequest<Boolean> {
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "leaveChat"
|
override fun method(): String = "leaveChat"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,9 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.Adm
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.ArrayListSerializer
|
import kotlinx.serialization.builtins.ListSerializer
|
||||||
|
|
||||||
private val chatMembersListSerializer = ArrayListSerializer(
|
private val chatMembersListSerializer = ListSerializer(
|
||||||
AdministratorChatMemberSerializerWithoutDeserialization
|
AdministratorChatMemberSerializerWithoutDeserialization
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.IntSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class GetChatMembersCount(
|
data class GetChatMembersCount(
|
||||||
@ -16,7 +16,7 @@ data class GetChatMembersCount(
|
|||||||
): ChatRequest, SimpleRequest<Int> {
|
): ChatRequest, SimpleRequest<Int> {
|
||||||
override fun method(): String = "getChatMembersCount"
|
override fun method(): String = "getChatMembersCount"
|
||||||
override val resultDeserializer: DeserializationStrategy<Int>
|
override val resultDeserializer: DeserializationStrategy<Int>
|
||||||
get() = IntSerializer
|
get() = Int.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMe
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class KickChatMember(
|
data class KickChatMember(
|
||||||
@ -19,7 +19,7 @@ data class KickChatMember(
|
|||||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||||
override fun method(): String = "kickChatMember"
|
override fun method(): String = "kickChatMember"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMe
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class PromoteChatMember(
|
data class PromoteChatMember(
|
||||||
@ -35,7 +35,7 @@ data class PromoteChatMember(
|
|||||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||||
override fun method(): String = "promoteChatMember"
|
override fun method(): String = "promoteChatMember"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RestrictChatMember(
|
data class RestrictChatMember(
|
||||||
@ -22,7 +22,7 @@ data class RestrictChatMember(
|
|||||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||||
override fun method(): String = "restrictChatMember"
|
override fun method(): String = "restrictChatMember"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMe
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Representation of https://core.telegram.org/bots/api#setchatadministratorcustomtitle
|
* Representation of https://core.telegram.org/bots/api#setchatadministratorcustomtitle
|
||||||
@ -23,7 +23,7 @@ data class SetChatAdministratorCustomTitle(
|
|||||||
) : ChatMemberRequest<Boolean> {
|
) : ChatMemberRequest<Boolean> {
|
||||||
override fun method(): String = "setChatAdministratorCustomTitle"
|
override fun method(): String = "setChatAdministratorCustomTitle"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = RestrictChatMember.serializer()
|
get() = RestrictChatMember.serializer()
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMe
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class UnbanChatMember(
|
data class UnbanChatMember(
|
||||||
@ -16,7 +16,7 @@ data class UnbanChatMember(
|
|||||||
) : ChatMemberRequest<Boolean> {
|
) : ChatMemberRequest<Boolean> {
|
||||||
override fun method(): String = "unbanChatMember"
|
override fun method(): String = "unbanChatMember"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class DeleteChatPhoto(
|
data class DeleteChatPhoto(
|
||||||
@ -16,7 +16,7 @@ data class DeleteChatPhoto(
|
|||||||
): ChatRequest, SimpleRequest<Boolean> {
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "deleteChatPhoto"
|
override fun method(): String = "deleteChatPhoto"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class PinChatMessage (
|
data class PinChatMessage (
|
||||||
@ -20,7 +17,7 @@ data class PinChatMessage (
|
|||||||
): ChatRequest, SimpleRequest<Boolean>, MessageAction, DisableNotification {
|
): ChatRequest, SimpleRequest<Boolean>, MessageAction, DisableNotification {
|
||||||
override fun method(): String = "pinChatMessage"
|
override fun method(): String = "pinChatMessage"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleReque
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SetChatDescription (
|
data class SetChatDescription (
|
||||||
@ -23,7 +23,7 @@ data class SetChatDescription (
|
|||||||
|
|
||||||
override fun method(): String = "setChatDescription"
|
override fun method(): String = "setChatDescription"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SetChatPermissions (
|
data class SetChatPermissions (
|
||||||
@ -18,7 +18,7 @@ data class SetChatPermissions (
|
|||||||
): ChatRequest, SimpleRequest<Boolean> {
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "setChatPermissions"
|
override fun method(): String = "setChatPermissions"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJson
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJson
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ -19,7 +19,7 @@ data class SetChatPhoto (
|
|||||||
): ChatRequest, MultipartRequest<Boolean> {
|
): ChatRequest, MultipartRequest<Boolean> {
|
||||||
override fun method(): String = "setChatPhoto"
|
override fun method(): String = "setChatPhoto"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val mediaMap: Map<String, MultipartFile> = mapOf(photoField to photo)
|
override val mediaMap: Map<String, MultipartFile> = mapOf(photoField to photo)
|
||||||
override val paramsJson: JsonObject = toJson(serializer())
|
override val paramsJson: JsonObject = toJson(serializer())
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleReque
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SetChatTitle (
|
data class SetChatTitle (
|
||||||
@ -23,7 +23,7 @@ data class SetChatTitle (
|
|||||||
|
|
||||||
override fun method(): String = "setChatTitle"
|
override fun method(): String = "setChatTitle"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class UnpinChatMessage(
|
data class UnpinChatMessage(
|
||||||
@ -16,7 +16,7 @@ data class UnpinChatMessage(
|
|||||||
): ChatRequest, SimpleRequest<Boolean> {
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "unpinChatMessage"
|
override fun method(): String = "unpinChatMessage"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.SupergroupChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.SupergroupChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class DeleteChatStickerSet(
|
data class DeleteChatStickerSet(
|
||||||
@ -16,7 +16,7 @@ data class DeleteChatStickerSet(
|
|||||||
): ChatRequest, SimpleRequest<Boolean> {
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "deleteChatStickerSet"
|
override fun method(): String = "deleteChatStickerSet"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleReque
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.SupergroupChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.SupergroupChat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SetChatStickerSet(
|
data class SetChatStickerSet(
|
||||||
@ -17,7 +17,7 @@ data class SetChatStickerSet(
|
|||||||
): ChatRequest, SimpleRequest<Boolean> {
|
): ChatRequest, SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "setChatStickerSet"
|
override fun method(): String = "setChatStickerSet"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
||||||
import kotlinx.serialization.DeserializationStrategy
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
interface EditInlineMessage : SimpleRequest<Boolean> {
|
interface EditInlineMessage : SimpleRequest<Boolean> {
|
||||||
val inlineMessageId: InlineMessageIdentifier
|
val inlineMessageId: InlineMessageIdentifier
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.games.GameHighScore
|
import com.github.insanusmokrassar.TelegramBotAPI.types.games.GameHighScore
|
||||||
import kotlinx.serialization.DeserializationStrategy
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.internal.ArrayListSerializer
|
import kotlinx.serialization.builtins.ListSerializer
|
||||||
|
|
||||||
interface GetGameHighScores : SimpleRequest<List<GameHighScore>> {
|
interface GetGameHighScores : SimpleRequest<List<GameHighScore>> {
|
||||||
val userId: UserId
|
val userId: UserId
|
||||||
@ -15,4 +15,4 @@ interface GetGameHighScores : SimpleRequest<List<GameHighScore>> {
|
|||||||
get() = GameHighScoresSerializer
|
get() = GameHighScoresSerializer
|
||||||
}
|
}
|
||||||
|
|
||||||
internal object GameHighScoresSerializer : KSerializer<List<GameHighScore>> by ArrayListSerializer(GameHighScore.serializer())
|
internal object GameHighScoresSerializer : KSerializer<List<GameHighScore>> by ListSerializer(GameHighScore.serializer())
|
||||||
|
@ -3,6 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
||||||
import kotlinx.serialization.DeserializationStrategy
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
import kotlinx.serialization.serializer
|
import kotlinx.serialization.serializer
|
||||||
|
|
||||||
interface SetGameScore : SimpleRequest<Boolean> {
|
interface SetGameScore : SimpleRequest<Boolean> {
|
||||||
|
@ -6,7 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.actions.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.actions.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send notification to user which will be shown for 5 seconds or while user have no messages from bot
|
* Send notification to user which will be shown for 5 seconds or while user have no messages from bot
|
||||||
@ -20,7 +20,7 @@ data class SendAction(
|
|||||||
): SendChatMessageRequest<Boolean> {
|
): SendChatMessageRequest<Boolean> {
|
||||||
override fun method(): String = "sendChatAction"
|
override fun method(): String = "sendChatAction"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaG
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.ArrayListSerializer
|
import kotlinx.serialization.builtins.ListSerializer
|
||||||
import kotlinx.serialization.json.jsonArray
|
import kotlinx.serialization.json.jsonArray
|
||||||
|
|
||||||
val membersCountInMediaGroup: IntRange = 2 .. 10
|
val membersCountInMediaGroup: IntRange = 2 .. 10
|
||||||
@ -55,8 +55,8 @@ fun SendMediaGroup(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val messagesListSerializer: ArrayListSerializer<MediaGroupMessage>
|
private val messagesListSerializer: KSerializer<List<MediaGroupMessage>>
|
||||||
= ArrayListSerializer(TelegramBotAPIMessageDeserializeOnlySerializerClass())
|
= ListSerializer(TelegramBotAPIMessageDeserializeOnlySerializerClass())
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SendMediaGroupData internal constructor(
|
data class SendMediaGroupData internal constructor(
|
||||||
|
@ -6,7 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleReque
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickerField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickerField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class DeleteStickerFromSet(
|
data class DeleteStickerFromSet(
|
||||||
@ -15,7 +15,7 @@ data class DeleteStickerFromSet(
|
|||||||
) : SimpleRequest<Boolean> {
|
) : SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "deleteStickerFromSet"
|
override fun method(): String = "deleteStickerFromSet"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.positionField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.positionField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickerField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickerField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SetStickerPositionInSet(
|
data class SetStickerPositionInSet(
|
||||||
@ -24,7 +24,7 @@ data class SetStickerPositionInSet(
|
|||||||
|
|
||||||
override fun method(): String = "setStickerPositionInSet"
|
override fun method(): String = "setStickerPositionInSet"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleReque
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
interface StickerSetAction : SimpleRequest<Boolean> {
|
interface StickerSetAction : SimpleRequest<Boolean> {
|
||||||
val userId: UserId
|
val userId: UserId
|
||||||
@ -13,5 +13,5 @@ interface StickerSetAction : SimpleRequest<Boolean> {
|
|||||||
val maskPosition: MaskPosition?
|
val maskPosition: MaskPosition?
|
||||||
|
|
||||||
override val resultDeserializer: KSerializer<Boolean>
|
override val resultDeserializer: KSerializer<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
}
|
}
|
@ -2,14 +2,14 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.webhook
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
class DeleteWebhook : SimpleRequest<Boolean> {
|
class DeleteWebhook : SimpleRequest<Boolean> {
|
||||||
override fun method(): String = "deleteWebhook"
|
override fun method(): String = "deleteWebhook"
|
||||||
|
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.DataR
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.MultipartRequestImpl
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.MultipartRequestImpl
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
fun SetWebhook(
|
fun SetWebhook(
|
||||||
url: String,
|
url: String,
|
||||||
@ -53,7 +53,7 @@ data class SetWebhook internal constructor(
|
|||||||
) : DataRequest<Boolean> {
|
) : DataRequest<Boolean> {
|
||||||
override fun method(): String = "setWebhook"
|
override fun method(): String = "setWebhook"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = BooleanSerializer
|
get() = Boolean.serializer()
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
|
|
||||||
|
@ -49,10 +49,10 @@ internal object ChatIdentifierSerializer : KSerializer<ChatIdentifier> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, obj: ChatIdentifier) {
|
override fun serialize(encoder: Encoder, value: ChatIdentifier) {
|
||||||
when (obj) {
|
when (value) {
|
||||||
is ChatId -> encoder.encodeLong(obj.chatId)
|
is ChatId -> encoder.encodeLong(value.chatId)
|
||||||
is Username -> encoder.encodeString(obj.username)
|
is Username -> encoder.encodeString(value.username)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,16 +10,16 @@ interface ChatMember {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal object AdministratorChatMemberSerializerWithoutDeserialization : KSerializer<AdministratorChatMember> {
|
internal object AdministratorChatMemberSerializerWithoutDeserialization : KSerializer<AdministratorChatMember> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("ChatMemberSerializerWithoutDeserialization")
|
override val descriptor: SerialDescriptor = ChatMemberDeserializationStrategy.descriptor
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): AdministratorChatMember
|
override fun deserialize(decoder: Decoder): AdministratorChatMember
|
||||||
= ChatMemberDeserializationStrategy.deserialize(decoder) as AdministratorChatMember
|
= ChatMemberDeserializationStrategy.deserialize(decoder) as AdministratorChatMember
|
||||||
override fun serialize(encoder: Encoder, obj: AdministratorChatMember) = throw UnsupportedOperationException()
|
override fun serialize(encoder: Encoder, value: AdministratorChatMember) = throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal object ChatMemberDeserializationStrategy : DeserializationStrategy<ChatMember> {
|
internal object ChatMemberDeserializationStrategy : DeserializationStrategy<ChatMember> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("ChatMemberDeserializationStrategy")
|
override val descriptor: SerialDescriptor = RawChatMember.serializer().descriptor
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): ChatMember = RawChatMember.serializer().deserialize(decoder).asChatMember
|
override fun deserialize(decoder: Decoder): ChatMember = RawChatMember.serializer().deserialize(decoder).asChatMember
|
||||||
override fun patch(decoder: Decoder, old: ChatMember): ChatMember = throw UpdateNotSupportedException(descriptor.name)
|
override fun patch(decoder: Decoder, old: ChatMember): ChatMember = throw UpdateNotSupportedException("ChatMember")
|
||||||
}
|
}
|
||||||
|
@ -7,29 +7,29 @@ import kotlinx.serialization.internal.StringDescriptor
|
|||||||
|
|
||||||
@Serializer(InlineQueryResult::class)
|
@Serializer(InlineQueryResult::class)
|
||||||
internal object InlineQueryResultSerializer : KSerializer<InlineQueryResult> {
|
internal object InlineQueryResultSerializer : KSerializer<InlineQueryResult> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName(InlineQueryResult::class.toString())
|
override val descriptor: SerialDescriptor = SerialDescriptor(InlineQueryResult::class.toString(), PolymorphicKind.OPEN)
|
||||||
override fun serialize(encoder: Encoder, obj: InlineQueryResult) {
|
override fun serialize(encoder: Encoder, value: InlineQueryResult) {
|
||||||
when(obj) {
|
when(value) {
|
||||||
is InlineQueryResultArticle -> InlineQueryResultArticle.serializer().serialize(encoder, obj)
|
is InlineQueryResultArticle -> InlineQueryResultArticle.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultAudioCachedImpl -> InlineQueryResultAudioCachedImpl.serializer().serialize(encoder, obj)
|
is InlineQueryResultAudioCachedImpl -> InlineQueryResultAudioCachedImpl.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultAudioImpl -> InlineQueryResultAudioImpl.serializer().serialize(encoder, obj)
|
is InlineQueryResultAudioImpl -> InlineQueryResultAudioImpl.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultContact -> InlineQueryResultContact.serializer().serialize(encoder, obj)
|
is InlineQueryResultContact -> InlineQueryResultContact.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultDocumentCachedImpl -> InlineQueryResultDocumentCachedImpl.serializer().serialize(encoder, obj)
|
is InlineQueryResultDocumentCachedImpl -> InlineQueryResultDocumentCachedImpl.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultDocumentImpl -> InlineQueryResultDocumentImpl.serializer().serialize(encoder, obj)
|
is InlineQueryResultDocumentImpl -> InlineQueryResultDocumentImpl.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultGame -> InlineQueryResultGame.serializer().serialize(encoder, obj)
|
is InlineQueryResultGame -> InlineQueryResultGame.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultGifCachedImpl -> InlineQueryResultGifCachedImpl.serializer().serialize(encoder, obj)
|
is InlineQueryResultGifCachedImpl -> InlineQueryResultGifCachedImpl.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultGifImpl -> InlineQueryResultGifImpl.serializer().serialize(encoder, obj)
|
is InlineQueryResultGifImpl -> InlineQueryResultGifImpl.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultLocation -> InlineQueryResultLocation.serializer().serialize(encoder, obj)
|
is InlineQueryResultLocation -> InlineQueryResultLocation.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultMpeg4GifCachedImpl -> InlineQueryResultMpeg4GifCachedImpl.serializer().serialize(encoder, obj)
|
is InlineQueryResultMpeg4GifCachedImpl -> InlineQueryResultMpeg4GifCachedImpl.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultMpeg4GifImpl -> InlineQueryResultMpeg4GifImpl.serializer().serialize(encoder, obj)
|
is InlineQueryResultMpeg4GifImpl -> InlineQueryResultMpeg4GifImpl.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultPhotoCachedImpl -> InlineQueryResultPhotoCachedImpl.serializer().serialize(encoder, obj)
|
is InlineQueryResultPhotoCachedImpl -> InlineQueryResultPhotoCachedImpl.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultPhotoImpl -> InlineQueryResultPhotoImpl.serializer().serialize(encoder, obj)
|
is InlineQueryResultPhotoImpl -> InlineQueryResultPhotoImpl.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultStickerCached -> InlineQueryResultStickerCached.serializer().serialize(encoder, obj)
|
is InlineQueryResultStickerCached -> InlineQueryResultStickerCached.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultVenue -> InlineQueryResultVenue.serializer().serialize(encoder, obj)
|
is InlineQueryResultVenue -> InlineQueryResultVenue.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultVideoCachedImpl -> InlineQueryResultVideoCachedImpl.serializer().serialize(encoder, obj)
|
is InlineQueryResultVideoCachedImpl -> InlineQueryResultVideoCachedImpl.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultVideoImpl -> InlineQueryResultVideoImpl.serializer().serialize(encoder, obj)
|
is InlineQueryResultVideoImpl -> InlineQueryResultVideoImpl.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultVoiceCachedImpl -> InlineQueryResultVoiceCachedImpl.serializer().serialize(encoder, obj)
|
is InlineQueryResultVoiceCachedImpl -> InlineQueryResultVoiceCachedImpl.serializer().serialize(encoder, value)
|
||||||
is InlineQueryResultVoiceImpl -> InlineQueryResultVoiceImpl.serializer().serialize(encoder, obj)
|
is InlineQueryResultVoiceImpl -> InlineQueryResultVoiceImpl.serializer().serialize(encoder, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,13 +7,13 @@ import kotlinx.serialization.internal.StringDescriptor
|
|||||||
|
|
||||||
@Serializer(InputMessageContent::class)
|
@Serializer(InputMessageContent::class)
|
||||||
internal object InputMessageContentSerializer : KSerializer<InputMessageContent> {
|
internal object InputMessageContentSerializer : KSerializer<InputMessageContent> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName(InputMessageContent::class.toString())
|
override val descriptor: SerialDescriptor = SerialDescriptor(InputMessageContent::class.toString(), PolymorphicKind.OPEN)
|
||||||
override fun serialize(encoder: Encoder, obj: InputMessageContent) {
|
override fun serialize(encoder: Encoder, value: InputMessageContent) {
|
||||||
when (obj) {
|
when (value) {
|
||||||
is InputContactMessageContent -> InputContactMessageContent.serializer().serialize(encoder, obj)
|
is InputContactMessageContent -> InputContactMessageContent.serializer().serialize(encoder, value)
|
||||||
is InputLocationMessageContent -> InputLocationMessageContent.serializer().serialize(encoder, obj)
|
is InputLocationMessageContent -> InputLocationMessageContent.serializer().serialize(encoder, value)
|
||||||
is InputTextMessageContent -> InputTextMessageContent.serializer().serialize(encoder, obj)
|
is InputTextMessageContent -> InputTextMessageContent.serializer().serialize(encoder, value)
|
||||||
is InputVenueMessageContent -> InputVenueMessageContent.serializer().serialize(encoder, obj)
|
is InputVenueMessageContent -> InputVenueMessageContent.serializer().serialize(encoder, value)
|
||||||
else -> throw IllegalArgumentException("Unknown for serializing InputContactMessageContent")
|
else -> throw IllegalArgumentException("Unknown for serializing InputContactMessageContent")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ data class InputMediaPhoto(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
override val arguments: Map<String, Any?> = Mapper.mapNullable(serializer(), this)
|
override val arguments: Map<String, Any?> = Properties.storeNullable(serializer(), this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun PhotoSize.toInputMediaPhoto(
|
fun PhotoSize.toInputMediaPhoto(
|
||||||
|
@ -5,15 +5,15 @@ import kotlinx.serialization.internal.StringDescriptor
|
|||||||
|
|
||||||
@Serializer(InputMedia::class)
|
@Serializer(InputMedia::class)
|
||||||
internal object InputMediaSerializer : KSerializer<InputMedia> {
|
internal object InputMediaSerializer : KSerializer<InputMedia> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName(InputMedia::class.toString())
|
override val descriptor: SerialDescriptor = SerialDescriptor(InputMedia::class.toString(), PolymorphicKind.OPEN)
|
||||||
override fun serialize(encoder: Encoder, obj: InputMedia) {
|
override fun serialize(encoder: Encoder, value: InputMedia) {
|
||||||
when (obj) {
|
when (value) {
|
||||||
is InputMediaVideo -> InputMediaVideo.serializer().serialize(encoder, obj)
|
is InputMediaVideo -> InputMediaVideo.serializer().serialize(encoder, value)
|
||||||
is InputMediaAudio -> InputMediaAudio.serializer().serialize(encoder, obj)
|
is InputMediaAudio -> InputMediaAudio.serializer().serialize(encoder, value)
|
||||||
is InputMediaPhoto -> InputMediaPhoto.serializer().serialize(encoder, obj)
|
is InputMediaPhoto -> InputMediaPhoto.serializer().serialize(encoder, value)
|
||||||
is InputMediaAnimation -> InputMediaAnimation.serializer().serialize(encoder, obj)
|
is InputMediaAnimation -> InputMediaAnimation.serializer().serialize(encoder, value)
|
||||||
is InputMediaDocument -> InputMediaDocument.serializer().serialize(encoder, obj)
|
is InputMediaDocument -> InputMediaDocument.serializer().serialize(encoder, value)
|
||||||
else -> throw IllegalArgumentException("Can't perform and serialize $obj")
|
else -> throw IllegalArgumentException("Can't perform and serialize $value")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,5 +28,5 @@ data class InputMediaVideo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
override val arguments: Map<String, Any?> = Mapper.mapNullable(serializer(), this)
|
override val arguments: Map<String, Any?> = Properties.storeNullable(serializer(), this)
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@ import kotlinx.serialization.internal.StringDescriptor
|
|||||||
|
|
||||||
@Serializer(MediaGroupMemberInputMedia::class)
|
@Serializer(MediaGroupMemberInputMedia::class)
|
||||||
internal object MediaGroupMemberInputMediaSerializer : KSerializer<MediaGroupMemberInputMedia> {
|
internal object MediaGroupMemberInputMediaSerializer : KSerializer<MediaGroupMemberInputMedia> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName(MediaGroupMemberInputMedia::class.toString())
|
override val descriptor: SerialDescriptor = SerialDescriptor(MediaGroupMemberInputMedia::class.toString(), PolymorphicKind.OPEN)
|
||||||
override fun serialize(encoder: Encoder, obj: MediaGroupMemberInputMedia) {
|
override fun serialize(encoder: Encoder, value: MediaGroupMemberInputMedia) {
|
||||||
when (obj) {
|
when (value) {
|
||||||
is InputMediaPhoto -> InputMediaPhoto.serializer().serialize(encoder, obj)
|
is InputMediaPhoto -> InputMediaPhoto.serializer().serialize(encoder, value)
|
||||||
is InputMediaVideo -> InputMediaVideo.serializer().serialize(encoder, obj)
|
is InputMediaVideo -> InputMediaVideo.serializer().serialize(encoder, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ internal object ParseModeSerializerObject : KSerializer<ParseMode> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, obj: ParseMode) {
|
override fun serialize(encoder: Encoder, value: ParseMode) {
|
||||||
encoder.encodeString(obj.parseModeName)
|
encoder.encodeString(value.parseModeName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,9 @@ fun DateTime.toTelegramDate(): TelegramDate = TelegramDate(this)
|
|||||||
|
|
||||||
@Serializer(TelegramDate::class)
|
@Serializer(TelegramDate::class)
|
||||||
internal object TelegramDateSerializer : KSerializer<TelegramDate> {
|
internal object TelegramDateSerializer : KSerializer<TelegramDate> {
|
||||||
override fun serialize(encoder: Encoder, obj: TelegramDate) {
|
override fun serialize(encoder: Encoder, value: TelegramDate) {
|
||||||
encoder.encodeLong(
|
encoder.encodeLong(
|
||||||
obj.date
|
value.date
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types
|
package com.github.insanusmokrassar.TelegramBotAPI.types
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PrivateChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PrivateChat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlinx.serialization.json.JsonObjectSerializer
|
import kotlinx.serialization.json.JsonObjectSerializer
|
||||||
@ -67,7 +68,7 @@ internal object UserSerializer : KSerializer<User> {
|
|||||||
val asJson = JsonObjectSerializer.deserialize(decoder)
|
val asJson = JsonObjectSerializer.deserialize(decoder)
|
||||||
|
|
||||||
return when {
|
return when {
|
||||||
asJson.getPrimitiveOrNull(isBotField) ?.booleanOrNull != true -> Json.nonstrict.fromJson(
|
asJson.getPrimitiveOrNull(isBotField) ?.booleanOrNull != true -> nonstrictJsonFormat.fromJson(
|
||||||
CommonUser.serializer(),
|
CommonUser.serializer(),
|
||||||
asJson
|
asJson
|
||||||
)
|
)
|
||||||
@ -76,12 +77,12 @@ internal object UserSerializer : KSerializer<User> {
|
|||||||
?: asJson.get(canReadAllGroupMessagesField)
|
?: asJson.get(canReadAllGroupMessagesField)
|
||||||
?: asJson.get(supportInlineQueriesField)) != null
|
?: asJson.get(supportInlineQueriesField)) != null
|
||||||
) {
|
) {
|
||||||
Json.nonstrict.fromJson(
|
nonstrictJsonFormat.fromJson(
|
||||||
ExtendedBot.serializer(),
|
ExtendedBot.serializer(),
|
||||||
asJson
|
asJson
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Json.nonstrict.fromJson(
|
nonstrictJsonFormat.fromJson(
|
||||||
CommonBot.serializer(),
|
CommonBot.serializer(),
|
||||||
asJson
|
asJson
|
||||||
)
|
)
|
||||||
@ -90,11 +91,11 @@ internal object UserSerializer : KSerializer<User> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, obj: User) {
|
override fun serialize(encoder: Encoder, value: User) {
|
||||||
when (obj) {
|
when (value) {
|
||||||
is CommonUser -> CommonUser.serializer().serialize(encoder, obj)
|
is CommonUser -> CommonUser.serializer().serialize(encoder, value)
|
||||||
is CommonBot -> CommonBot.serializer().serialize(encoder, obj)
|
is CommonBot -> CommonBot.serializer().serialize(encoder, value)
|
||||||
is ExtendedBot -> ExtendedBot.serializer().serialize(encoder, obj)
|
is ExtendedBot -> ExtendedBot.serializer().serialize(encoder, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Photo
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Photo
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSerializer
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSerializer
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.ArrayListSerializer
|
import kotlinx.serialization.builtins.ListSerializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class UserProfilePhotos (
|
data class UserProfilePhotos (
|
||||||
@ -13,6 +13,6 @@ data class UserProfilePhotos (
|
|||||||
val photos: List<Photo>
|
val photos: List<Photo>
|
||||||
)
|
)
|
||||||
|
|
||||||
internal object UserProfilePhotosPhotosSerializer : KSerializer<List<Photo>> by ArrayListSerializer(
|
internal object UserProfilePhotosPhotosSerializer : KSerializer<List<Photo>> by ListSerializer(
|
||||||
PhotoSerializer
|
PhotoSerializer
|
||||||
)
|
)
|
||||||
|
@ -9,8 +9,8 @@ sealed class BotAction {
|
|||||||
|
|
||||||
@Serializer(BotAction::class)
|
@Serializer(BotAction::class)
|
||||||
internal object BotActionSerializer: KSerializer<BotAction> {
|
internal object BotActionSerializer: KSerializer<BotAction> {
|
||||||
override fun serialize(encoder: Encoder, obj: BotAction) {
|
override fun serialize(encoder: Encoder, value: BotAction) {
|
||||||
encoder.encodeString(obj.actionName)
|
encoder.encodeString(value.actionName)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): BotAction {
|
override fun deserialize(decoder: Decoder): BotAction {
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons
|
package com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.StringDescriptor
|
import kotlinx.serialization.internal.StringDescriptor
|
||||||
import kotlinx.serialization.json.*
|
import kotlinx.serialization.json.*
|
||||||
|
|
||||||
internal object InlineKeyboardButtonSerializer : KSerializer<InlineKeyboardButton> {
|
internal object InlineKeyboardButtonSerializer : KSerializer<InlineKeyboardButton> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons.InlineKeyboardButton")
|
override val descriptor: SerialDescriptor = SerialDescriptor(
|
||||||
|
"com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons.InlineKeyboardButton",
|
||||||
|
PolymorphicKind.SEALED
|
||||||
|
)
|
||||||
|
|
||||||
private fun resolveSerializer(json: JsonObject): KSerializer<out InlineKeyboardButton> {
|
private fun resolveSerializer(json: JsonObject): KSerializer<out InlineKeyboardButton> {
|
||||||
return when {
|
return when {
|
||||||
@ -23,17 +27,17 @@ internal object InlineKeyboardButtonSerializer : KSerializer<InlineKeyboardButto
|
|||||||
override fun deserialize(decoder: Decoder): InlineKeyboardButton {
|
override fun deserialize(decoder: Decoder): InlineKeyboardButton {
|
||||||
val json = JsonElementSerializer.deserialize(decoder)
|
val json = JsonElementSerializer.deserialize(decoder)
|
||||||
|
|
||||||
return Json.nonstrict.fromJson(resolveSerializer(json.jsonObject), json)
|
return nonstrictJsonFormat.fromJson(resolveSerializer(json.jsonObject), json)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, obj: InlineKeyboardButton) {
|
override fun serialize(encoder: Encoder, value: InlineKeyboardButton) {
|
||||||
when (obj) {
|
when (value) {
|
||||||
is CallbackDataInlineKeyboardButton -> CallbackDataInlineKeyboardButton.serializer().serialize(encoder, obj)
|
is CallbackDataInlineKeyboardButton -> CallbackDataInlineKeyboardButton.serializer().serialize(encoder, value)
|
||||||
is LoginURLInlineKeyboardButton -> LoginURLInlineKeyboardButton.serializer().serialize(encoder, obj)
|
is LoginURLInlineKeyboardButton -> LoginURLInlineKeyboardButton.serializer().serialize(encoder, value)
|
||||||
is PayInlineKeyboardButton -> PayInlineKeyboardButton.serializer().serialize(encoder, obj)
|
is PayInlineKeyboardButton -> PayInlineKeyboardButton.serializer().serialize(encoder, value)
|
||||||
is SwitchInlineQueryInlineKeyboardButton -> SwitchInlineQueryInlineKeyboardButton.serializer().serialize(encoder, obj)
|
is SwitchInlineQueryInlineKeyboardButton -> SwitchInlineQueryInlineKeyboardButton.serializer().serialize(encoder, value)
|
||||||
is SwitchInlineQueryCurrentChatInlineKeyboardButton -> SwitchInlineQueryCurrentChatInlineKeyboardButton.serializer().serialize(encoder, obj)
|
is SwitchInlineQueryCurrentChatInlineKeyboardButton -> SwitchInlineQueryCurrentChatInlineKeyboardButton.serializer().serialize(encoder, value)
|
||||||
is URLInlineKeyboardButton -> URLInlineKeyboardButton.serializer().serialize(encoder, obj)
|
is URLInlineKeyboardButton -> URLInlineKeyboardButton.serializer().serialize(encoder, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.buttons
|
package com.github.insanusmokrassar.TelegramBotAPI.types.buttons
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.json.*
|
import kotlinx.serialization.json.*
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ internal object KeyboardButtonSerializer : KSerializer<KeyboardButton> {
|
|||||||
)
|
)
|
||||||
asJson is JsonObject && asJson.getObjectOrNull(requestPollField) != null -> RequestPollKeyboardButton(
|
asJson is JsonObject && asJson.getObjectOrNull(requestPollField) != null -> RequestPollKeyboardButton(
|
||||||
asJson.getPrimitive(textField).content,
|
asJson.getPrimitive(textField).content,
|
||||||
Json.nonstrict.fromJson(
|
nonstrictJsonFormat.fromJson(
|
||||||
KeyboardButtonPollType.serializer(),
|
KeyboardButtonPollType.serializer(),
|
||||||
asJson.getObject(requestPollField)
|
asJson.getObject(requestPollField)
|
||||||
)
|
)
|
||||||
@ -74,13 +75,13 @@ internal object KeyboardButtonSerializer : KSerializer<KeyboardButton> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, obj: KeyboardButton) {
|
override fun serialize(encoder: Encoder, value: KeyboardButton) {
|
||||||
when (obj) {
|
when (value) {
|
||||||
is RequestContactKeyboardButton -> RequestContactKeyboardButton.serializer().serialize(encoder, obj)
|
is RequestContactKeyboardButton -> RequestContactKeyboardButton.serializer().serialize(encoder, value)
|
||||||
is RequestLocationKeyboardButton -> RequestLocationKeyboardButton.serializer().serialize(encoder, obj)
|
is RequestLocationKeyboardButton -> RequestLocationKeyboardButton.serializer().serialize(encoder, value)
|
||||||
is RequestPollKeyboardButton -> RequestPollKeyboardButton.serializer().serialize(encoder, obj)
|
is RequestPollKeyboardButton -> RequestPollKeyboardButton.serializer().serialize(encoder, value)
|
||||||
is SimpleKeyboardButton -> encoder.encodeString(obj.text)
|
is SimpleKeyboardButton -> encoder.encodeString(value.text)
|
||||||
is UnknownKeyboardButton -> JsonElementSerializer.serialize(encoder, Json.nonstrict.parseJson(obj.raw))
|
is UnknownKeyboardButton -> JsonElementSerializer.serialize(encoder, nonstrictJsonFormat.parseJson(value.raw))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,12 +42,12 @@ internal object KeyboardButtonPollTypeSerializer : KSerializer<KeyboardButtonPol
|
|||||||
/**
|
/**
|
||||||
* Crutch due to the fact that direct serialization of objects currently does not work perfectly
|
* Crutch due to the fact that direct serialization of objects currently does not work perfectly
|
||||||
*/
|
*/
|
||||||
override fun serialize(encoder: Encoder, obj: KeyboardButtonPollType) {
|
override fun serialize(encoder: Encoder, value: KeyboardButtonPollType) {
|
||||||
JsonObjectSerializer.serialize(
|
JsonObjectSerializer.serialize(
|
||||||
encoder,
|
encoder,
|
||||||
JsonObject(
|
JsonObject(
|
||||||
mapOf(
|
mapOf(
|
||||||
typeField to JsonPrimitive(obj.type)
|
typeField to JsonPrimitive(value.type)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -5,13 +5,16 @@ import kotlinx.serialization.internal.StringDescriptor
|
|||||||
|
|
||||||
@Serializer(KeyboardMarkup::class)
|
@Serializer(KeyboardMarkup::class)
|
||||||
internal object KeyboardMarkupSerializer : KSerializer<KeyboardMarkup> {
|
internal object KeyboardMarkupSerializer : KSerializer<KeyboardMarkup> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName(KeyboardMarkup::class.toString())
|
override val descriptor: SerialDescriptor = SerialDescriptor(
|
||||||
override fun serialize(encoder: Encoder, obj: KeyboardMarkup) {
|
KeyboardMarkup::class.toString(),
|
||||||
when(obj) {
|
PolymorphicKind.OPEN
|
||||||
is ForceReply -> ForceReply.serializer().serialize(encoder, obj)
|
)
|
||||||
is InlineKeyboardMarkup -> InlineKeyboardMarkup.serializer().serialize(encoder, obj)
|
override fun serialize(encoder: Encoder, value: KeyboardMarkup) {
|
||||||
is ReplyKeyboardMarkup -> ReplyKeyboardMarkup.serializer().serialize(encoder, obj)
|
when(value) {
|
||||||
is ReplyKeyboardRemove -> ReplyKeyboardRemove.serializer().serialize(encoder, obj)
|
is ForceReply -> ForceReply.serializer().serialize(encoder, value)
|
||||||
|
is InlineKeyboardMarkup -> InlineKeyboardMarkup.serializer().serialize(encoder, value)
|
||||||
|
is ReplyKeyboardMarkup -> ReplyKeyboardMarkup.serializer().serialize(encoder, value)
|
||||||
|
is ReplyKeyboardRemove -> ReplyKeyboardRemove.serializer().serialize(encoder, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,16 +5,15 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.UnknownChatType
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.UnknownChatType
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.extended.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.extended.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.LongSerializer
|
import kotlinx.serialization.builtins.serializer
|
||||||
import kotlinx.serialization.internal.StringDescriptor
|
|
||||||
import kotlinx.serialization.json.Json
|
|
||||||
import kotlinx.serialization.json.JsonObjectSerializer
|
import kotlinx.serialization.json.JsonObjectSerializer
|
||||||
|
|
||||||
private val formatter = Json.nonstrict
|
private val formatter = nonstrictJsonFormat
|
||||||
|
|
||||||
internal object PreviewChatSerializer : KSerializer<Chat> {
|
internal object PreviewChatSerializer : KSerializer<Chat> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("PreviewChatSerializer")
|
override val descriptor: SerialDescriptor = SerialDescriptor("PreviewChatSerializer", PolymorphicKind.OPEN)
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): Chat {
|
override fun deserialize(decoder: Decoder): Chat {
|
||||||
val decodedJson = JsonObjectSerializer.deserialize(decoder)
|
val decodedJson = JsonObjectSerializer.deserialize(decoder)
|
||||||
@ -27,25 +26,25 @@ internal object PreviewChatSerializer : KSerializer<Chat> {
|
|||||||
"supergroup" -> formatter.fromJson(SupergroupChatImpl.serializer(), decodedJson)
|
"supergroup" -> formatter.fromJson(SupergroupChatImpl.serializer(), decodedJson)
|
||||||
"channel" -> formatter.fromJson(ChannelChatImpl.serializer(), decodedJson)
|
"channel" -> formatter.fromJson(ChannelChatImpl.serializer(), decodedJson)
|
||||||
else -> UnknownChatType(
|
else -> UnknownChatType(
|
||||||
formatter.fromJson(LongSerializer, decodedJson.getPrimitive(chatIdField)).toChatId(),
|
formatter.fromJson(Long.serializer(), decodedJson.getPrimitive(chatIdField)).toChatId(),
|
||||||
decodedJson.toString()
|
decodedJson.toString()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, obj: Chat) {
|
override fun serialize(encoder: Encoder, value: Chat) {
|
||||||
when (obj) {
|
when (value) {
|
||||||
is ExtendedChat -> ExtendedChatSerializer.serialize(encoder, obj)
|
is ExtendedChat -> ExtendedChatSerializer.serialize(encoder, value)
|
||||||
is PrivateChatImpl -> PrivateChatImpl.serializer().serialize(encoder, obj)
|
is PrivateChatImpl -> PrivateChatImpl.serializer().serialize(encoder, value)
|
||||||
is GroupChatImpl -> GroupChatImpl.serializer().serialize(encoder, obj)
|
is GroupChatImpl -> GroupChatImpl.serializer().serialize(encoder, value)
|
||||||
is SupergroupChatImpl -> SupergroupChatImpl.serializer().serialize(encoder, obj)
|
is SupergroupChatImpl -> SupergroupChatImpl.serializer().serialize(encoder, value)
|
||||||
is ChannelChatImpl -> ChannelChatImpl.serializer().serialize(encoder, obj)
|
is ChannelChatImpl -> ChannelChatImpl.serializer().serialize(encoder, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal object ExtendedChatSerializer : KSerializer<ExtendedChat> {
|
internal object ExtendedChatSerializer : KSerializer<ExtendedChat> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("PreviewChatSerializer")
|
override val descriptor: SerialDescriptor = SerialDescriptor("PreviewChatSerializer", PolymorphicKind.OPEN)
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): ExtendedChat {
|
override fun deserialize(decoder: Decoder): ExtendedChat {
|
||||||
val decodedJson = JsonObjectSerializer.deserialize(decoder)
|
val decodedJson = JsonObjectSerializer.deserialize(decoder)
|
||||||
@ -61,12 +60,12 @@ internal object ExtendedChatSerializer : KSerializer<ExtendedChat> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, obj: ExtendedChat) {
|
override fun serialize(encoder: Encoder, value: ExtendedChat) {
|
||||||
when (obj) {
|
when (value) {
|
||||||
is ExtendedPrivateChatImpl -> ExtendedPrivateChatImpl.serializer().serialize(encoder, obj)
|
is ExtendedPrivateChatImpl -> ExtendedPrivateChatImpl.serializer().serialize(encoder, value)
|
||||||
is ExtendedGroupChatImpl -> ExtendedGroupChatImpl.serializer().serialize(encoder, obj)
|
is ExtendedGroupChatImpl -> ExtendedGroupChatImpl.serializer().serialize(encoder, value)
|
||||||
is ExtendedSupergroupChatImpl -> ExtendedSupergroupChatImpl.serializer().serialize(encoder, obj)
|
is ExtendedSupergroupChatImpl -> ExtendedSupergroupChatImpl.serializer().serialize(encoder, value)
|
||||||
is ExtendedChannelChatImpl -> ExtendedChannelChatImpl.serializer().serialize(encoder, obj)
|
is ExtendedChannelChatImpl -> ExtendedChannelChatImpl.serializer().serialize(encoder, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.FileUniqueId
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.fileUniqueIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.fileUniqueIdField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.*
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.ArrayListSerializer
|
import kotlinx.serialization.builtins.ListSerializer
|
||||||
|
|
||||||
typealias Photo = List<PhotoSize>
|
typealias Photo = List<PhotoSize>
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ fun Photo.biggest(): PhotoSize? = maxBy {
|
|||||||
it.resolution
|
it.resolution
|
||||||
}
|
}
|
||||||
|
|
||||||
internal object PhotoSerializer : KSerializer<Photo> by ArrayListSerializer(
|
internal object PhotoSerializer : KSerializer<Photo> by ListSerializer(
|
||||||
PhotoSize.serializer()
|
PhotoSize.serializer()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ data class UnknownMessageType(
|
|||||||
) : Message
|
) : Message
|
||||||
|
|
||||||
internal class TelegramBotAPIMessageDeserializationStrategyClass<T> : DeserializationStrategy<T> {
|
internal class TelegramBotAPIMessageDeserializationStrategyClass<T> : DeserializationStrategy<T> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("TelegramBotAPIMessageSerializer")
|
override val descriptor: SerialDescriptor = SerialDescriptor("TelegramBotAPIMessageSerializer", PolymorphicKind.OPEN)
|
||||||
|
|
||||||
override fun patch(decoder: Decoder, old: T): T = throw UpdateNotSupportedException(descriptor.name)
|
override fun patch(decoder: Decoder, old: T): T = throw UpdateNotSupportedException("TelegramBotAPIMessageSerializer")
|
||||||
override fun deserialize(decoder: Decoder): T {
|
override fun deserialize(decoder: Decoder): T {
|
||||||
return RawMessage.serializer().deserialize(decoder).asMessage as T
|
return RawMessage.serializer().deserialize(decoder).asMessage as T
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ internal class TelegramBotAPIMessageDeserializeOnlySerializerClass<T : Message>
|
|||||||
return deserializer.deserialize(decoder)
|
return deserializer.deserialize(decoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, obj: T) {
|
override fun serialize(encoder: Encoder, value: T) {
|
||||||
throw UnsupportedOperationException("Currently, Message objects can't be serialized y this serializer")
|
throw UnsupportedOperationException("Currently, Message objects can't be serialized y this serializer")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.payments
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.abstracts.Priced
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.abstracts.Priced
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.ArrayListSerializer
|
import kotlinx.serialization.builtins.ListSerializer
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class ShippingOption(
|
data class ShippingOption(
|
||||||
@ -16,6 +16,6 @@ data class ShippingOption(
|
|||||||
override val prices: List<LabeledPrice>
|
override val prices: List<LabeledPrice>
|
||||||
) : Priced
|
) : Priced
|
||||||
|
|
||||||
internal object LabeledPricesSerializer : KSerializer<List<LabeledPrice>> by ArrayListSerializer(
|
internal object LabeledPricesSerializer : KSerializer<List<LabeledPrice>> by ListSerializer(
|
||||||
LabeledPrice.serializer()
|
LabeledPrice.serializer()
|
||||||
)
|
)
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.polls
|
package com.github.insanusmokrassar.TelegramBotAPI.types.polls
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.ArrayListSerializer
|
import kotlinx.serialization.builtins.ListSerializer
|
||||||
import kotlinx.serialization.json.*
|
import kotlinx.serialization.json.*
|
||||||
|
|
||||||
@Serializable(PollSerializer::class)
|
@Serializable(PollSerializer::class)
|
||||||
@ -73,23 +74,23 @@ data class QuizPoll(
|
|||||||
|
|
||||||
@Serializer(Poll::class)
|
@Serializer(Poll::class)
|
||||||
internal object PollSerializer : KSerializer<Poll> {
|
internal object PollSerializer : KSerializer<Poll> {
|
||||||
private val pollOptionsSerializer = ArrayListSerializer(PollOption.serializer())
|
private val pollOptionsSerializer = ListSerializer(PollOption.serializer())
|
||||||
override fun deserialize(decoder: Decoder): Poll {
|
override fun deserialize(decoder: Decoder): Poll {
|
||||||
val asJson = JsonObjectSerializer.deserialize(decoder)
|
val asJson = JsonObjectSerializer.deserialize(decoder)
|
||||||
|
|
||||||
return when (asJson.getPrimitive(typeField).content) {
|
return when (asJson.getPrimitive(typeField).content) {
|
||||||
regularPollType -> Json.nonstrict.fromJson(
|
regularPollType -> nonstrictJsonFormat.fromJson(
|
||||||
RegularPoll.serializer(),
|
RegularPoll.serializer(),
|
||||||
asJson
|
asJson
|
||||||
)
|
)
|
||||||
quizPollType -> Json.nonstrict.fromJson(
|
quizPollType -> nonstrictJsonFormat.fromJson(
|
||||||
QuizPoll.serializer(),
|
QuizPoll.serializer(),
|
||||||
asJson
|
asJson
|
||||||
)
|
)
|
||||||
else -> UnknownPollType(
|
else -> UnknownPollType(
|
||||||
asJson.getPrimitive(idField).content,
|
asJson.getPrimitive(idField).content,
|
||||||
asJson.getPrimitive(questionField).content,
|
asJson.getPrimitive(questionField).content,
|
||||||
Json.nonstrict.fromJson(
|
nonstrictJsonFormat.fromJson(
|
||||||
pollOptionsSerializer,
|
pollOptionsSerializer,
|
||||||
asJson.getArray(optionsField)
|
asJson.getArray(optionsField)
|
||||||
),
|
),
|
||||||
@ -101,17 +102,17 @@ internal object PollSerializer : KSerializer<Poll> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, obj: Poll) {
|
override fun serialize(encoder: Encoder, value: Poll) {
|
||||||
val asJson = when (obj) {
|
val asJson = when (value) {
|
||||||
is RegularPoll -> Json.nonstrict.toJson(RegularPoll.serializer(), obj)
|
is RegularPoll -> nonstrictJsonFormat.toJson(RegularPoll.serializer(), value)
|
||||||
is QuizPoll -> Json.nonstrict.toJson(QuizPoll.serializer(), obj)
|
is QuizPoll -> nonstrictJsonFormat.toJson(QuizPoll.serializer(), value)
|
||||||
is UnknownPollType -> throw IllegalArgumentException("Currently unable to correctly serialize object of poll $obj")
|
is UnknownPollType -> throw IllegalArgumentException("Currently unable to correctly serialize object of poll $value")
|
||||||
}
|
}
|
||||||
val resultJson = JsonObject(
|
val resultJson = JsonObject(
|
||||||
asJson.jsonObject + (typeField to when (obj) {
|
asJson.jsonObject + (typeField to when (value) {
|
||||||
is RegularPoll -> JsonPrimitive(regularPollType)
|
is RegularPoll -> JsonPrimitive(regularPollType)
|
||||||
is QuizPoll -> JsonPrimitive(quizPollType)
|
is QuizPoll -> JsonPrimitive(quizPollType)
|
||||||
is UnknownPollType -> throw IllegalArgumentException("Currently unable to correctly serialize object of poll $obj")
|
is UnknownPollType -> throw IllegalArgumentException("Currently unable to correctly serialize object of poll $value")
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
JsonObjectSerializer.serialize(encoder, resultJson)
|
JsonObjectSerializer.serialize(encoder, resultJson)
|
||||||
|
@ -20,17 +20,17 @@ data class SimplePollOption (
|
|||||||
) : PollOption()
|
) : PollOption()
|
||||||
|
|
||||||
internal object PollOptionSerializer : KSerializer<PollOption> {
|
internal object PollOptionSerializer : KSerializer<PollOption> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName(PollOption::class.simpleName ?: "PollOption")
|
override val descriptor: SerialDescriptor = SimplePollOption.serializer().descriptor
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): PollOption = SimplePollOption.serializer().deserialize(
|
override fun deserialize(decoder: Decoder): PollOption = SimplePollOption.serializer().deserialize(
|
||||||
decoder
|
decoder
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, obj: PollOption) {
|
override fun serialize(encoder: Encoder, value: PollOption) {
|
||||||
when (obj) {
|
when (value) {
|
||||||
is SimplePollOption -> SimplePollOption.serializer().serialize(
|
is SimplePollOption -> SimplePollOption.serializer().serialize(
|
||||||
encoder,
|
encoder,
|
||||||
obj
|
value
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.RawUpdate
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.RawUpdate
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.StringDescriptor
|
|
||||||
import kotlinx.serialization.json.Json
|
|
||||||
import kotlinx.serialization.json.JsonElementSerializer
|
import kotlinx.serialization.json.JsonElementSerializer
|
||||||
|
|
||||||
interface Update {
|
interface Update {
|
||||||
@ -18,21 +17,21 @@ data class UnknownUpdateType(
|
|||||||
) : Update
|
) : Update
|
||||||
|
|
||||||
internal object UpdateSerializerWithoutDeserialization : KSerializer<Update> {
|
internal object UpdateSerializerWithoutDeserialization : KSerializer<Update> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("UpdateSerializerWithoutDeserialization")
|
override val descriptor: SerialDescriptor = JsonElementSerializer.descriptor
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): Update = UpdateDeserializationStrategy.deserialize(decoder)
|
override fun deserialize(decoder: Decoder): Update = UpdateDeserializationStrategy.deserialize(decoder)
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, obj: Update) = throw UnsupportedOperationException()
|
override fun serialize(encoder: Encoder, value: Update) = throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal object UpdateDeserializationStrategy : DeserializationStrategy<Update> {
|
internal object UpdateDeserializationStrategy : DeserializationStrategy<Update> {
|
||||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("UpdateDeserializationStrategy")
|
override val descriptor: SerialDescriptor = JsonElementSerializer.descriptor
|
||||||
|
|
||||||
override fun patch(decoder: Decoder, old: Update): Update = throw UpdateNotSupportedException(descriptor.name)
|
override fun patch(decoder: Decoder, old: Update): Update = throw UpdateNotSupportedException("Update")
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): Update {
|
override fun deserialize(decoder: Decoder): Update {
|
||||||
val asJson = JsonElementSerializer.deserialize(decoder)
|
val asJson = JsonElementSerializer.deserialize(decoder)
|
||||||
return Json.nonstrict.fromJson(
|
return nonstrictJsonFormat.fromJson(
|
||||||
RawUpdate.serializer(),
|
RawUpdate.serializer(),
|
||||||
asJson
|
asJson
|
||||||
).asUpdate(
|
).asUpdate(
|
||||||
|
@ -3,9 +3,16 @@ package com.github.insanusmokrassar.TelegramBotAPI.utils
|
|||||||
import kotlinx.serialization.SerializationStrategy
|
import kotlinx.serialization.SerializationStrategy
|
||||||
import kotlinx.serialization.json.*
|
import kotlinx.serialization.json.*
|
||||||
|
|
||||||
|
val nonstrictJsonFormat = Json {
|
||||||
|
isLenient = true
|
||||||
|
ignoreUnknownKeys = true
|
||||||
|
serializeSpecialFloatingPointValues = true
|
||||||
|
useArrayPolymorphism = true
|
||||||
|
}
|
||||||
|
|
||||||
inline fun <T: Any> T.toJsonWithoutNulls(serializer: SerializationStrategy<T>): JsonObject = toJson(serializer).withoutNulls()
|
inline fun <T: Any> T.toJsonWithoutNulls(serializer: SerializationStrategy<T>): JsonObject = toJson(serializer).withoutNulls()
|
||||||
|
|
||||||
inline fun <T: Any> T.toJson(serializer: SerializationStrategy<T>): JsonObject = Json.nonstrict.toJson(
|
inline fun <T: Any> T.toJson(serializer: SerializationStrategy<T>): JsonObject = nonstrictJsonFormat.toJson(
|
||||||
serializer,
|
serializer,
|
||||||
this
|
this
|
||||||
).jsonObject
|
).jsonObject
|
||||||
|
Loading…
Reference in New Issue
Block a user