mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
commit
498efc2ec3
30
CHANGELOG.md
30
CHANGELOG.md
@ -1,5 +1,35 @@
|
||||
# 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
|
||||
|
||||
* Made internal and not available outside of library:
|
||||
|
@ -1,4 +1,4 @@
|
||||
project.version = "0.18.1"
|
||||
project.version = "0.19.0"
|
||||
project.group = "com.github.insanusmokrassar"
|
||||
|
||||
buildscript {
|
||||
@ -42,9 +42,3 @@ dependencies {
|
||||
|
||||
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs = [ disableImplicitReflectionSerializerAnnotation ]
|
||||
}
|
||||
}
|
||||
|
@ -9,5 +9,3 @@ gradle_bintray_plugin_version=1.8.4
|
||||
|
||||
project_public_name=Telegram Bot API
|
||||
project_public_description=Library for Object-Oriented and type-safe work with Telegram Bot API
|
||||
|
||||
disableImplicitReflectionSerializerAnnotation=-Xexperimental=kotlinx.serialization.ImplicitReflectionSerializer
|
||||
|
@ -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
|
@ -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
|
@ -4,14 +4,4 @@ import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
|
||||
|
||||
abstract class BaseRequestsExecutor(
|
||||
protected val telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper
|
||||
) : 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))
|
||||
}
|
||||
) : RequestsExecutor
|
||||
|
@ -25,28 +25,6 @@ class KtorRequestsExecutor(
|
||||
private val requestsLimiter: RequestLimiter = EmptyLimiter,
|
||||
private val jsonFormatter: Json = Json.nonstrict
|
||||
) : 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 {
|
||||
if (!excludeDefaultFactories) {
|
||||
asSequence().plus(SimpleRequestCallFactory()).plus(MultipartRequestCallFactory()).toList()
|
||||
@ -77,7 +55,7 @@ class KtorRequestsExecutor(
|
||||
val responseObject = jsonFormatter.parse(Response.serializer(), content)
|
||||
|
||||
(responseObject.result ?.let {
|
||||
jsonFormatter.fromJson(request.resultDeserializer(), it)
|
||||
jsonFormatter.fromJson(request.resultDeserializer, it)
|
||||
} ?: responseObject.parameters ?.let {
|
||||
val error = it.error
|
||||
if (error is RetryAfterError) {
|
||||
|
@ -12,12 +12,11 @@ class SimpleRequestCallFactory : AbstractRequestCallFactory() {
|
||||
baseUrl: String,
|
||||
request: Request<T>
|
||||
): Any? = (request as? SimpleRequest<T>) ?.let { _ ->
|
||||
val content = request.toJsonWithoutNulls(SimpleRequestSerializer).toString()
|
||||
val content = request.json().toString()
|
||||
|
||||
TextContent(
|
||||
content,
|
||||
ContentType.Application.Json
|
||||
)
|
||||
}
|
||||
|
||||
}
|
@ -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
|
@ -32,9 +32,3 @@ class UnauthorizedException(response: Response, plainAnswer: String, message: St
|
||||
|
||||
class ReplyMessageNotFoundException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||
RequestException(response, plainAnswer, message, cause)
|
||||
|
||||
@Deprecated(
|
||||
"Replaced by ReplyMessageNotFoundException",
|
||||
ReplaceWith("ReplyMessageNotFoundException", "com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.ReplyMessageNotFoundException")
|
||||
)
|
||||
typealias ReplyMessageNotFound = ReplyMessageNotFoundException
|
@ -15,5 +15,8 @@ data class DeleteMessage(
|
||||
) : SimpleRequest<Boolean>, MessageAction {
|
||||
override fun method(): String = "deleteMessage"
|
||||
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -24,5 +24,8 @@ data class 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()
|
||||
}
|
||||
|
@ -2,11 +2,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
class GetMe : SimpleRequest<User> {
|
||||
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()
|
||||
}
|
@ -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.update.abstracts.Update
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UpdateSerializerWithoutDeserialization
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.ArrayListSerializer
|
||||
|
||||
private val updatesListSerializer = ArrayListSerializer(
|
||||
UpdateSerializerWithoutDeserialization
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class GetUpdates(
|
||||
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>> {
|
||||
override fun method(): String = "getUpdates"
|
||||
|
||||
override fun resultDeserializer(): KSerializer<List<Update>> = ArrayListSerializer(
|
||||
UpdateSerializerWithoutDeserialization
|
||||
)
|
||||
override val resultDeserializer: DeserializationStrategy<List<Update>>
|
||||
get() = updatesListSerializer
|
||||
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -18,5 +18,8 @@ data class StopPoll(
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : MessageAction, SimpleRequest<Poll>, ReplyMarkup {
|
||||
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()
|
||||
}
|
||||
|
@ -1,13 +1,8 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
@Serializable(RequestSerializer::class)
|
||||
interface Request<T: Any> {
|
||||
fun method(): String
|
||||
fun resultDeserializer(): DeserializationStrategy<T>
|
||||
fun json(): JsonObject = toJsonWithoutNulls(RequestSerializer)
|
||||
val resultDeserializer: DeserializationStrategy<T>
|
||||
}
|
||||
object RequestSerializer : KSerializer<Request<*>> by ContextSerializer(Request::class)
|
||||
|
@ -1,8 +1,12 @@
|
||||
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>)
|
||||
|
@ -20,7 +20,10 @@ data class AnswerCallbackQuery(
|
||||
val cachedTimeSeconds: Int? = null
|
||||
) : SimpleRequest<Boolean> {
|
||||
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(
|
||||
|
@ -28,7 +28,10 @@ data class AnswerInlineQuery(
|
||||
val switchPmParameter: String? = null
|
||||
): SimpleRequest<Boolean> {
|
||||
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(
|
||||
|
@ -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.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class AnswerPreCheckoutQueryOk(
|
||||
@ -13,6 +12,8 @@ data class AnswerPreCheckoutQueryOk(
|
||||
) : AnswerPreCheckoutQuery {
|
||||
@SerialName(okField)
|
||||
override val isOk: Boolean = true
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
|
||||
@ -25,6 +26,8 @@ data class AnswerPreCheckoutQueryError(
|
||||
) : AnswerPreCheckoutQuery {
|
||||
@SerialName(okField)
|
||||
override val isOk: Boolean = false
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
fun PreCheckoutQuery.createAnswerOk(): AnswerPreCheckoutQueryOk = AnswerPreCheckoutQueryOk(
|
||||
|
@ -17,6 +17,8 @@ data class AnswerShippingQueryOk(
|
||||
) : AnswerShippingQuery {
|
||||
@SerialName(okField)
|
||||
override val isOk: Boolean = true
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
object ShippingOptionsSerializer : KSerializer<List<ShippingOption>> by ArrayListSerializer(
|
||||
@ -32,6 +34,8 @@ data class AnswerShippingQueryError(
|
||||
) : AnswerShippingQuery {
|
||||
@SerialName(okField)
|
||||
override val isOk: Boolean = false
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
fun ShippingQuery.createAnswerOk(
|
||||
|
@ -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.types.PreCheckoutQueryId
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
import kotlinx.serialization.serializer
|
||||
|
||||
interface AnswerPreCheckoutQuery : SimpleRequest<Boolean> {
|
||||
override fun method(): String = "answerPreCheckoutQuery"
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = Boolean.serializer()
|
||||
override val resultDeserializer: KSerializer<Boolean>
|
||||
get() = BooleanSerializer
|
||||
|
||||
val preCheckoutQueryId: PreCheckoutQueryId
|
||||
val isOk: Boolean
|
||||
|
@ -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.types.ShippingQueryIdentifier
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.serializer
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
|
||||
interface AnswerShippingQuery : SimpleRequest<Boolean> {
|
||||
override fun method(): String = "answerShippingQuery"
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = Boolean.serializer()
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
|
||||
val shippingQueryId: ShippingQueryIdentifier
|
||||
val isOk: Boolean
|
||||
|
@ -13,5 +13,8 @@ data class ExportChatInviteLink(
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<String> {
|
||||
override fun method(): String = "exportChatInviteLink"
|
||||
override fun resultDeserializer(): KSerializer<String> = StringSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<String>
|
||||
get() = StringSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -13,5 +13,8 @@ data class LeaveChat(
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<Boolean> {
|
||||
override fun method(): String = "leaveChat"
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -14,5 +14,8 @@ data class GetChat(
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<ExtendedChat> {
|
||||
override fun method(): String = "getChat"
|
||||
override fun resultDeserializer(): KSerializer<ExtendedChat> = ExtendedChatSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<ExtendedChat>
|
||||
get() = ExtendedChatSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -9,13 +9,18 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.ArrayListSerializer
|
||||
|
||||
private val chatMembersListSerializer = ArrayListSerializer(
|
||||
ChatMemberSerializerWithoutDeserialization
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class GetChatAdministrators(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<List<ChatMember>> {
|
||||
override fun method(): String = "getChatAdministrators"
|
||||
override fun resultDeserializer(): KSerializer<List<ChatMember>> = ArrayListSerializer(
|
||||
ChatMemberSerializerWithoutDeserialization
|
||||
)
|
||||
override val resultDeserializer: DeserializationStrategy<List<ChatMember>>
|
||||
get() = chatMembersListSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -13,5 +13,8 @@ data class GetChatMembersCount(
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<Int> {
|
||||
override fun method(): String = "getChatMembersCount"
|
||||
override fun resultDeserializer(): KSerializer<Int> = IntSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<Int>
|
||||
get() = IntSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -14,5 +14,8 @@ data class GetChatMember(
|
||||
override val userId: UserId
|
||||
) : ChatMemberRequest<ChatMember> {
|
||||
override fun method(): String = "getChatMember"
|
||||
override fun resultDeserializer(): DeserializationStrategy<ChatMember> = ChatMemberDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ChatMember>
|
||||
get() = ChatMemberDeserializationStrategy
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -16,5 +16,8 @@ data class KickChatMember(
|
||||
override val untilDate: TelegramDate? = null
|
||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||
override fun method(): String = "kickChatMember"
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -32,5 +32,8 @@ data class PromoteChatMember(
|
||||
private val canPromoteMembers: Boolean? = null
|
||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||
override fun method(): String = "promoteChatMember"
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -19,5 +19,8 @@ data class RestrictChatMember(
|
||||
val permissions: ChatPermissions
|
||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||
override fun method(): String = "restrictChatMember"
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -13,5 +13,8 @@ data class UnbanChatMember(
|
||||
override val userId: UserId
|
||||
) : ChatMemberRequest<Boolean> {
|
||||
override fun method(): String = "unbanChatMember"
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -13,5 +13,8 @@ data class DeleteChatPhoto(
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<Boolean> {
|
||||
override fun method(): String = "deleteChatPhoto"
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -16,5 +16,8 @@ data class PinChatMessage (
|
||||
override val disableNotification: Boolean = false
|
||||
): ChatRequest, SimpleRequest<Boolean>, MessageAction, DisableNotification {
|
||||
override fun method(): String = "pinChatMessage"
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -20,5 +20,8 @@ data class 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()
|
||||
}
|
||||
|
@ -15,5 +15,8 @@ data class SetChatPermissions (
|
||||
val permissions: ChatPermissions
|
||||
): ChatRequest, SimpleRequest<Boolean> {
|
||||
override fun method(): String = "setChatPermissions"
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -16,7 +16,8 @@ data class SetChatPhoto (
|
||||
val photo: MultipartFile = throw IllegalArgumentException("Unfortunately, this type of objects can't be parsed automatically")
|
||||
): ChatRequest, MultipartRequest<Boolean> {
|
||||
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 paramsJson: JsonObject = toJson(serializer())
|
||||
}
|
||||
|
@ -20,5 +20,8 @@ data class 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()
|
||||
}
|
||||
|
@ -13,5 +13,8 @@ data class UnpinChatMessage(
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<Boolean> {
|
||||
override fun method(): String = "unpinChatMessage"
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -13,5 +13,8 @@ data class DeleteChatStickerSet(
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<Boolean> {
|
||||
override fun method(): String = "deleteChatStickerSet"
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -14,5 +14,8 @@ data class SetChatStickerSet(
|
||||
val stickerSetName: StickerSetName
|
||||
): ChatRequest, SimpleRequest<Boolean> {
|
||||
override fun method(): String = "setChatStickerSet"
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
data class CommonMultipartFileRequest<T: Any>(
|
||||
val data: Request<T>,
|
||||
val data: SimpleRequest<T>,
|
||||
override val mediaMap: Map<String, MultipartFile>
|
||||
) : MultipartRequest<T>, Request<T> by data {
|
||||
override val paramsJson: JsonObject = data.json()
|
||||
|
@ -21,5 +21,8 @@ data class EditChatMessageLiveLocation(
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : EditChatMessage, EditReplyMessage, EditLocationMessage {
|
||||
override fun method(): String = "editMessageLiveLocation"
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation
|
||||
|
||||
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.buttons.InlineKeyboardMarkup
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class EditInlineMessageLiveLocation(
|
||||
@ -18,4 +18,6 @@ data class EditInlineMessageLiveLocation(
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : EditInlineMessage, EditReplyMessage, EditLocationMessage {
|
||||
override fun method(): String = "editMessageLiveLocation"
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -18,5 +18,8 @@ data class StopChatMessageLiveLocation(
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : EditChatMessage, EditReplyMessage {
|
||||
override fun method(): String = "stopMessageLiveLocation"
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -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.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class StopInlineMessageLiveLocation(
|
||||
@ -15,4 +14,6 @@ data class StopInlineMessageLiveLocation(
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : EditInlineMessage, EditReplyMessage {
|
||||
override fun method(): String = "stopMessageLiveLocation"
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -21,5 +21,8 @@ data class EditChatMessageReplyMarkup(
|
||||
) : EditChatMessage, EditReplyMessage {
|
||||
|
||||
override fun method(): String = editMessageReplyMarkupMethod
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
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.EditReplyMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class EditInlineMessageReplyMarkup(
|
||||
@ -15,4 +15,6 @@ data class EditInlineMessageReplyMarkup(
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : EditInlineMessage, EditReplyMessage {
|
||||
override fun method(): String = editMessageReplyMarkupMethod
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -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.types.InlineMessageIdentifier
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
|
||||
interface EditInlineMessage : SimpleRequest<Boolean> {
|
||||
val inlineMessageId: InlineMessageIdentifier
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
}
|
@ -26,5 +26,8 @@ data class EditChatMessageCaption(
|
||||
) : EditChatMessage, EditTextChatMessage, EditReplyMessage {
|
||||
|
||||
override fun method(): String = editMessageCaptionMethod
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -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.parseModeField
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class EditInlineMessageCaption(
|
||||
@ -20,4 +19,6 @@ data class EditInlineMessageCaption(
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage {
|
||||
override fun method(): String = editMessageCaptionMethod
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -30,5 +30,8 @@ data class EditChatMessageMedia(
|
||||
}
|
||||
|
||||
override fun method(): String = editMessageMediaMethod
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media
|
||||
|
||||
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.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
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)")
|
||||
}
|
||||
}
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
override fun method(): String = editMessageMediaMethod
|
||||
}
|
||||
|
@ -28,5 +28,8 @@ data class EditChatMessageText(
|
||||
) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
||||
|
||||
override fun method(): String = editMessageTextMethod
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
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.media.editMessageMediaMethod
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class EditInlineMessageText(
|
||||
@ -23,4 +23,6 @@ data class EditInlineMessageText(
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
||||
override fun method(): String = editMessageMediaMethod
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -3,8 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class GetGameHighScoresByChat (
|
||||
@ -14,4 +13,7 @@ data class GetGameHighScoresByChat (
|
||||
override val chatId: ChatId,
|
||||
@SerialName(messageIdField)
|
||||
override val messageId: MessageIdentifier
|
||||
) : GetGameHighScores, MessageAction
|
||||
) : GetGameHighScores, MessageAction {
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -3,8 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.InlineMessageAction
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class GetGameHighScoresByInlineMessageId (
|
||||
@ -12,4 +11,7 @@ data class GetGameHighScoresByInlineMessageId (
|
||||
override val userId: UserId,
|
||||
@SerialName(inlineMessageIdField)
|
||||
override val inlineMessageId: InlineMessageIdentifier
|
||||
) : GetGameHighScores, InlineMessageAction
|
||||
) : GetGameHighScores, InlineMessageAction {
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -3,8 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.SetGameScore
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class SetGameScoreByChatId (
|
||||
@ -20,4 +19,7 @@ data class SetGameScoreByChatId (
|
||||
override val force: Boolean = false,
|
||||
@SerialName(disableEditMessageField)
|
||||
override val disableEditMessage: Boolean = false
|
||||
) : SetGameScore, MessageAction
|
||||
) : SetGameScore, MessageAction {
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -3,8 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.InlineMessageAction
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.SetGameScore
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class SetGameScoreByInlineMessageId (
|
||||
@ -18,4 +17,7 @@ data class SetGameScoreByInlineMessageId (
|
||||
override val force: Boolean = false,
|
||||
@SerialName(disableEditMessageField)
|
||||
override val disableEditMessage: Boolean = false
|
||||
) : SetGameScore, InlineMessageAction
|
||||
) : SetGameScore, InlineMessageAction {
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = 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.types.UserId
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.games.GameHighScore
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.internal.ArrayListSerializer
|
||||
|
||||
@ -10,7 +11,8 @@ interface GetGameHighScores : SimpleRequest<List<GameHighScore>> {
|
||||
val userId: UserId
|
||||
|
||||
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())
|
||||
|
@ -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.types.UserId
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.serializer
|
||||
import kotlinx.serialization.*
|
||||
|
||||
interface SetGameScore : SimpleRequest<Boolean> {
|
||||
val userId: UserId
|
||||
@ -12,5 +11,6 @@ interface SetGameScore : SimpleRequest<Boolean> {
|
||||
val disableEditMessage: Boolean
|
||||
|
||||
override fun method(): String = "setGameScore"
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = Boolean.serializer()
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
}
|
@ -12,5 +12,8 @@ data class GetFile(
|
||||
val fileId: FileId
|
||||
): SimpleRequest<PathedFile> {
|
||||
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()
|
||||
}
|
||||
|
@ -11,5 +11,8 @@ data class GetStickerSet(
|
||||
val name: String
|
||||
): SimpleRequest<StickerSet> {
|
||||
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()
|
||||
}
|
||||
|
@ -23,5 +23,8 @@ data class 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()
|
||||
}
|
||||
|
@ -17,5 +17,8 @@ data class SendAction(
|
||||
val action: BotAction
|
||||
): SendChatMessageRequest<Boolean> {
|
||||
override fun method(): String = "sendChatAction"
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -44,7 +44,10 @@ data class 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(
|
||||
|
@ -30,5 +30,8 @@ data class 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()
|
||||
}
|
||||
|
@ -38,5 +38,8 @@ data class 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()
|
||||
}
|
||||
|
@ -40,5 +40,8 @@ data class 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()
|
||||
}
|
@ -51,7 +51,10 @@ data class 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(
|
||||
|
@ -23,5 +23,8 @@ data class SendGame (
|
||||
) : SendMessageRequest<Message>,
|
||||
ReplyMarkup {
|
||||
override fun method(): String = "sendGame"
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
@ -95,7 +95,10 @@ data class SendAnimationData internal constructor(
|
||||
}
|
||||
|
||||
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(
|
||||
|
@ -97,7 +97,10 @@ data class SendAudioData internal constructor(
|
||||
}
|
||||
|
||||
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(
|
||||
|
@ -81,7 +81,10 @@ data class SendDocumentData internal constructor(
|
||||
}
|
||||
|
||||
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(
|
||||
|
@ -53,7 +53,7 @@ fun SendMediaGroup(
|
||||
}
|
||||
}
|
||||
|
||||
private val serializer = ArrayListSerializer(TelegramBotAPIMessageDeserializeOnlySerializer)
|
||||
private val messagesListSerializer = ArrayListSerializer(TelegramBotAPIMessageDeserializeOnlySerializer)
|
||||
|
||||
@Serializable
|
||||
data class SendMediaGroupData internal constructor(
|
||||
@ -64,9 +64,7 @@ data class SendMediaGroupData internal constructor(
|
||||
override val disableNotification: Boolean = false,
|
||||
@SerialName(replyToMessageIdField)
|
||||
override val replyToMessageId: MessageIdentifier? = null
|
||||
) : DataRequest<List<Message>>,
|
||||
SendMessageRequest<List<Message>>
|
||||
{
|
||||
) : DataRequest<List<Message>>, SendMessageRequest<List<Message>> {
|
||||
@SerialName(mediaField)
|
||||
private val convertedMedia: String
|
||||
get() = jsonArray {
|
||||
@ -77,7 +75,10 @@ data class SendMediaGroupData internal constructor(
|
||||
|
||||
|
||||
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(
|
||||
|
@ -67,7 +67,10 @@ data class SendPhotoData internal constructor(
|
||||
}
|
||||
|
||||
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(
|
||||
|
@ -44,7 +44,10 @@ data class SendStickerByFileId internal constructor(
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : SendMessageRequest<Message>, ReplyingMarkupSendMessageRequest<Message> {
|
||||
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(
|
||||
|
@ -99,7 +99,10 @@ data class SendVideoData internal constructor(
|
||||
}
|
||||
|
||||
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(
|
||||
|
@ -82,7 +82,6 @@ data class SendVideoNoteData internal constructor(
|
||||
DuratedSendMessageRequest<Message>,
|
||||
SizedSendMessageRequest<Message>
|
||||
{
|
||||
@Transient
|
||||
override val height: Int?
|
||||
get() = width
|
||||
|
||||
@ -95,7 +94,10 @@ data class SendVideoNoteData internal constructor(
|
||||
}
|
||||
|
||||
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(
|
||||
|
@ -86,7 +86,10 @@ data class SendVoiceData internal constructor(
|
||||
}
|
||||
|
||||
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(
|
||||
|
@ -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>
|
@ -3,7 +3,4 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable(DataRequestSerializer::class)
|
||||
interface DataRequest<T: Any> : SimpleRequest<T>
|
||||
|
||||
object DataRequestSerializer : KSerializer<DataRequest<*>> by ContextSerializer(DataRequest::class)
|
@ -1,8 +1,7 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartRequest
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
/**
|
||||
@ -13,7 +12,8 @@ class MultipartRequestImpl<D: DataRequest<R>, F: Files, R: Any>(
|
||||
val files: F
|
||||
) : MultipartRequest<R> {
|
||||
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 mediaMap: Map<String, MultipartFile> = files
|
||||
}
|
||||
|
@ -65,7 +65,10 @@ data class SendInvoice(
|
||||
ReplyMarkup,
|
||||
SendMessageRequest<Message> {
|
||||
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)
|
||||
var photoUrl: String? = null
|
||||
|
@ -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.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.*
|
||||
|
||||
fun AddStickerToSet(
|
||||
userId: UserId,
|
||||
@ -44,5 +43,8 @@ data class AddStickerToSet internal constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
override fun method(): String = "addStickerToSet"
|
||||
}
|
||||
|
@ -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.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.*
|
||||
|
||||
fun CreateNewStickerSet(
|
||||
userId: UserId,
|
||||
@ -47,5 +46,8 @@ data class CreateNewStickerSet internal constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
override fun method(): String = "createNewStickerSet"
|
||||
}
|
||||
|
@ -12,5 +12,8 @@ data class DeleteStickerFromSet(
|
||||
val sticker: FileId
|
||||
) : SimpleRequest<Boolean> {
|
||||
override fun method(): String = "deleteStickerFromSet"
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -21,5 +21,8 @@ data class 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()
|
||||
}
|
||||
|
@ -24,5 +24,6 @@ data class UploadStickerFile(
|
||||
override val mediaMap: Map<String, MultipartFile> = mapOf(pngStickerField to sticker)
|
||||
@Transient
|
||||
override val paramsJson: JsonObject = toJsonWithoutNulls(serializer())
|
||||
override fun resultDeserializer(): KSerializer<File> = File.serializer()
|
||||
override val resultDeserializer: DeserializationStrategy<File>
|
||||
get() = File.serializer()
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ interface StickerSetAction : SimpleRequest<Boolean> {
|
||||
val emojis: String // must be more than one
|
||||
val maskPosition: MaskPosition?
|
||||
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override val resultDeserializer: KSerializer<Boolean>
|
||||
get() = BooleanSerializer
|
||||
}
|
@ -1,13 +1,15 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.webhook
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.BooleanSerializer
|
||||
|
||||
@Serializable
|
||||
class DeleteWebhook : SimpleRequest<Boolean> {
|
||||
override fun method(): String = "deleteWebhook"
|
||||
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = BooleanSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -2,12 +2,14 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.webhook
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.WebhookInfo
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
class GetWebhookInfo : SimpleRequest<WebhookInfo> {
|
||||
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()
|
||||
}
|
||||
|
@ -51,7 +51,10 @@ data class SetWebhook internal constructor(
|
||||
val allowedUpdates: List<String>? = null
|
||||
) : DataRequest<Boolean> {
|
||||
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 {
|
||||
maxAllowedConnections ?.let {
|
||||
|
@ -21,7 +21,6 @@ internal data class RawCallbackQuery(
|
||||
@SerialName("game_short_name")
|
||||
val gameShortName: String? = null
|
||||
) {
|
||||
@Transient
|
||||
val asCallbackQuery: CallbackQuery by lazy {
|
||||
when {
|
||||
message != null && data != null -> MessageDataCallbackQuery(id, from, chatInstance, message, data)
|
||||
|
@ -40,7 +40,6 @@ internal data class RawChatMember(
|
||||
@SerialName(canAddWebPagePreviewsField)
|
||||
private val canAddWebPagePreviews: Boolean = false
|
||||
) {
|
||||
@Transient
|
||||
val asChatMember: ChatMember by lazy {
|
||||
when (status) {
|
||||
"creator" -> CreatorChatMember(user)
|
||||
|
@ -17,7 +17,6 @@ internal data class RawChosenInlineResult(
|
||||
@SerialName(inlineMessageIdField)
|
||||
val inlineMessageId: InlineMessageIdentifier? = null
|
||||
) {
|
||||
@Transient
|
||||
val asChosenInlineResult: ChosenInlineResult by lazy {
|
||||
location ?.let {
|
||||
LocationChosenInlineResult(resultId, user, location, inlineMessageId, query)
|
||||
|
@ -16,7 +16,6 @@ internal data class RawInlineQuery(
|
||||
@SerialName(locationField)
|
||||
val location: Location? = null
|
||||
) {
|
||||
@Transient
|
||||
val asInlineQuery by lazy {
|
||||
location ?.let {
|
||||
LocationInlineQuery(id, from, query, offset, location)
|
||||
|
@ -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
|
@ -11,7 +11,6 @@ data class ResponseParametersRaw(
|
||||
) {
|
||||
@Transient
|
||||
private val createTime: Long = System.currentTimeMillis()
|
||||
@Transient
|
||||
val error: RequestError? by lazy {
|
||||
when {
|
||||
migrateToChatId != null -> MigrateChatId(migrateToChatId);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user