1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-23 02:28:45 +00:00

Merge pull request #44 from InsanusMokrassar/0.19.0

0.19.0
This commit is contained in:
InsanusMokrassar 2019-12-02 14:56:41 +06:00 committed by GitHub
commit 498efc2ec3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
113 changed files with 382 additions and 404 deletions

View File

@ -1,5 +1,35 @@
# TelegramBotAPI changelog # TelegramBotAPI changelog
## 0.19.0 ImplicitReflection removing
* Total rework of serialization for requests. Now all `SimpleRequest` children have:
* `requestSerializer` - field, which must provide serializer of current type
* `resultDeserializer` - field, which must provide opportunity to deserializer result. Previously it was a function
* Removed deprecations:
* `com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.WebhookPrivateKeyConfig`
* `com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.UpdatesFilter`
* `com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.createSimpleUpdateFilter`
* `com.github.insanusmokrassar.TelegramBotAPI.utils.createMarkdownText`
* `com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaption`
* `com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownText`
* `com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.KtorUpdatesPoller`
* `com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent`
* `com.github.insanusmokrassar.TelegramBotAPI.types.message.CommonForwardedMessage`
* `com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.CaptionedInputMedia`
* `com.github.insanusmokrassar.TelegramBotAPI.types.games.Game#text`
* `com.github.insanusmokrassar.TelegramBotAPI.types.games.Game#textEntities`
* `com.github.insanusmokrassar.TelegramBotAPI.types.files.PathedFileKt.makeFileUrl`
* `com.github.insanusmokrassar.TelegramBotAPI.types.files.PathedFileKt.downloadingFilesBaseUrl`
* `com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.Data`
* `com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ByInlineMessageId`
* `com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ByMessageId`
* `com.github.insanusmokrassar.TelegramBotAPI.bot.RequestException`
* `com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.ReplyMessageNotFound`
* `com.github.insanusmokrassar.TelegramBotAPI.bot.BaseRequestsExecutor#baseUrl`
* `com.github.insanusmokrassar.TelegramBotAPI.bot.BaseRequestsExecutor#constructor(token, hostUrl)`
* `com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorRequestsExecutor#constructor(token, client, hostUrl, callsFactories, excludeDefaultFactories, requestsLimiter, jsonFormatter)`
* `com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorRequestsExecutor#constructor(token, engine, hostUrl)`
## 0.18.0 Raws cleaning ## 0.18.0 Raws cleaning
* Made internal and not available outside of library: * Made internal and not available outside of library:

View File

@ -1,4 +1,4 @@
project.version = "0.18.1" project.version = "0.19.0"
project.group = "com.github.insanusmokrassar" project.group = "com.github.insanusmokrassar"
buildscript { buildscript {
@ -42,9 +42,3 @@ dependencies {
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
} }
compileKotlin {
kotlinOptions {
freeCompilerArgs = [ disableImplicitReflectionSerializerAnnotation ]
}
}

View File

@ -9,5 +9,3 @@ gradle_bintray_plugin_version=1.8.4
project_public_name=Telegram Bot API project_public_name=Telegram Bot API
project_public_description=Library for Object-Oriented and type-safe work with Telegram Bot API project_public_description=Library for Object-Oriented and type-safe work with Telegram Bot API
disableImplicitReflectionSerializerAnnotation=-Xexperimental=kotlinx.serialization.ImplicitReflectionSerializer

View File

@ -1,7 +0,0 @@
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
@Deprecated(
"Deprecated for the reason of creating of more obvious type interface",
ReplaceWith("InlineMessageAction", "com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.InlineMessageAction")
)
typealias ByInlineMessageId = InlineMessageAction

View File

@ -1,8 +0,0 @@
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
@Deprecated(
"Deprecated for the reason of creating of more obvious type interface",
ReplaceWith("MessageAction", "com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction")
)
typealias ByMessageId = MessageAction

View File

@ -4,14 +4,4 @@ import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
abstract class BaseRequestsExecutor( abstract class BaseRequestsExecutor(
protected val telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper protected val telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper
) : RequestsExecutor { ) : RequestsExecutor
@Deprecated("Deprecated due to new TelegramAPIUrlKeeper API", ReplaceWith("telegramAPIUrlsKeeper.commonAPIUrl"))
protected val baseUrl: String
get() = telegramAPIUrlsKeeper.commonAPIUrl
@Deprecated("Deprecated due to new TelegramAPIUrlKeeper API")
constructor(
token: String,
hostUrl: String = "https://api.telegram.org"
) : this (TelegramAPIUrlsKeeper(token, hostUrl))
}

View File

@ -25,28 +25,6 @@ class KtorRequestsExecutor(
private val requestsLimiter: RequestLimiter = EmptyLimiter, private val requestsLimiter: RequestLimiter = EmptyLimiter,
private val jsonFormatter: Json = Json.nonstrict private val jsonFormatter: Json = Json.nonstrict
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) { ) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
@Deprecated("Deprecated due to new TelegramAPIUrlKeeper API")
constructor(
token: String,
client: HttpClient = HttpClient(),
hostUrl: String = "https://api.telegram.org",
callsFactories: List<KtorCallFactory> = emptyList(),
excludeDefaultFactories: Boolean = false,
requestsLimiter: RequestLimiter = EmptyLimiter,
jsonFormatter: Json = Json.nonstrict
) : this(TelegramAPIUrlsKeeper(token, hostUrl), client, callsFactories, excludeDefaultFactories, requestsLimiter, jsonFormatter)
@Deprecated("Deprecated due to new TelegramAPIUrlKeeper API")
constructor(
token: String,
engine: HttpClientEngine? = null,
hostUrl: String = "https://api.telegram.org"
) : this(
TelegramAPIUrlsKeeper(token, hostUrl),
engine ?.let { HttpClient(engine) } ?: HttpClient()
)
private val callsFactories: List<KtorCallFactory> = callsFactories.run { private val callsFactories: List<KtorCallFactory> = callsFactories.run {
if (!excludeDefaultFactories) { if (!excludeDefaultFactories) {
asSequence().plus(SimpleRequestCallFactory()).plus(MultipartRequestCallFactory()).toList() asSequence().plus(SimpleRequestCallFactory()).plus(MultipartRequestCallFactory()).toList()
@ -77,7 +55,7 @@ class KtorRequestsExecutor(
val responseObject = jsonFormatter.parse(Response.serializer(), content) val responseObject = jsonFormatter.parse(Response.serializer(), content)
(responseObject.result ?.let { (responseObject.result ?.let {
jsonFormatter.fromJson(request.resultDeserializer(), it) jsonFormatter.fromJson(request.resultDeserializer, it)
} ?: responseObject.parameters ?.let { } ?: responseObject.parameters ?.let {
val error = it.error val error = it.error
if (error is RetryAfterError) { if (error is RetryAfterError) {

View File

@ -12,12 +12,11 @@ class SimpleRequestCallFactory : AbstractRequestCallFactory() {
baseUrl: String, baseUrl: String,
request: Request<T> request: Request<T>
): Any? = (request as? SimpleRequest<T>) ?.let { _ -> ): Any? = (request as? SimpleRequest<T>) ?.let { _ ->
val content = request.toJsonWithoutNulls(SimpleRequestSerializer).toString() val content = request.json().toString()
TextContent( TextContent(
content, content,
ContentType.Application.Json ContentType.Application.Json
) )
} }
} }

View File

@ -1,12 +0,0 @@
package com.github.insanusmokrassar.TelegramBotAPI.bot
import com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.RequestException
@Deprecated(
"Replaced to another package",
ReplaceWith(
"RequestException",
"com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.RequestException"
)
)
typealias RequestException = RequestException

View File

@ -32,9 +32,3 @@ class UnauthorizedException(response: Response, plainAnswer: String, message: St
class ReplyMessageNotFoundException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) : class ReplyMessageNotFoundException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
RequestException(response, plainAnswer, message, cause) RequestException(response, plainAnswer, message, cause)
@Deprecated(
"Replaced by ReplyMessageNotFoundException",
ReplaceWith("ReplyMessageNotFoundException", "com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.ReplyMessageNotFoundException")
)
typealias ReplyMessageNotFound = ReplyMessageNotFoundException

View File

@ -15,5 +15,8 @@ data class DeleteMessage(
) : SimpleRequest<Boolean>, MessageAction { ) : SimpleRequest<Boolean>, MessageAction {
override fun method(): String = "deleteMessage" override fun method(): String = "deleteMessage"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -24,5 +24,8 @@ data class ForwardMessage(
override fun method(): String = "forwardMessage" override fun method(): String = "forwardMessage"
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -2,11 +2,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
import com.github.insanusmokrassar.TelegramBotAPI.types.User import com.github.insanusmokrassar.TelegramBotAPI.types.User
import kotlinx.serialization.KSerializer import kotlinx.serialization.*
import kotlinx.serialization.Serializable
@Serializable @Serializable
class GetMe : SimpleRequest<User> { class GetMe : SimpleRequest<User> {
override fun method(): String = "getMe" override fun method(): String = "getMe"
override fun resultDeserializer(): KSerializer<User> = User.serializer() override val resultDeserializer: DeserializationStrategy<User>
get() = User.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -5,10 +5,13 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
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.KSerializer import kotlinx.serialization.*
import kotlinx.serialization.Serializable
import kotlinx.serialization.internal.ArrayListSerializer import kotlinx.serialization.internal.ArrayListSerializer
private val updatesListSerializer = ArrayListSerializer(
UpdateSerializerWithoutDeserialization
)
@Serializable @Serializable
data class GetUpdates( data class GetUpdates(
val offset: UpdateIdentifier? = null,// set `last update id + 1` to receive next part of updates val offset: UpdateIdentifier? = null,// set `last update id + 1` to receive next part of updates
@ -18,7 +21,9 @@ data class GetUpdates(
): SimpleRequest<List<Update>> { ): SimpleRequest<List<Update>> {
override fun method(): String = "getUpdates" override fun method(): String = "getUpdates"
override fun resultDeserializer(): KSerializer<List<Update>> = ArrayListSerializer( override val resultDeserializer: DeserializationStrategy<List<Update>>
UpdateSerializerWithoutDeserialization get() = updatesListSerializer
)
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -18,5 +18,8 @@ data class StopPoll(
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : MessageAction, SimpleRequest<Poll>, ReplyMarkup { ) : MessageAction, SimpleRequest<Poll>, ReplyMarkup {
override fun method(): String = "stopPoll" override fun method(): String = "stopPoll"
override fun resultDeserializer(): KSerializer<Poll> = Poll.serializer() override val resultDeserializer: DeserializationStrategy<Poll>
get() = Poll.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -1,13 +1,8 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.json.JsonObject
@Serializable(RequestSerializer::class)
interface Request<T: Any> { interface Request<T: Any> {
fun method(): String fun method(): String
fun resultDeserializer(): DeserializationStrategy<T> val resultDeserializer: DeserializationStrategy<T>
fun json(): JsonObject = toJsonWithoutNulls(RequestSerializer)
} }
object RequestSerializer : KSerializer<Request<*>> by ContextSerializer(Request::class)

View File

@ -1,8 +1,12 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts
import kotlinx.serialization.* import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
import kotlinx.serialization.SerializationStrategy
import kotlinx.serialization.json.JsonObject
@Serializable(SimpleRequestSerializer::class) interface SimpleRequest<T: Any> : Request<T> {
interface SimpleRequest<T: Any> : Request<T> val requestSerializer: SerializationStrategy<*>
}
object SimpleRequestSerializer : KSerializer<SimpleRequest<*>> by ContextSerializer(SimpleRequest::class) @Suppress("UNCHECKED_CAST")
inline fun <T: Any, K: SimpleRequest<T>> K.json(): JsonObject = toJsonWithoutNulls(requestSerializer as SerializationStrategy<K>)

View File

@ -20,7 +20,10 @@ data class AnswerCallbackQuery(
val cachedTimeSeconds: Int? = null val cachedTimeSeconds: Int? = null
) : SimpleRequest<Boolean> { ) : SimpleRequest<Boolean> {
override fun method(): String = "answerCallbackQuery" override fun method(): String = "answerCallbackQuery"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }
fun CallbackQuery.createAnswer( fun CallbackQuery.createAnswer(

View File

@ -28,7 +28,10 @@ data class AnswerInlineQuery(
val switchPmParameter: String? = null val switchPmParameter: String? = null
): SimpleRequest<Boolean> { ): SimpleRequest<Boolean> {
override fun method(): String = "answerInlineQuery" override fun method(): String = "answerInlineQuery"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }
fun InlineQuery.createAnswer( fun InlineQuery.createAnswer(

View File

@ -3,8 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abstracts.AnswerPreCheckoutQuery import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abstracts.AnswerPreCheckoutQuery
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery
import kotlinx.serialization.SerialName import kotlinx.serialization.*
import kotlinx.serialization.Serializable
@Serializable @Serializable
data class AnswerPreCheckoutQueryOk( data class AnswerPreCheckoutQueryOk(
@ -13,6 +12,8 @@ data class AnswerPreCheckoutQueryOk(
) : AnswerPreCheckoutQuery { ) : AnswerPreCheckoutQuery {
@SerialName(okField) @SerialName(okField)
override val isOk: Boolean = true override val isOk: Boolean = true
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }
@ -25,6 +26,8 @@ data class AnswerPreCheckoutQueryError(
) : AnswerPreCheckoutQuery { ) : AnswerPreCheckoutQuery {
@SerialName(okField) @SerialName(okField)
override val isOk: Boolean = false override val isOk: Boolean = false
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }
fun PreCheckoutQuery.createAnswerOk(): AnswerPreCheckoutQueryOk = AnswerPreCheckoutQueryOk( fun PreCheckoutQuery.createAnswerOk(): AnswerPreCheckoutQueryOk = AnswerPreCheckoutQueryOk(

View File

@ -17,6 +17,8 @@ data class AnswerShippingQueryOk(
) : AnswerShippingQuery { ) : AnswerShippingQuery {
@SerialName(okField) @SerialName(okField)
override val isOk: Boolean = true override val isOk: Boolean = true
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }
object ShippingOptionsSerializer : KSerializer<List<ShippingOption>> by ArrayListSerializer( object ShippingOptionsSerializer : KSerializer<List<ShippingOption>> by ArrayListSerializer(
@ -32,6 +34,8 @@ data class AnswerShippingQueryError(
) : AnswerShippingQuery { ) : AnswerShippingQuery {
@SerialName(okField) @SerialName(okField)
override val isOk: Boolean = false override val isOk: Boolean = false
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }
fun ShippingQuery.createAnswerOk( fun ShippingQuery.createAnswerOk(

View File

@ -3,11 +3,13 @@ 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.serializer import kotlinx.serialization.serializer
interface AnswerPreCheckoutQuery : SimpleRequest<Boolean> { interface AnswerPreCheckoutQuery : SimpleRequest<Boolean> {
override fun method(): String = "answerPreCheckoutQuery" override fun method(): String = "answerPreCheckoutQuery"
override fun resultDeserializer(): KSerializer<Boolean> = Boolean.serializer() override val resultDeserializer: KSerializer<Boolean>
get() = BooleanSerializer
val preCheckoutQueryId: PreCheckoutQueryId val preCheckoutQueryId: PreCheckoutQueryId
val isOk: Boolean val isOk: Boolean

View File

@ -2,12 +2,13 @@ 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.KSerializer import kotlinx.serialization.*
import kotlinx.serialization.serializer import kotlinx.serialization.internal.BooleanSerializer
interface AnswerShippingQuery : SimpleRequest<Boolean> { interface AnswerShippingQuery : SimpleRequest<Boolean> {
override fun method(): String = "answerShippingQuery" override fun method(): String = "answerShippingQuery"
override fun resultDeserializer(): KSerializer<Boolean> = Boolean.serializer() override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
val shippingQueryId: ShippingQueryIdentifier val shippingQueryId: ShippingQueryIdentifier
val isOk: Boolean val isOk: Boolean

View File

@ -13,5 +13,8 @@ data class ExportChatInviteLink(
override val chatId: ChatIdentifier override val chatId: ChatIdentifier
): ChatRequest, SimpleRequest<String> { ): ChatRequest, SimpleRequest<String> {
override fun method(): String = "exportChatInviteLink" override fun method(): String = "exportChatInviteLink"
override fun resultDeserializer(): KSerializer<String> = StringSerializer override val resultDeserializer: DeserializationStrategy<String>
get() = StringSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -13,5 +13,8 @@ data class LeaveChat(
override val chatId: ChatIdentifier override val chatId: ChatIdentifier
): ChatRequest, SimpleRequest<Boolean> { ): ChatRequest, SimpleRequest<Boolean> {
override fun method(): String = "leaveChat" override fun method(): String = "leaveChat"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -14,5 +14,8 @@ data class GetChat(
override val chatId: ChatIdentifier override val chatId: ChatIdentifier
): ChatRequest, SimpleRequest<ExtendedChat> { ): ChatRequest, SimpleRequest<ExtendedChat> {
override fun method(): String = "getChat" override fun method(): String = "getChat"
override fun resultDeserializer(): KSerializer<ExtendedChat> = ExtendedChatSerializer override val resultDeserializer: DeserializationStrategy<ExtendedChat>
get() = ExtendedChatSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -9,13 +9,18 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.internal.ArrayListSerializer import kotlinx.serialization.internal.ArrayListSerializer
private val chatMembersListSerializer = ArrayListSerializer(
ChatMemberSerializerWithoutDeserialization
)
@Serializable @Serializable
data class GetChatAdministrators( data class GetChatAdministrators(
@SerialName(chatIdField) @SerialName(chatIdField)
override val chatId: ChatIdentifier override val chatId: ChatIdentifier
): ChatRequest, SimpleRequest<List<ChatMember>> { ): ChatRequest, SimpleRequest<List<ChatMember>> {
override fun method(): String = "getChatAdministrators" override fun method(): String = "getChatAdministrators"
override fun resultDeserializer(): KSerializer<List<ChatMember>> = ArrayListSerializer( override val resultDeserializer: DeserializationStrategy<List<ChatMember>>
ChatMemberSerializerWithoutDeserialization get() = chatMembersListSerializer
) override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -13,5 +13,8 @@ data class GetChatMembersCount(
override val chatId: ChatIdentifier override val chatId: ChatIdentifier
): ChatRequest, SimpleRequest<Int> { ): ChatRequest, SimpleRequest<Int> {
override fun method(): String = "getChatMembersCount" override fun method(): String = "getChatMembersCount"
override fun resultDeserializer(): KSerializer<Int> = IntSerializer override val resultDeserializer: DeserializationStrategy<Int>
get() = IntSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -14,5 +14,8 @@ data class GetChatMember(
override val userId: UserId override val userId: UserId
) : ChatMemberRequest<ChatMember> { ) : ChatMemberRequest<ChatMember> {
override fun method(): String = "getChatMember" override fun method(): String = "getChatMember"
override fun resultDeserializer(): DeserializationStrategy<ChatMember> = ChatMemberDeserializationStrategy override val resultDeserializer: DeserializationStrategy<ChatMember>
get() = ChatMemberDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -16,5 +16,8 @@ data class KickChatMember(
override val untilDate: TelegramDate? = null override val untilDate: TelegramDate? = null
) : ChatMemberRequest<Boolean>, UntilDate { ) : ChatMemberRequest<Boolean>, UntilDate {
override fun method(): String = "kickChatMember" override fun method(): String = "kickChatMember"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -32,5 +32,8 @@ data class PromoteChatMember(
private val canPromoteMembers: Boolean? = null private val canPromoteMembers: Boolean? = null
) : ChatMemberRequest<Boolean>, UntilDate { ) : ChatMemberRequest<Boolean>, UntilDate {
override fun method(): String = "promoteChatMember" override fun method(): String = "promoteChatMember"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -19,5 +19,8 @@ data class RestrictChatMember(
val permissions: ChatPermissions val permissions: ChatPermissions
) : ChatMemberRequest<Boolean>, UntilDate { ) : ChatMemberRequest<Boolean>, UntilDate {
override fun method(): String = "restrictChatMember" override fun method(): String = "restrictChatMember"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -13,5 +13,8 @@ data class UnbanChatMember(
override val userId: UserId override val userId: UserId
) : ChatMemberRequest<Boolean> { ) : ChatMemberRequest<Boolean> {
override fun method(): String = "unbanChatMember" override fun method(): String = "unbanChatMember"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -13,5 +13,8 @@ data class DeleteChatPhoto(
override val chatId: ChatIdentifier override val chatId: ChatIdentifier
): ChatRequest, SimpleRequest<Boolean> { ): ChatRequest, SimpleRequest<Boolean> {
override fun method(): String = "deleteChatPhoto" override fun method(): String = "deleteChatPhoto"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -16,5 +16,8 @@ data class PinChatMessage (
override val disableNotification: Boolean = false override val disableNotification: Boolean = false
): ChatRequest, SimpleRequest<Boolean>, MessageAction, DisableNotification { ): ChatRequest, SimpleRequest<Boolean>, MessageAction, DisableNotification {
override fun method(): String = "pinChatMessage" override fun method(): String = "pinChatMessage"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -20,5 +20,8 @@ data class SetChatDescription (
} }
override fun method(): String = "setChatDescription" override fun method(): String = "setChatDescription"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -15,5 +15,8 @@ data class SetChatPermissions (
val permissions: ChatPermissions val permissions: ChatPermissions
): ChatRequest, SimpleRequest<Boolean> { ): ChatRequest, SimpleRequest<Boolean> {
override fun method(): String = "setChatPermissions" override fun method(): String = "setChatPermissions"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -16,7 +16,8 @@ data class SetChatPhoto (
val photo: MultipartFile = throw IllegalArgumentException("Unfortunately, this type of objects can't be parsed automatically") val photo: MultipartFile = throw IllegalArgumentException("Unfortunately, this type of objects can't be parsed automatically")
): ChatRequest, MultipartRequest<Boolean> { ): ChatRequest, MultipartRequest<Boolean> {
override fun method(): String = "setChatPhoto" override fun method(): String = "setChatPhoto"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
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())
} }

View File

@ -20,5 +20,8 @@ data class SetChatTitle (
} }
override fun method(): String = "setChatTitle" override fun method(): String = "setChatTitle"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -13,5 +13,8 @@ data class UnpinChatMessage(
override val chatId: ChatIdentifier override val chatId: ChatIdentifier
): ChatRequest, SimpleRequest<Boolean> { ): ChatRequest, SimpleRequest<Boolean> {
override fun method(): String = "unpinChatMessage" override fun method(): String = "unpinChatMessage"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -13,5 +13,8 @@ data class DeleteChatStickerSet(
override val chatId: ChatIdentifier override val chatId: ChatIdentifier
): ChatRequest, SimpleRequest<Boolean> { ): ChatRequest, SimpleRequest<Boolean> {
override fun method(): String = "deleteChatStickerSet" override fun method(): String = "deleteChatStickerSet"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -14,5 +14,8 @@ data class SetChatStickerSet(
val stickerSetName: StickerSetName val stickerSetName: StickerSetName
): ChatRequest, SimpleRequest<Boolean> { ): ChatRequest, SimpleRequest<Boolean> {
override fun method(): String = "setChatStickerSet" override fun method(): String = "setChatStickerSet"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonObject
data class CommonMultipartFileRequest<T: Any>( data class CommonMultipartFileRequest<T: Any>(
val data: Request<T>, val data: SimpleRequest<T>,
override val mediaMap: Map<String, MultipartFile> override val mediaMap: Map<String, MultipartFile>
) : MultipartRequest<T>, Request<T> by data { ) : MultipartRequest<T>, Request<T> by data {
override val paramsJson: JsonObject = data.json() override val paramsJson: JsonObject = data.json()

View File

@ -21,5 +21,8 @@ data class EditChatMessageLiveLocation(
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditChatMessage, EditReplyMessage, EditLocationMessage { ) : EditChatMessage, EditReplyMessage, EditLocationMessage {
override fun method(): String = "editMessageLiveLocation" override fun method(): String = "editMessageLiveLocation"
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -1,10 +1,10 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption.EditInlineMessageCaption
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import kotlinx.serialization.SerialName import kotlinx.serialization.*
import kotlinx.serialization.Serializable
@Serializable @Serializable
data class EditInlineMessageLiveLocation( data class EditInlineMessageLiveLocation(
@ -18,4 +18,6 @@ data class EditInlineMessageLiveLocation(
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditInlineMessage, EditReplyMessage, EditLocationMessage { ) : EditInlineMessage, EditReplyMessage, EditLocationMessage {
override fun method(): String = "editMessageLiveLocation" override fun method(): String = "editMessageLiveLocation"
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -18,5 +18,8 @@ data class StopChatMessageLiveLocation(
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditChatMessage, EditReplyMessage { ) : EditChatMessage, EditReplyMessage {
override fun method(): String = "stopMessageLiveLocation" override fun method(): String = "stopMessageLiveLocation"
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -4,8 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditIn
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import kotlinx.serialization.SerialName import kotlinx.serialization.*
import kotlinx.serialization.Serializable
@Serializable @Serializable
data class StopInlineMessageLiveLocation( data class StopInlineMessageLiveLocation(
@ -15,4 +14,6 @@ data class StopInlineMessageLiveLocation(
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditInlineMessage, EditReplyMessage { ) : EditInlineMessage, EditReplyMessage {
override fun method(): String = "stopMessageLiveLocation" override fun method(): String = "stopMessageLiveLocation"
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -21,5 +21,8 @@ data class EditChatMessageReplyMarkup(
) : EditChatMessage, EditReplyMessage { ) : EditChatMessage, EditReplyMessage {
override fun method(): String = editMessageReplyMarkupMethod override fun method(): String = editMessageReplyMarkupMethod
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -1,11 +1,11 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation.EditInlineMessageLiveLocation
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditInlineMessage import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditInlineMessage
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import kotlinx.serialization.SerialName import kotlinx.serialization.*
import kotlinx.serialization.Serializable
@Serializable @Serializable
data class EditInlineMessageReplyMarkup( data class EditInlineMessageReplyMarkup(
@ -15,4 +15,6 @@ data class EditInlineMessageReplyMarkup(
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditInlineMessage, EditReplyMessage { ) : EditInlineMessage, EditReplyMessage {
override fun method(): String = editMessageReplyMarkupMethod override fun method(): String = editMessageReplyMarkupMethod
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -2,10 +2,11 @@ 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.KSerializer import kotlinx.serialization.*
import kotlinx.serialization.internal.BooleanSerializer import kotlinx.serialization.internal.BooleanSerializer
interface EditInlineMessage : SimpleRequest<Boolean> { interface EditInlineMessage : SimpleRequest<Boolean> {
val inlineMessageId: InlineMessageIdentifier val inlineMessageId: InlineMessageIdentifier
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
} }

View File

@ -26,5 +26,8 @@ data class EditChatMessageCaption(
) : EditChatMessage, EditTextChatMessage, EditReplyMessage { ) : EditChatMessage, EditTextChatMessage, EditReplyMessage {
override fun method(): String = editMessageCaptionMethod override fun method(): String = editMessageCaptionMethod
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -5,8 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import kotlinx.serialization.SerialName import kotlinx.serialization.*
import kotlinx.serialization.Serializable
@Serializable @Serializable
data class EditInlineMessageCaption( data class EditInlineMessageCaption(
@ -20,4 +19,6 @@ data class EditInlineMessageCaption(
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage { ) : EditInlineMessage, EditTextChatMessage, EditReplyMessage {
override fun method(): String = editMessageCaptionMethod override fun method(): String = editMessageCaptionMethod
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -30,5 +30,8 @@ data class EditChatMessageMedia(
} }
override fun method(): String = editMessageMediaMethod override fun method(): String = editMessageMediaMethod
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -1,12 +1,12 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation.EditInlineMessageLiveLocation
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import kotlinx.serialization.SerialName import kotlinx.serialization.*
import kotlinx.serialization.Serializable
@Serializable @Serializable
data class EditInlineMessageMedia( data class EditInlineMessageMedia(
@ -23,6 +23,8 @@ data class EditInlineMessageMedia(
throw IllegalArgumentException("For editing of media messages you MUST use file id (according to documentation)") throw IllegalArgumentException("For editing of media messages you MUST use file id (according to documentation)")
} }
} }
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
override fun method(): String = editMessageMediaMethod override fun method(): String = editMessageMediaMethod
} }

View File

@ -28,5 +28,8 @@ data class EditChatMessageText(
) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage { ) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
override fun method(): String = editMessageTextMethod override fun method(): String = editMessageTextMethod
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -1,13 +1,13 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation.EditInlineMessageLiveLocation
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.editMessageMediaMethod import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.editMessageMediaMethod
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import kotlinx.serialization.SerialName import kotlinx.serialization.*
import kotlinx.serialization.Serializable
@Serializable @Serializable
data class EditInlineMessageText( data class EditInlineMessageText(
@ -23,4 +23,6 @@ data class EditInlineMessageText(
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage { ) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
override fun method(): String = editMessageMediaMethod override fun method(): String = editMessageMediaMethod
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -3,8 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import kotlinx.serialization.SerialName import kotlinx.serialization.*
import kotlinx.serialization.Serializable
@Serializable @Serializable
data class GetGameHighScoresByChat ( data class GetGameHighScoresByChat (
@ -14,4 +13,7 @@ data class GetGameHighScoresByChat (
override val chatId: ChatId, override val chatId: ChatId,
@SerialName(messageIdField) @SerialName(messageIdField)
override val messageId: MessageIdentifier override val messageId: MessageIdentifier
) : GetGameHighScores, MessageAction ) : GetGameHighScores, MessageAction {
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@ -3,8 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.InlineMessageAction import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.InlineMessageAction
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import kotlinx.serialization.SerialName import kotlinx.serialization.*
import kotlinx.serialization.Serializable
@Serializable @Serializable
data class GetGameHighScoresByInlineMessageId ( data class GetGameHighScoresByInlineMessageId (
@ -12,4 +11,7 @@ data class GetGameHighScoresByInlineMessageId (
override val userId: UserId, override val userId: UserId,
@SerialName(inlineMessageIdField) @SerialName(inlineMessageIdField)
override val inlineMessageId: InlineMessageIdentifier override val inlineMessageId: InlineMessageIdentifier
) : GetGameHighScores, InlineMessageAction ) : GetGameHighScores, InlineMessageAction {
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@ -3,8 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.SetGameScore import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.SetGameScore
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import kotlinx.serialization.SerialName import kotlinx.serialization.*
import kotlinx.serialization.Serializable
@Serializable @Serializable
data class SetGameScoreByChatId ( data class SetGameScoreByChatId (
@ -20,4 +19,7 @@ data class SetGameScoreByChatId (
override val force: Boolean = false, override val force: Boolean = false,
@SerialName(disableEditMessageField) @SerialName(disableEditMessageField)
override val disableEditMessage: Boolean = false override val disableEditMessage: Boolean = false
) : SetGameScore, MessageAction ) : SetGameScore, MessageAction {
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@ -3,8 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.InlineMessageAction import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.InlineMessageAction
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.SetGameScore import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.SetGameScore
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import kotlinx.serialization.SerialName import kotlinx.serialization.*
import kotlinx.serialization.Serializable
@Serializable @Serializable
data class SetGameScoreByInlineMessageId ( data class SetGameScoreByInlineMessageId (
@ -18,4 +17,7 @@ data class SetGameScoreByInlineMessageId (
override val force: Boolean = false, override val force: Boolean = false,
@SerialName(disableEditMessageField) @SerialName(disableEditMessageField)
override val disableEditMessage: Boolean = false override val disableEditMessage: Boolean = false
) : SetGameScore, InlineMessageAction ) : SetGameScore, InlineMessageAction {
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@ -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 com.github.insanusmokrassar.TelegramBotAPI.types.games.GameHighScore import com.github.insanusmokrassar.TelegramBotAPI.types.games.GameHighScore
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.KSerializer import kotlinx.serialization.KSerializer
import kotlinx.serialization.internal.ArrayListSerializer import kotlinx.serialization.internal.ArrayListSerializer
@ -10,7 +11,8 @@ interface GetGameHighScores : SimpleRequest<List<GameHighScore>> {
val userId: UserId val userId: UserId
override fun method(): String = "getGameHighScores" override fun method(): String = "getGameHighScores"
override fun resultDeserializer(): KSerializer<List<GameHighScore>> = GameHighScoresSerializer override val resultDeserializer: DeserializationStrategy<List<GameHighScore>>
get() = GameHighScoresSerializer
} }
object GameHighScoresSerializer : KSerializer<List<GameHighScore>> by ArrayListSerializer(GameHighScore.serializer()) object GameHighScoresSerializer : KSerializer<List<GameHighScore>> by ArrayListSerializer(GameHighScore.serializer())

View File

@ -2,8 +2,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.KSerializer import kotlinx.serialization.*
import kotlinx.serialization.serializer
interface SetGameScore : SimpleRequest<Boolean> { interface SetGameScore : SimpleRequest<Boolean> {
val userId: UserId val userId: UserId
@ -12,5 +11,6 @@ interface SetGameScore : SimpleRequest<Boolean> {
val disableEditMessage: Boolean val disableEditMessage: Boolean
override fun method(): String = "setGameScore" override fun method(): String = "setGameScore"
override fun resultDeserializer(): KSerializer<Boolean> = Boolean.serializer() override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
} }

View File

@ -12,5 +12,8 @@ data class GetFile(
val fileId: FileId val fileId: FileId
): SimpleRequest<PathedFile> { ): SimpleRequest<PathedFile> {
override fun method(): String = "getFile" override fun method(): String = "getFile"
override fun resultDeserializer(): KSerializer<PathedFile> = PathedFile.serializer() override val resultDeserializer: DeserializationStrategy<PathedFile>
get() = PathedFile.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -11,5 +11,8 @@ data class GetStickerSet(
val name: String val name: String
): SimpleRequest<StickerSet> { ): SimpleRequest<StickerSet> {
override fun method(): String = "getStickerSet" override fun method(): String = "getStickerSet"
override fun resultDeserializer(): KSerializer<StickerSet> = StickerSet.serializer() override val resultDeserializer: DeserializationStrategy<StickerSet>
get() = StickerSet.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -23,5 +23,8 @@ data class GetUserProfilePhotos(
} }
override fun method(): String = "getUserProfilePhotos" override fun method(): String = "getUserProfilePhotos"
override fun resultDeserializer(): KSerializer<UserProfilePhotos> = UserProfilePhotos.serializer() override val resultDeserializer: DeserializationStrategy<UserProfilePhotos>
get() = UserProfilePhotos.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -17,5 +17,8 @@ data class SendAction(
val action: BotAction val action: BotAction
): SendChatMessageRequest<Boolean> { ): SendChatMessageRequest<Boolean> {
override fun method(): String = "sendChatAction" override fun method(): String = "sendChatAction"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -44,7 +44,10 @@ data class SendContact(
) )
override fun method(): String = "sendContact" override fun method(): String = "sendContact"
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }
fun Contact.toRequest( fun Contact.toRequest(

View File

@ -30,5 +30,8 @@ data class SendLocation(
{ {
override fun method(): String = "sendLocation" override fun method(): String = "sendLocation"
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -38,5 +38,8 @@ data class SendMessage(
} }
override fun method(): String = "sendMessage" override fun method(): String = "sendMessage"
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -40,5 +40,8 @@ data class SendPoll(
} }
override fun method(): String = "sendPoll" override fun method(): String = "sendPoll"
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -51,7 +51,10 @@ data class SendVenue(
) )
override fun method(): String = "sendVenue" override fun method(): String = "sendVenue"
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }
fun Venue.toRequest( fun Venue.toRequest(

View File

@ -23,5 +23,8 @@ data class SendGame (
) : SendMessageRequest<Message>, ) : SendMessageRequest<Message>,
ReplyMarkup { ReplyMarkup {
override fun method(): String = "sendGame" override fun method(): String = "sendGame"
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -95,7 +95,10 @@ data class SendAnimationData internal constructor(
} }
override fun method(): String = "sendAnimation" override fun method(): String = "sendAnimation"
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }
data class SendAnimationFiles internal constructor( data class SendAnimationFiles internal constructor(

View File

@ -97,7 +97,10 @@ data class SendAudioData internal constructor(
} }
override fun method(): String = "sendAudio" override fun method(): String = "sendAudio"
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }
data class SendAudioFiles internal constructor( data class SendAudioFiles internal constructor(

View File

@ -81,7 +81,10 @@ data class SendDocumentData internal constructor(
} }
override fun method(): String = "sendDocument" override fun method(): String = "sendDocument"
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }
data class SendDocumentFiles internal constructor( data class SendDocumentFiles internal constructor(

View File

@ -53,7 +53,7 @@ fun SendMediaGroup(
} }
} }
private val serializer = ArrayListSerializer(TelegramBotAPIMessageDeserializeOnlySerializer) private val messagesListSerializer = ArrayListSerializer(TelegramBotAPIMessageDeserializeOnlySerializer)
@Serializable @Serializable
data class SendMediaGroupData internal constructor( data class SendMediaGroupData internal constructor(
@ -64,9 +64,7 @@ data class SendMediaGroupData internal constructor(
override val disableNotification: Boolean = false, override val disableNotification: Boolean = false,
@SerialName(replyToMessageIdField) @SerialName(replyToMessageIdField)
override val replyToMessageId: MessageIdentifier? = null override val replyToMessageId: MessageIdentifier? = null
) : DataRequest<List<Message>>, ) : DataRequest<List<Message>>, SendMessageRequest<List<Message>> {
SendMessageRequest<List<Message>>
{
@SerialName(mediaField) @SerialName(mediaField)
private val convertedMedia: String private val convertedMedia: String
get() = jsonArray { get() = jsonArray {
@ -77,7 +75,10 @@ data class SendMediaGroupData internal constructor(
override fun method(): String = "sendMediaGroup" override fun method(): String = "sendMediaGroup"
override fun resultDeserializer(): DeserializationStrategy<List<Message>> = serializer override val requestSerializer: SerializationStrategy<*>
get() = serializer()
override val resultDeserializer: DeserializationStrategy<List<Message>>
get() = messagesListSerializer
} }
data class SendMediaGroupFiles internal constructor( data class SendMediaGroupFiles internal constructor(

View File

@ -67,7 +67,10 @@ data class SendPhotoData internal constructor(
} }
override fun method(): String = "sendPhoto" override fun method(): String = "sendPhoto"
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }
data class SendPhotoFiles internal constructor( data class SendPhotoFiles internal constructor(

View File

@ -44,7 +44,10 @@ data class SendStickerByFileId internal constructor(
override val replyMarkup: KeyboardMarkup? = null override val replyMarkup: KeyboardMarkup? = null
) : SendMessageRequest<Message>, ReplyingMarkupSendMessageRequest<Message> { ) : SendMessageRequest<Message>, ReplyingMarkupSendMessageRequest<Message> {
override fun method(): String = "sendSticker" override fun method(): String = "sendSticker"
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }
data class SendStickerByFile internal constructor( data class SendStickerByFile internal constructor(

View File

@ -99,7 +99,10 @@ data class SendVideoData internal constructor(
} }
override fun method(): String = "sendVideo" override fun method(): String = "sendVideo"
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }
data class SendVideoFiles internal constructor( data class SendVideoFiles internal constructor(

View File

@ -82,7 +82,6 @@ data class SendVideoNoteData internal constructor(
DuratedSendMessageRequest<Message>, DuratedSendMessageRequest<Message>,
SizedSendMessageRequest<Message> SizedSendMessageRequest<Message>
{ {
@Transient
override val height: Int? override val height: Int?
get() = width get() = width
@ -95,7 +94,10 @@ data class SendVideoNoteData internal constructor(
} }
override fun method(): String = "sendVideoNote" override fun method(): String = "sendVideoNote"
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }
data class SendVideoNoteFiles internal constructor( data class SendVideoNoteFiles internal constructor(

View File

@ -86,7 +86,10 @@ data class SendVoiceData internal constructor(
} }
override fun method(): String = "sendVoice" override fun method(): String = "sendVoice"
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }
data class SendVoiceFiles internal constructor( data class SendVoiceFiles internal constructor(

View File

@ -1,10 +0,0 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base
@Deprecated(
"Renamed to DataRequest",
ReplaceWith(
"DataRequest",
"com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.DataRequest"
)
)
typealias Data<T> = DataRequest<T>

View File

@ -3,7 +3,4 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
import kotlinx.serialization.* import kotlinx.serialization.*
@Serializable(DataRequestSerializer::class)
interface DataRequest<T: Any> : SimpleRequest<T> interface DataRequest<T: Any> : SimpleRequest<T>
object DataRequestSerializer : KSerializer<DataRequest<*>> by ContextSerializer(DataRequest::class)

View File

@ -1,8 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartRequest import kotlinx.serialization.*
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonObject
/** /**
@ -13,7 +12,8 @@ class MultipartRequestImpl<D: DataRequest<R>, F: Files, R: Any>(
val files: F val files: F
) : MultipartRequest<R> { ) : MultipartRequest<R> {
override fun method(): String = data.method() override fun method(): String = data.method()
override fun resultDeserializer(): DeserializationStrategy<R> = data.resultDeserializer() override val resultDeserializer: DeserializationStrategy<R>
get() = data.resultDeserializer
override val paramsJson: JsonObject = data.json() override val paramsJson: JsonObject = data.json()
override val mediaMap: Map<String, MultipartFile> = files override val mediaMap: Map<String, MultipartFile> = files
} }

View File

@ -65,7 +65,10 @@ data class SendInvoice(
ReplyMarkup, ReplyMarkup,
SendMessageRequest<Message> { SendMessageRequest<Message> {
override fun method(): String = "sendInvoice" override fun method(): String = "sendInvoice"
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy override val resultDeserializer: DeserializationStrategy<Message>
get() = TelegramBotAPIMessageDeserializationStrategy
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
@SerialName(photoUrlField) @SerialName(photoUrlField)
var photoUrl: String? = null var photoUrl: String? = null

View File

@ -5,8 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipar
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
import kotlinx.serialization.SerialName import kotlinx.serialization.*
import kotlinx.serialization.Serializable
fun AddStickerToSet( fun AddStickerToSet(
userId: UserId, userId: UserId,
@ -44,5 +43,8 @@ data class AddStickerToSet internal constructor(
} }
} }
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
override fun method(): String = "addStickerToSet" override fun method(): String = "addStickerToSet"
} }

View File

@ -5,8 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.common.CommonMultipar
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.abstracts.StickerSetAction
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
import kotlinx.serialization.SerialName import kotlinx.serialization.*
import kotlinx.serialization.Serializable
fun CreateNewStickerSet( fun CreateNewStickerSet(
userId: UserId, userId: UserId,
@ -47,5 +46,8 @@ data class CreateNewStickerSet internal constructor(
} }
} }
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
override fun method(): String = "createNewStickerSet" override fun method(): String = "createNewStickerSet"
} }

View File

@ -12,5 +12,8 @@ data class DeleteStickerFromSet(
val sticker: FileId val sticker: FileId
) : SimpleRequest<Boolean> { ) : SimpleRequest<Boolean> {
override fun method(): String = "deleteStickerFromSet" override fun method(): String = "deleteStickerFromSet"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -21,5 +21,8 @@ data class SetStickerPositionInSet(
} }
override fun method(): String = "setStickerPositionInSet" override fun method(): String = "setStickerPositionInSet"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -24,5 +24,6 @@ data class UploadStickerFile(
override val mediaMap: Map<String, MultipartFile> = mapOf(pngStickerField to sticker) override val mediaMap: Map<String, MultipartFile> = mapOf(pngStickerField to sticker)
@Transient @Transient
override val paramsJson: JsonObject = toJsonWithoutNulls(serializer()) override val paramsJson: JsonObject = toJsonWithoutNulls(serializer())
override fun resultDeserializer(): KSerializer<File> = File.serializer() override val resultDeserializer: DeserializationStrategy<File>
get() = File.serializer()
} }

View File

@ -12,5 +12,6 @@ interface StickerSetAction : SimpleRequest<Boolean> {
val emojis: String // must be more than one val emojis: String // must be more than one
val maskPosition: MaskPosition? val maskPosition: MaskPosition?
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: KSerializer<Boolean>
get() = BooleanSerializer
} }

View File

@ -1,13 +1,15 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.webhook 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.KSerializer import kotlinx.serialization.*
import kotlinx.serialization.Serializable
import kotlinx.serialization.internal.BooleanSerializer import kotlinx.serialization.internal.BooleanSerializer
@Serializable @Serializable
class DeleteWebhook : SimpleRequest<Boolean> { class DeleteWebhook : SimpleRequest<Boolean> {
override fun method(): String = "deleteWebhook" override fun method(): String = "deleteWebhook"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -2,12 +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 com.github.insanusmokrassar.TelegramBotAPI.types.WebhookInfo import com.github.insanusmokrassar.TelegramBotAPI.types.WebhookInfo
import kotlinx.serialization.KSerializer import kotlinx.serialization.*
import kotlinx.serialization.Serializable
@Serializable @Serializable
class GetWebhookInfo : SimpleRequest<WebhookInfo> { class GetWebhookInfo : SimpleRequest<WebhookInfo> {
override fun method(): String = "getWebhookInfo" override fun method(): String = "getWebhookInfo"
override fun resultDeserializer(): KSerializer<WebhookInfo> = WebhookInfo.serializer() override val resultDeserializer: DeserializationStrategy<WebhookInfo>
get() = WebhookInfo.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
} }

View File

@ -51,7 +51,10 @@ data class SetWebhook internal constructor(
val allowedUpdates: List<String>? = null val allowedUpdates: List<String>? = null
) : DataRequest<Boolean> { ) : DataRequest<Boolean> {
override fun method(): String = "setWebhook" override fun method(): String = "setWebhook"
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer override val resultDeserializer: DeserializationStrategy<Boolean>
get() = BooleanSerializer
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
init { init {
maxAllowedConnections ?.let { maxAllowedConnections ?.let {

View File

@ -21,7 +21,6 @@ internal data class RawCallbackQuery(
@SerialName("game_short_name") @SerialName("game_short_name")
val gameShortName: String? = null val gameShortName: String? = null
) { ) {
@Transient
val asCallbackQuery: CallbackQuery by lazy { val asCallbackQuery: CallbackQuery by lazy {
when { when {
message != null && data != null -> MessageDataCallbackQuery(id, from, chatInstance, message, data) message != null && data != null -> MessageDataCallbackQuery(id, from, chatInstance, message, data)

View File

@ -40,7 +40,6 @@ internal data class RawChatMember(
@SerialName(canAddWebPagePreviewsField) @SerialName(canAddWebPagePreviewsField)
private val canAddWebPagePreviews: Boolean = false private val canAddWebPagePreviews: Boolean = false
) { ) {
@Transient
val asChatMember: ChatMember by lazy { val asChatMember: ChatMember by lazy {
when (status) { when (status) {
"creator" -> CreatorChatMember(user) "creator" -> CreatorChatMember(user)

View File

@ -17,7 +17,6 @@ internal data class RawChosenInlineResult(
@SerialName(inlineMessageIdField) @SerialName(inlineMessageIdField)
val inlineMessageId: InlineMessageIdentifier? = null val inlineMessageId: InlineMessageIdentifier? = null
) { ) {
@Transient
val asChosenInlineResult: ChosenInlineResult by lazy { val asChosenInlineResult: ChosenInlineResult by lazy {
location ?.let { location ?.let {
LocationChosenInlineResult(resultId, user, location, inlineMessageId, query) LocationChosenInlineResult(resultId, user, location, inlineMessageId, query)

View File

@ -16,7 +16,6 @@ internal data class RawInlineQuery(
@SerialName(locationField) @SerialName(locationField)
val location: Location? = null val location: Location? = null
) { ) {
@Transient
val asInlineQuery by lazy { val asInlineQuery by lazy {
location ?.let { location ?.let {
LocationInlineQuery(id, from, query, offset, location) LocationInlineQuery(id, from, query, offset, location)

View File

@ -1,9 +0,0 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
@Deprecated(
"Deprecated due to replace by common type CaptionedOutput",
ReplaceWith("CaptionedOutput", "com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput")
)
typealias CaptionedInputMedia = CaptionedOutput

View File

@ -11,7 +11,6 @@ data class ResponseParametersRaw(
) { ) {
@Transient @Transient
private val createTime: Long = System.currentTimeMillis() private val createTime: Long = System.currentTimeMillis()
@Transient
val error: RequestError? by lazy { val error: RequestError? by lazy {
when { when {
migrateToChatId != null -> MigrateChatId(migrateToChatId); migrateToChatId != null -> MigrateChatId(migrateToChatId);

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