mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-29 13:38:43 +00:00
commit
17c10a2975
22
CHANGELOG.md
22
CHANGELOG.md
@ -1,6 +1,26 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 0.17.0
|
||||
## 0.18.0 Raws cleaning
|
||||
|
||||
* Made internal and not available outside of library:
|
||||
* `RawMessage`
|
||||
* `RawUpdate`
|
||||
* `RawChatMember`
|
||||
* `RawMessageEntity`
|
||||
* `RawInlineQuery`
|
||||
* `RawCallbackQuery`
|
||||
* `RawChosenInlineResult`
|
||||
|
||||
* All `RawMessage` usages was replaced with `Message` interface (with some of other raw classes was made the same things)
|
||||
* `TelegramBotAPIMessageDeserializationStrategy` was created. It was used for deserialization of Telegram Bot API
|
||||
incoming messages
|
||||
* `TelegramBotAPIMessageDeserializeOnlySerializer` was created. It **MUST NOT** be used to serialize messages
|
||||
* Update of description
|
||||
* Make `Game` object a little bit more standartizated
|
||||
* `Game` now is not serializable and have no additional trash, related to serialization
|
||||
* `TelegramFile` was removed
|
||||
|
||||
## 0.17.0 July 29, 2019 API Update
|
||||
|
||||
Libraries updates:
|
||||
|
||||
|
@ -5,8 +5,8 @@
|
||||
|
||||
## What is it?
|
||||
|
||||
It is one more project which wish to be useful and full Telegram Bots API bridge for Kotlin. Most part of some specific
|
||||
solves or unuseful moments are describing by official [Telegram Bot API](https://core.telegram.org/bots/api).
|
||||
Library for Object-Oriented and type-safe work with Telegram Bot API. Most part of some specific solves or unuseful
|
||||
moments are describing by official [Telegram Bot API](https://core.telegram.org/bots/api).
|
||||
|
||||
## Compatibility
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
project.version = "0.17.0"
|
||||
project.version = "0.18.0"
|
||||
project.group = "com.github.insanusmokrassar"
|
||||
|
||||
buildscript {
|
||||
|
@ -8,6 +8,6 @@ ktor_version=1.2.3
|
||||
gradle_bintray_plugin_version=1.8.4
|
||||
|
||||
project_public_name=Telegram Bot API
|
||||
project_public_description=It is one more project which wish to be useful and full Telegram Bots API bridge for Kotlin
|
||||
project_public_description=Library for Object-Oriented and type-safe work with Telegram Bot API
|
||||
|
||||
disableImplicitReflectionSerializerAnnotation=-Xexperimental=kotlinx.serialization.ImplicitReflectionSerializer
|
||||
|
@ -7,6 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.newRequestExcep
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.EmptyLimiter
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.RequestLimiter
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.extractResult
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.RetryAfterError
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
|
||||
@ -74,11 +75,11 @@ class KtorRequestsExecutor(
|
||||
val content = call.response.use {
|
||||
it.content.toByteArray().toString(Charsets.UTF_8)
|
||||
}
|
||||
val responseObject = jsonFormatter.parse(
|
||||
Response.serializer(request.resultSerializer()),
|
||||
content
|
||||
)
|
||||
responseObject.result ?: responseObject.parameters ?.let {
|
||||
val responseObject = jsonFormatter.parse(Response.serializer(), content)
|
||||
|
||||
(responseObject.result ?.let {
|
||||
jsonFormatter.fromJson(request.resultDeserializer(), it)
|
||||
} ?: responseObject.parameters ?.let {
|
||||
val error = it.error
|
||||
if (error is RetryAfterError) {
|
||||
delay(error.leftToRetry)
|
||||
@ -92,7 +93,7 @@ class KtorRequestsExecutor(
|
||||
content,
|
||||
"Can't get result object from $content"
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapWithCommonValues
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.request.forms.*
|
||||
import io.ktor.client.request.forms.MultiPartFormDataContent
|
||||
import io.ktor.client.request.forms.formData
|
||||
import io.ktor.http.Headers
|
||||
import io.ktor.http.HttpHeaders
|
||||
import kotlinx.io.core.readBytes
|
||||
|
||||
class MultipartRequestCallFactory : AbstractRequestCallFactory() {
|
||||
|
||||
@ -21,9 +23,7 @@ class MultipartRequestCallFactory : AbstractRequestCallFactory() {
|
||||
when (value) {
|
||||
is MultipartFile -> append(
|
||||
key,
|
||||
InputProvider {
|
||||
value.file.asInput()
|
||||
},
|
||||
value.file.asInput().readBytes(),
|
||||
Headers.build {
|
||||
append(HttpHeaders.ContentType, value.mimeType)
|
||||
append(HttpHeaders.ContentDisposition, "filename=${value.fileId}")
|
||||
|
@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||
import java.io.IOException
|
||||
|
||||
fun newRequestException(
|
||||
response: Response<*>,
|
||||
response: Response,
|
||||
plainAnswer: String,
|
||||
message: String? = null,
|
||||
cause: Throwable? = null
|
||||
@ -15,7 +15,7 @@ fun newRequestException(
|
||||
}
|
||||
|
||||
sealed class RequestException constructor(
|
||||
val response: Response<*>,
|
||||
val response: Response,
|
||||
val plainAnswer: String,
|
||||
message: String? = null,
|
||||
cause: Throwable? = null
|
||||
@ -24,13 +24,13 @@ sealed class RequestException constructor(
|
||||
cause
|
||||
)
|
||||
|
||||
class CommonRequestException(response: Response<*>, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||
class CommonRequestException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||
RequestException(response, plainAnswer, message, cause)
|
||||
|
||||
class UnauthorizedException(response: Response<*>, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||
class UnauthorizedException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||
RequestException(response, plainAnswer, message, cause)
|
||||
|
||||
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)
|
||||
|
||||
@Deprecated(
|
||||
|
@ -15,5 +15,5 @@ data class DeleteMessage(
|
||||
) : SimpleRequest<Boolean>, MessageAction {
|
||||
override fun method(): String = "deleteMessage"
|
||||
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
@ -16,12 +17,12 @@ data class ForwardMessage(
|
||||
override val messageId: MessageIdentifier,
|
||||
@SerialName(disableNotificationField)
|
||||
val disableNotification: Boolean = false
|
||||
): SimpleRequest<RawMessage>, MessageAction {
|
||||
): SimpleRequest<Message>, MessageAction {
|
||||
@Transient
|
||||
override val chatId: ChatIdentifier
|
||||
get() = fromChatId
|
||||
|
||||
override fun method(): String = "forwardMessage"
|
||||
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
@ -8,5 +8,5 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
class GetMe : SimpleRequest<User> {
|
||||
override fun method(): String = "getMe"
|
||||
override fun resultSerializer(): KSerializer<User> = User.serializer()
|
||||
override fun resultDeserializer(): KSerializer<User> = User.serializer()
|
||||
}
|
@ -3,40 +3,22 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.RawUpdate
|
||||
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.internal.ArrayListSerializer
|
||||
|
||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_MESSAGE", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_MESSAGE"))
|
||||
const val UPDATE_MESSAGE = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_MESSAGE
|
||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_EDITED_MESSAGE", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_EDITED_MESSAGE"))
|
||||
const val UPDATE_EDITED_MESSAGE = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_EDITED_MESSAGE
|
||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_CHANNEL_POST", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_CHANNEL_POST"))
|
||||
const val UPDATE_CHANNEL_POST = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_CHANNEL_POST
|
||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_EDITED_CHANNEL_POST", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_EDITED_CHANNEL_POST"))
|
||||
const val UPDATE_EDITED_CHANNEL_POST = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_EDITED_CHANNEL_POST
|
||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_CHOSEN_INLINE_RESULT", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_CHOSEN_INLINE_RESULT"))
|
||||
const val UPDATE_CHOSEN_INLINE_RESULT = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_CHOSEN_INLINE_RESULT
|
||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_INLINE_QUERY", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_INLINE_QUERY"))
|
||||
const val UPDATE_INLINE_QUERY = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_INLINE_QUERY
|
||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_CALLBACK_QUERY", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_CALLBACK_QUERY"))
|
||||
const val UPDATE_CALLBACK_QUERY = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_CALLBACK_QUERY
|
||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_SHIPPING_QUERY", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_SHIPPING_QUERY"))
|
||||
const val UPDATE_SHIPPING_QUERY = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_SHIPPING_QUERY
|
||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_PRE_CHECKOUT_QUERY", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_PRE_CHECKOUT_QUERY"))
|
||||
const val UPDATE_PRE_CHECKOUT_QUERY = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_PRE_CHECKOUT_QUERY
|
||||
@Deprecated("Replaced to other package", ReplaceWith("UPDATE_POLL", "com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_POLL"))
|
||||
const val UPDATE_POLL = com.github.insanusmokrassar.TelegramBotAPI.types.UPDATE_POLL
|
||||
|
||||
@Serializable
|
||||
data class GetUpdates(
|
||||
val offset: UpdateIdentifier? = null,// set `last update id + 1` to receive next part of updates
|
||||
val limit: Int? = null,
|
||||
val timeout: Int? = null,
|
||||
val allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||
): SimpleRequest<List<RawUpdate>> {
|
||||
): SimpleRequest<List<Update>> {
|
||||
override fun method(): String = "getUpdates"
|
||||
|
||||
override fun resultSerializer(): KSerializer<List<RawUpdate>> = ArrayListSerializer(RawUpdate.serializer())
|
||||
override fun resultDeserializer(): KSerializer<List<Update>> = ArrayListSerializer(
|
||||
UpdateSerializerWithoutDeserialization
|
||||
)
|
||||
}
|
||||
|
@ -18,5 +18,5 @@ data class StopPoll(
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : MessageAction, SimpleRequest<Poll>, ReplyMarkup {
|
||||
override fun method(): String = "stopPoll"
|
||||
override fun resultSerializer(): KSerializer<Poll> = Poll.serializer()
|
||||
override fun resultDeserializer(): KSerializer<Poll> = Poll.serializer()
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
@ -8,14 +7,7 @@ import kotlinx.serialization.json.JsonObject
|
||||
@Serializable(RequestSerializer::class)
|
||||
interface Request<T: Any> {
|
||||
fun method(): String
|
||||
fun resultSerializer(): KSerializer<T>
|
||||
fun resultDeserializer(): DeserializationStrategy<T>
|
||||
fun json(): JsonObject = toJsonWithoutNulls(RequestSerializer)
|
||||
}
|
||||
object RequestSerializer : KSerializer<Request<*>> by ContextSerializer(Request::class)
|
||||
|
||||
fun <T : Any> StringFormat.extractResult(
|
||||
from: String,
|
||||
dataSerializer: KSerializer<T>
|
||||
): Response<T> {
|
||||
return parse(Response.serializer(dataSerializer), from)
|
||||
}
|
@ -20,7 +20,7 @@ data class AnswerCallbackQuery(
|
||||
val cachedTimeSeconds: Int? = null
|
||||
) : SimpleRequest<Boolean> {
|
||||
override fun method(): String = "answerCallbackQuery"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
||||
fun CallbackQuery.createAnswer(
|
||||
|
@ -28,7 +28,7 @@ data class AnswerInlineQuery(
|
||||
val switchPmParameter: String? = null
|
||||
): SimpleRequest<Boolean> {
|
||||
override fun method(): String = "answerInlineQuery"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
||||
fun InlineQuery.createAnswer(
|
||||
|
@ -7,7 +7,7 @@ import kotlinx.serialization.serializer
|
||||
|
||||
interface AnswerPreCheckoutQuery : SimpleRequest<Boolean> {
|
||||
override fun method(): String = "answerPreCheckoutQuery"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = Boolean.serializer()
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = Boolean.serializer()
|
||||
|
||||
val preCheckoutQueryId: PreCheckoutQueryId
|
||||
val isOk: Boolean
|
||||
|
@ -7,7 +7,7 @@ import kotlinx.serialization.serializer
|
||||
|
||||
interface AnswerShippingQuery : SimpleRequest<Boolean> {
|
||||
override fun method(): String = "answerShippingQuery"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = Boolean.serializer()
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = Boolean.serializer()
|
||||
|
||||
val shippingQueryId: ShippingQueryIdentifier
|
||||
val isOk: Boolean
|
||||
|
@ -13,5 +13,5 @@ data class ExportChatInviteLink(
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<String> {
|
||||
override fun method(): String = "exportChatInviteLink"
|
||||
override fun resultSerializer(): KSerializer<String> = StringSerializer
|
||||
override fun resultDeserializer(): KSerializer<String> = StringSerializer
|
||||
}
|
||||
|
@ -13,5 +13,5 @@ data class LeaveChat(
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<Boolean> {
|
||||
override fun method(): String = "leaveChat"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
@ -14,5 +14,5 @@ data class GetChat(
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<ExtendedChat> {
|
||||
override fun method(): String = "getChat"
|
||||
override fun resultSerializer(): KSerializer<ExtendedChat> = ExtendedChatSerializer
|
||||
override fun resultDeserializer(): KSerializer<ExtendedChat> = ExtendedChatSerializer
|
||||
}
|
||||
|
@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.RawChatMember
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMember
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMemberSerializerWithoutDeserialization
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.ArrayListSerializer
|
||||
@ -12,7 +13,9 @@ import kotlinx.serialization.internal.ArrayListSerializer
|
||||
data class GetChatAdministrators(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<List<RawChatMember>> {
|
||||
): ChatRequest, SimpleRequest<List<ChatMember>> {
|
||||
override fun method(): String = "getChatAdministrators"
|
||||
override fun resultSerializer(): KSerializer<List<RawChatMember>> = ArrayListSerializer(RawChatMember.serializer())
|
||||
override fun resultDeserializer(): KSerializer<List<ChatMember>> = ArrayListSerializer(
|
||||
ChatMemberSerializerWithoutDeserialization
|
||||
)
|
||||
}
|
||||
|
@ -13,5 +13,5 @@ data class GetChatMembersCount(
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<Int> {
|
||||
override fun method(): String = "getChatMembersCount"
|
||||
override fun resultSerializer(): KSerializer<Int> = IntSerializer
|
||||
override fun resultDeserializer(): KSerializer<Int> = IntSerializer
|
||||
}
|
||||
|
@ -2,7 +2,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.abstracts.ChatMemberRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.RawChatMember
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMember
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMemberDeserializationStrategy
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
@ -11,7 +12,7 @@ data class GetChatMember(
|
||||
override val chatId: ChatIdentifier,
|
||||
@SerialName(userIdField)
|
||||
override val userId: UserId
|
||||
) : ChatMemberRequest<RawChatMember> {
|
||||
) : ChatMemberRequest<ChatMember> {
|
||||
override fun method(): String = "getChatMember"
|
||||
override fun resultSerializer(): KSerializer<RawChatMember> = RawChatMember.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<ChatMember> = ChatMemberDeserializationStrategy
|
||||
}
|
||||
|
@ -16,5 +16,5 @@ data class KickChatMember(
|
||||
override val untilDate: TelegramDate? = null
|
||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||
override fun method(): String = "kickChatMember"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
@ -32,5 +32,5 @@ data class PromoteChatMember(
|
||||
private val canPromoteMembers: Boolean? = null
|
||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||
override fun method(): String = "promoteChatMember"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
@ -19,5 +19,5 @@ data class RestrictChatMember(
|
||||
val permissions: ChatPermissions
|
||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||
override fun method(): String = "restrictChatMember"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
@ -13,5 +13,5 @@ data class UnbanChatMember(
|
||||
override val userId: UserId
|
||||
) : ChatMemberRequest<Boolean> {
|
||||
override fun method(): String = "unbanChatMember"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
@ -13,5 +13,5 @@ data class DeleteChatPhoto(
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<Boolean> {
|
||||
override fun method(): String = "deleteChatPhoto"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
@ -16,5 +16,5 @@ data class PinChatMessage (
|
||||
override val disableNotification: Boolean = false
|
||||
): ChatRequest, SimpleRequest<Boolean>, MessageAction, DisableNotification {
|
||||
override fun method(): String = "pinChatMessage"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
@ -20,5 +20,5 @@ data class SetChatDescription (
|
||||
}
|
||||
|
||||
override fun method(): String = "setChatDescription"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
@ -15,5 +15,5 @@ data class SetChatPermissions (
|
||||
val permissions: ChatPermissions
|
||||
): ChatRequest, SimpleRequest<Boolean> {
|
||||
override fun method(): String = "setChatPermissions"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ 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 resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override val mediaMap: Map<String, MultipartFile> = mapOf(photoField to photo)
|
||||
override val paramsJson: JsonObject = toJson(serializer())
|
||||
}
|
||||
|
@ -20,5 +20,5 @@ data class SetChatTitle (
|
||||
}
|
||||
|
||||
override fun method(): String = "setChatTitle"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
@ -13,5 +13,5 @@ data class UnpinChatMessage(
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<Boolean> {
|
||||
override fun method(): String = "unpinChatMessage"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
@ -13,5 +13,5 @@ data class DeleteChatStickerSet(
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<Boolean> {
|
||||
override fun method(): String = "deleteChatStickerSet"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
@ -14,5 +14,5 @@ data class SetChatStickerSet(
|
||||
val stickerSetName: StickerSetName
|
||||
): ChatRequest, SimpleRequest<Boolean> {
|
||||
override fun method(): String = "setChatStickerSet"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
@ -20,5 +21,5 @@ data class EditChatMessageLiveLocation(
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : EditChatMessage, EditReplyMessage, EditLocationMessage {
|
||||
override fun method(): String = "editMessageLiveLocation"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
@ -4,7 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditCh
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
@ -17,5 +18,5 @@ data class StopChatMessageLiveLocation(
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : EditChatMessage, EditReplyMessage {
|
||||
override fun method(): String = "stopMessageLiveLocation"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
@ -4,7 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditCh
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.EditReplyMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import kotlinx.serialization.*
|
||||
|
||||
const val editMessageReplyMarkupMethod = "editMessageReplyMarkup"
|
||||
@ -20,5 +21,5 @@ data class EditChatMessageReplyMarkup(
|
||||
) : EditChatMessage, EditReplyMessage {
|
||||
|
||||
override fun method(): String = editMessageReplyMarkupMethod
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
@ -2,6 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
|
||||
interface EditChatMessage : SimpleRequest<RawMessage>, MessageAction
|
||||
interface EditChatMessage : SimpleRequest<Message>, MessageAction
|
||||
|
@ -7,5 +7,5 @@ import kotlinx.serialization.internal.BooleanSerializer
|
||||
|
||||
interface EditInlineMessage : SimpleRequest<Boolean> {
|
||||
val inlineMessageId: InlineMessageIdentifier
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
@ -5,7 +5,8 @@ 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 com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import kotlinx.serialization.*
|
||||
|
||||
const val editMessageCaptionMethod = "editMessageCaption"
|
||||
@ -25,5 +26,5 @@ data class EditChatMessageCaption(
|
||||
) : EditChatMessage, EditTextChatMessage, EditReplyMessage {
|
||||
|
||||
override fun method(): String = editMessageCaptionMethod
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
@ -5,7 +5,8 @@ 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 com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import kotlinx.serialization.*
|
||||
|
||||
const val editMessageMediaMethod = "editMessageMedia"
|
||||
@ -29,5 +30,5 @@ data class EditChatMessageMedia(
|
||||
}
|
||||
|
||||
override fun method(): String = editMessageMediaMethod
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
@ -5,7 +5,8 @@ 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 com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import kotlinx.serialization.*
|
||||
|
||||
const val editMessageTextMethod = "editMessageText"
|
||||
@ -27,5 +28,5 @@ data class EditChatMessageText(
|
||||
) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
||||
|
||||
override fun method(): String = editMessageTextMethod
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ interface GetGameHighScores : SimpleRequest<List<GameHighScore>> {
|
||||
val userId: UserId
|
||||
|
||||
override fun method(): String = "getGameHighScores"
|
||||
override fun resultSerializer(): KSerializer<List<GameHighScore>> = GameHighScoresSerializer
|
||||
override fun resultDeserializer(): KSerializer<List<GameHighScore>> = GameHighScoresSerializer
|
||||
}
|
||||
|
||||
object GameHighScoresSerializer : KSerializer<List<GameHighScore>> by ArrayListSerializer(GameHighScore.serializer())
|
||||
|
@ -12,5 +12,5 @@ interface SetGameScore : SimpleRequest<Boolean> {
|
||||
val disableEditMessage: Boolean
|
||||
|
||||
override fun method(): String = "setGameScore"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = Boolean.serializer()
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = Boolean.serializer()
|
||||
}
|
@ -12,5 +12,5 @@ data class GetFile(
|
||||
val fileId: FileId
|
||||
): SimpleRequest<PathedFile> {
|
||||
override fun method(): String = "getFile"
|
||||
override fun resultSerializer(): KSerializer<PathedFile> = PathedFile.serializer()
|
||||
override fun resultDeserializer(): KSerializer<PathedFile> = PathedFile.serializer()
|
||||
}
|
||||
|
@ -11,5 +11,5 @@ data class GetStickerSet(
|
||||
val name: String
|
||||
): SimpleRequest<StickerSet> {
|
||||
override fun method(): String = "getStickerSet"
|
||||
override fun resultSerializer(): KSerializer<StickerSet> = StickerSet.serializer()
|
||||
override fun resultDeserializer(): KSerializer<StickerSet> = StickerSet.serializer()
|
||||
}
|
||||
|
@ -23,5 +23,5 @@ data class GetUserProfilePhotos(
|
||||
}
|
||||
|
||||
override fun method(): String = "getUserProfilePhotos"
|
||||
override fun resultSerializer(): KSerializer<UserProfilePhotos> = UserProfilePhotos.serializer()
|
||||
override fun resultDeserializer(): KSerializer<UserProfilePhotos> = UserProfilePhotos.serializer()
|
||||
}
|
||||
|
@ -17,5 +17,5 @@ data class SendAction(
|
||||
val action: BotAction
|
||||
): SendChatMessageRequest<Boolean> {
|
||||
override fun method(): String = "sendChatAction"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
@ -4,7 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.Replyi
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
@ -23,8 +24,8 @@ data class SendContact(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : SendMessageRequest<RawMessage>,
|
||||
ReplyingMarkupSendMessageRequest<RawMessage>
|
||||
) : SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>
|
||||
{
|
||||
constructor(
|
||||
chatId: ChatIdentifier,
|
||||
@ -43,7 +44,7 @@ data class SendContact(
|
||||
)
|
||||
|
||||
override fun method(): String = "sendContact"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
||||
fun Contact.toRequest(
|
||||
|
@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import kotlinx.serialization.*
|
||||
|
||||
// TODO:: Add location tracker for tracking location
|
||||
@ -23,11 +24,11 @@ data class SendLocation(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : SendMessageRequest<RawMessage>,
|
||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
||||
PositionedSendMessageRequest<RawMessage>
|
||||
) : SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>,
|
||||
PositionedSendMessageRequest<Message>
|
||||
{
|
||||
|
||||
override fun method(): String = "sendLocation"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ 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.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
@ -25,9 +26,9 @@ data class SendMessage(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : SendMessageRequest<RawMessage>,
|
||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
||||
TextableSendMessageRequest<RawMessage>,
|
||||
) : SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>,
|
||||
TextableSendMessageRequest<Message>,
|
||||
DisableWebPagePreview
|
||||
{
|
||||
init {
|
||||
@ -37,5 +38,5 @@ data class SendMessage(
|
||||
}
|
||||
|
||||
override fun method(): String = "sendMessage"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
@ -4,7 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.Replyi
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
@ -21,8 +22,8 @@ data class SendPoll(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : SendMessageRequest<RawMessage>,
|
||||
ReplyingMarkupSendMessageRequest<RawMessage> {
|
||||
) : SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message> {
|
||||
|
||||
init {
|
||||
if (question.length !in pollQuestionTextLength) {
|
||||
@ -39,5 +40,5 @@ data class SendPoll(
|
||||
}
|
||||
|
||||
override fun method(): String = "sendPoll"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
@ -26,10 +27,10 @@ data class SendVenue(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : SendMessageRequest<RawMessage>,
|
||||
PositionedSendMessageRequest<RawMessage>,
|
||||
TitledSendMessageRequest<RawMessage>,
|
||||
ReplyingMarkupSendMessageRequest<RawMessage>
|
||||
) : SendMessageRequest<Message>,
|
||||
PositionedSendMessageRequest<Message>,
|
||||
TitledSendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>
|
||||
{
|
||||
constructor(
|
||||
chatId: ChatIdentifier,
|
||||
@ -50,7 +51,7 @@ data class SendVenue(
|
||||
)
|
||||
|
||||
override fun method(): String = "sendVenue"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
||||
fun Venue.toRequest(
|
||||
|
@ -4,7 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ReplyMar
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
@ -19,8 +20,8 @@ data class SendGame (
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : SendMessageRequest<RawMessage>,
|
||||
) : SendMessageRequest<Message>,
|
||||
ReplyMarkup {
|
||||
override fun method(): String = "sendGame"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
@ -7,7 +7,8 @@ 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.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@ -23,7 +24,7 @@ fun SendAnimation(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<RawMessage> {
|
||||
): Request<Message> {
|
||||
val animationAsFileId = (animation as? FileId) ?.fileId
|
||||
val animationAsFile = animation as? MultipartFile
|
||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
||||
@ -77,13 +78,13 @@ data class SendAnimationData internal constructor(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : DataRequest<RawMessage>,
|
||||
SendMessageRequest<RawMessage>,
|
||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
||||
TextableSendMessageRequest<RawMessage>,
|
||||
ThumbedSendMessageRequest<RawMessage>,
|
||||
DuratedSendMessageRequest<RawMessage>,
|
||||
SizedSendMessageRequest<RawMessage>
|
||||
) : DataRequest<Message>,
|
||||
SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>,
|
||||
TextableSendMessageRequest<Message>,
|
||||
ThumbedSendMessageRequest<Message>,
|
||||
DuratedSendMessageRequest<Message>,
|
||||
SizedSendMessageRequest<Message>
|
||||
{
|
||||
init {
|
||||
text ?.let {
|
||||
@ -94,7 +95,7 @@ data class SendAnimationData internal constructor(
|
||||
}
|
||||
|
||||
override fun method(): String = "sendAnimation"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
||||
data class SendAnimationFiles internal constructor(
|
||||
|
@ -8,7 +8,8 @@ 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.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@ -24,7 +25,7 @@ fun SendAudio(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<RawMessage> {
|
||||
): Request<Message> {
|
||||
val audioAsFileId = (audio as? FileId) ?.fileId
|
||||
val audioAsFile = audio as? MultipartFile
|
||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
||||
@ -78,13 +79,13 @@ data class SendAudioData internal constructor(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : DataRequest<RawMessage>,
|
||||
SendMessageRequest<RawMessage>,
|
||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
||||
TextableSendMessageRequest<RawMessage>,
|
||||
ThumbedSendMessageRequest<RawMessage>,
|
||||
TitledSendMessageRequest<RawMessage>,
|
||||
DuratedSendMessageRequest<RawMessage>,
|
||||
) : DataRequest<Message>,
|
||||
SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>,
|
||||
TextableSendMessageRequest<Message>,
|
||||
ThumbedSendMessageRequest<Message>,
|
||||
TitledSendMessageRequest<Message>,
|
||||
DuratedSendMessageRequest<Message>,
|
||||
Performerable
|
||||
{
|
||||
init {
|
||||
@ -96,7 +97,7 @@ data class SendAudioData internal constructor(
|
||||
}
|
||||
|
||||
override fun method(): String = "sendAudio"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
||||
data class SendAudioFiles internal constructor(
|
||||
|
@ -7,7 +7,8 @@ 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.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@ -20,7 +21,7 @@ fun SendDocument(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<RawMessage> {
|
||||
): Request<Message> {
|
||||
val documentAsFileId = (document as? FileId) ?.fileId
|
||||
val documentAsFile = document as? MultipartFile
|
||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
||||
@ -65,11 +66,11 @@ data class SendDocumentData internal constructor(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : DataRequest<RawMessage>,
|
||||
SendMessageRequest<RawMessage>,
|
||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
||||
TextableSendMessageRequest<RawMessage>,
|
||||
ThumbedSendMessageRequest<RawMessage>
|
||||
) : DataRequest<Message>,
|
||||
SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>,
|
||||
TextableSendMessageRequest<Message>,
|
||||
ThumbedSendMessageRequest<Message>
|
||||
{
|
||||
init {
|
||||
text ?.let {
|
||||
@ -80,7 +81,7 @@ data class SendDocumentData internal constructor(
|
||||
}
|
||||
|
||||
override fun method(): String = "sendDocument"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
||||
data class SendDocumentFiles internal constructor(
|
||||
|
@ -6,7 +6,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMe
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.ArrayListSerializer
|
||||
@ -19,7 +20,7 @@ fun SendMediaGroup(
|
||||
media: List<MediaGroupMemberInputMedia>,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null
|
||||
): Request<List<RawMessage>> {
|
||||
): Request<List<Message>> {
|
||||
if (media.size !in membersCountInMediaGroup) {
|
||||
throw IllegalArgumentException("Count of members for media group must be in $membersCountInMediaGroup range")
|
||||
}
|
||||
@ -52,7 +53,7 @@ fun SendMediaGroup(
|
||||
}
|
||||
}
|
||||
|
||||
private val serializer = ArrayListSerializer(RawMessage.serializer())
|
||||
private val serializer = ArrayListSerializer(TelegramBotAPIMessageDeserializeOnlySerializer)
|
||||
|
||||
@Serializable
|
||||
data class SendMediaGroupData internal constructor(
|
||||
@ -63,8 +64,8 @@ data class SendMediaGroupData internal constructor(
|
||||
override val disableNotification: Boolean = false,
|
||||
@SerialName(replyToMessageIdField)
|
||||
override val replyToMessageId: MessageIdentifier? = null
|
||||
) : DataRequest<List<RawMessage>>,
|
||||
SendMessageRequest<List<RawMessage>>
|
||||
) : DataRequest<List<Message>>,
|
||||
SendMessageRequest<List<Message>>
|
||||
{
|
||||
@SerialName(mediaField)
|
||||
private val convertedMedia: String
|
||||
@ -76,7 +77,7 @@ data class SendMediaGroupData internal constructor(
|
||||
|
||||
|
||||
override fun method(): String = "sendMediaGroup"
|
||||
override fun resultSerializer(): KSerializer<List<RawMessage>> = serializer
|
||||
override fun resultDeserializer(): DeserializationStrategy<List<Message>> = serializer
|
||||
}
|
||||
|
||||
data class SendMediaGroupFiles internal constructor(
|
||||
|
@ -7,7 +7,8 @@ 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.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import kotlinx.serialization.*
|
||||
|
||||
fun SendPhoto(
|
||||
@ -18,7 +19,7 @@ fun SendPhoto(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<RawMessage> {
|
||||
): Request<Message> {
|
||||
val data = SendPhotoData(
|
||||
chatId,
|
||||
(photo as? FileId) ?.fileId,
|
||||
@ -52,10 +53,10 @@ data class SendPhotoData internal constructor(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : DataRequest<RawMessage>,
|
||||
SendMessageRequest<RawMessage>,
|
||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
||||
TextableSendMessageRequest<RawMessage>
|
||||
) : DataRequest<Message>,
|
||||
SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>,
|
||||
TextableSendMessageRequest<Message>
|
||||
{
|
||||
init {
|
||||
text ?.let {
|
||||
@ -66,7 +67,7 @@ data class SendPhotoData internal constructor(
|
||||
}
|
||||
|
||||
override fun method(): String = "sendPhoto"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
||||
data class SendPhotoFiles internal constructor(
|
||||
|
@ -5,7 +5,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.Replyi
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
@ -16,7 +17,7 @@ fun SendSticker(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<RawMessage> = SendStickerByFileId(
|
||||
): Request<Message> = SendStickerByFileId(
|
||||
chatId,
|
||||
sticker as? FileId,
|
||||
disableNotification,
|
||||
@ -41,16 +42,16 @@ data class SendStickerByFileId internal constructor(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : SendMessageRequest<RawMessage>, ReplyingMarkupSendMessageRequest<RawMessage> {
|
||||
) : SendMessageRequest<Message>, ReplyingMarkupSendMessageRequest<Message> {
|
||||
override fun method(): String = "sendSticker"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
||||
data class SendStickerByFile internal constructor(
|
||||
@Transient
|
||||
private val sendStickerByFileId: SendStickerByFileId,
|
||||
val sticker: MultipartFile
|
||||
) : MultipartRequest<RawMessage>, Request<RawMessage> by sendStickerByFileId {
|
||||
) : MultipartRequest<Message>, Request<Message> by sendStickerByFileId {
|
||||
override val mediaMap: Map<String, MultipartFile> = mapOf(stickerField to sticker)
|
||||
override val paramsJson: JsonObject = sendStickerByFileId.toJsonWithoutNulls(SendStickerByFileId.serializer())
|
||||
}
|
||||
|
@ -7,7 +7,8 @@ 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.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@ -24,7 +25,7 @@ fun SendVideo(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<RawMessage> {
|
||||
): Request<Message> {
|
||||
val videoAsFileId = (video as? FileId) ?.fileId
|
||||
val videoAsFile = video as? MultipartFile
|
||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
||||
@ -81,13 +82,13 @@ data class SendVideoData internal constructor(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : DataRequest<RawMessage>,
|
||||
SendMessageRequest<RawMessage>,
|
||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
||||
TextableSendMessageRequest<RawMessage>,
|
||||
ThumbedSendMessageRequest<RawMessage>,
|
||||
DuratedSendMessageRequest<RawMessage>,
|
||||
SizedSendMessageRequest<RawMessage>
|
||||
) : DataRequest<Message>,
|
||||
SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>,
|
||||
TextableSendMessageRequest<Message>,
|
||||
ThumbedSendMessageRequest<Message>,
|
||||
DuratedSendMessageRequest<Message>,
|
||||
SizedSendMessageRequest<Message>
|
||||
{
|
||||
init {
|
||||
text ?.let {
|
||||
@ -98,7 +99,7 @@ data class SendVideoData internal constructor(
|
||||
}
|
||||
|
||||
override fun method(): String = "sendVideo"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
||||
data class SendVideoFiles internal constructor(
|
||||
|
@ -7,7 +7,8 @@ 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.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@ -22,7 +23,7 @@ fun SendVideoNote(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<RawMessage> {
|
||||
): Request<Message> {
|
||||
val videoNoteAsFileId = (videoNote as? FileId) ?.fileId
|
||||
val videoNoteAsFile = videoNote as? MultipartFile
|
||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
||||
@ -73,13 +74,13 @@ data class SendVideoNoteData internal constructor(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : DataRequest<RawMessage>,
|
||||
SendMessageRequest<RawMessage>,
|
||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
||||
TextableSendMessageRequest<RawMessage>,
|
||||
ThumbedSendMessageRequest<RawMessage>,
|
||||
DuratedSendMessageRequest<RawMessage>,
|
||||
SizedSendMessageRequest<RawMessage>
|
||||
) : DataRequest<Message>,
|
||||
SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>,
|
||||
TextableSendMessageRequest<Message>,
|
||||
ThumbedSendMessageRequest<Message>,
|
||||
DuratedSendMessageRequest<Message>,
|
||||
SizedSendMessageRequest<Message>
|
||||
{
|
||||
@Transient
|
||||
override val height: Int?
|
||||
@ -94,7 +95,7 @@ data class SendVideoNoteData internal constructor(
|
||||
}
|
||||
|
||||
override fun method(): String = "sendVideoNote"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
||||
data class SendVideoNoteFiles internal constructor(
|
||||
|
@ -7,7 +7,8 @@ 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.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@ -21,7 +22,7 @@ fun SendVoice(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<RawMessage> {
|
||||
): Request<Message> {
|
||||
val voiceAsFileId = (voice as? FileId) ?.fileId
|
||||
val voiceAsFile = voice as? MultipartFile
|
||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
||||
@ -69,12 +70,12 @@ data class SendVoiceData internal constructor(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : DataRequest<RawMessage>,
|
||||
SendMessageRequest<RawMessage>,
|
||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
||||
TextableSendMessageRequest<RawMessage>,
|
||||
ThumbedSendMessageRequest<RawMessage>,
|
||||
DuratedSendMessageRequest<RawMessage>
|
||||
) : DataRequest<Message>,
|
||||
SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>,
|
||||
TextableSendMessageRequest<Message>,
|
||||
ThumbedSendMessageRequest<Message>,
|
||||
DuratedSendMessageRequest<Message>
|
||||
{
|
||||
init {
|
||||
text ?.let {
|
||||
@ -85,7 +86,7 @@ data class SendVoiceData internal constructor(
|
||||
}
|
||||
|
||||
override fun method(): String = "sendVoice"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
}
|
||||
|
||||
data class SendVoiceFiles internal constructor(
|
||||
|
@ -2,7 +2,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.KSerializer
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
/**
|
||||
@ -13,7 +13,7 @@ class MultipartRequestImpl<D: DataRequest<R>, F: Files, R: Any>(
|
||||
val files: F
|
||||
) : MultipartRequest<R> {
|
||||
override fun method(): String = data.method()
|
||||
override fun resultSerializer(): KSerializer<R> = data.resultSerializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<R> = data.resultDeserializer()
|
||||
override val paramsJson: JsonObject = data.json()
|
||||
override val mediaMap: Map<String, MultipartFile> = files
|
||||
}
|
||||
|
@ -4,7 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPrice
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPricesSerializer
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.abstracts.*
|
||||
@ -62,9 +63,9 @@ data class SendInvoice(
|
||||
DisableNotification,
|
||||
ReplyMessageId,
|
||||
ReplyMarkup,
|
||||
SendMessageRequest<RawMessage> {
|
||||
SendMessageRequest<Message> {
|
||||
override fun method(): String = "sendInvoice"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
|
||||
|
||||
@SerialName(photoUrlField)
|
||||
var photoUrl: String? = null
|
||||
|
@ -12,5 +12,5 @@ data class DeleteStickerFromSet(
|
||||
val sticker: FileId
|
||||
) : SimpleRequest<Boolean> {
|
||||
override fun method(): String = "deleteStickerFromSet"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
@ -21,5 +21,5 @@ data class SetStickerPositionInSet(
|
||||
}
|
||||
|
||||
override fun method(): String = "setStickerPositionInSet"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
@ -24,5 +24,5 @@ data class UploadStickerFile(
|
||||
override val mediaMap: Map<String, MultipartFile> = mapOf(pngStickerField to sticker)
|
||||
@Transient
|
||||
override val paramsJson: JsonObject = toJsonWithoutNulls(serializer())
|
||||
override fun resultSerializer(): KSerializer<File> = File.serializer()
|
||||
override fun resultDeserializer(): KSerializer<File> = File.serializer()
|
||||
}
|
||||
|
@ -12,5 +12,5 @@ interface StickerSetAction : SimpleRequest<Boolean> {
|
||||
val emojis: String // must be more than one
|
||||
val maskPosition: MaskPosition?
|
||||
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
@ -9,5 +9,5 @@ import kotlinx.serialization.internal.BooleanSerializer
|
||||
class DeleteWebhook : SimpleRequest<Boolean> {
|
||||
override fun method(): String = "deleteWebhook"
|
||||
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ import kotlinx.serialization.Serializable
|
||||
class GetWebhookInfo : SimpleRequest<WebhookInfo> {
|
||||
override fun method(): String = "getWebhookInfo"
|
||||
|
||||
override fun resultSerializer(): KSerializer<WebhookInfo> = WebhookInfo.serializer()
|
||||
override fun resultDeserializer(): KSerializer<WebhookInfo> = WebhookInfo.serializer()
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ data class SetWebhook internal constructor(
|
||||
val allowedUpdates: List<String>? = null
|
||||
) : DataRequest<Boolean> {
|
||||
override fun method(): String = "setWebhook"
|
||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
|
||||
|
||||
init {
|
||||
maxAllowedConnections ?.let {
|
||||
|
@ -1,16 +1,18 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class RawCallbackQuery(
|
||||
internal data class RawCallbackQuery(
|
||||
@SerialName(idField)
|
||||
val id: CallbackQueryIdentifier,
|
||||
@SerialName(fromField)
|
||||
val from: User,
|
||||
val message: RawMessage? = null,
|
||||
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
|
||||
val message: Message? = null,
|
||||
@SerialName(inlineMessageIdField)
|
||||
val inlineMessageId: InlineMessageIdentifier? = null,
|
||||
@SerialName("chat_instance")
|
||||
@ -22,8 +24,8 @@ data class RawCallbackQuery(
|
||||
@Transient
|
||||
val asCallbackQuery: CallbackQuery by lazy {
|
||||
when {
|
||||
message != null && data != null -> MessageDataCallbackQuery(id, from, chatInstance, message.asMessage, data)
|
||||
message != null && gameShortName != null -> MessageGameShortNameCallbackQuery(id, from, chatInstance, message.asMessage, gameShortName)
|
||||
message != null && data != null -> MessageDataCallbackQuery(id, from, chatInstance, message, data)
|
||||
message != null && gameShortName != null -> MessageGameShortNameCallbackQuery(id, from, chatInstance, message, gameShortName)
|
||||
inlineMessageId != null && data != null -> InlineMessageIdDataCallbackQuery(id, from, chatInstance, inlineMessageId, data)
|
||||
inlineMessageId != null && gameShortName != null -> InlineMessageIdGameShortNameCallbackQuery(id, from, chatInstance, inlineMessageId, gameShortName)
|
||||
else -> throw IllegalStateException("Strange answer from server, can't create callback query")
|
||||
|
@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.Cha
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class RawChatMember(
|
||||
internal data class RawChatMember(
|
||||
val user: User,
|
||||
private val status: String,
|
||||
private val until_date: TelegramDate? = null,
|
||||
|
@ -1,7 +1,24 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.RawChatMember
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.StringDescriptor
|
||||
|
||||
interface ChatMember {
|
||||
val user: User
|
||||
}
|
||||
|
||||
internal object ChatMemberSerializerWithoutDeserialization : KSerializer<ChatMember> {
|
||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("ChatMemberSerializerWithoutDeserialization")
|
||||
|
||||
override fun deserialize(decoder: Decoder): ChatMember = ChatMemberDeserializationStrategy.deserialize(decoder)
|
||||
override fun serialize(encoder: Encoder, obj: ChatMember) = throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
internal object ChatMemberDeserializationStrategy : DeserializationStrategy<ChatMember> {
|
||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("ChatMemberDeserializationStrategy")
|
||||
|
||||
override fun deserialize(decoder: Decoder): ChatMember = RawChatMember.serializer().deserialize(decoder).asChatMember
|
||||
override fun patch(decoder: Decoder, old: ChatMember): ChatMember = throw UpdateNotSupportedException(descriptor.name)
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class RawChosenInlineResult(
|
||||
internal data class RawChosenInlineResult(
|
||||
@SerialName(resultIdField)
|
||||
val resultId: InlineQueryIdentifier, //chosen temporary, can be changed
|
||||
@SerialName(fromField)
|
||||
|
@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class RawInlineQuery(
|
||||
internal data class RawInlineQuery(
|
||||
@SerialName(idField)
|
||||
val id: InlineQueryIdentifier,
|
||||
@SerialName(fromField)
|
||||
|
@ -6,7 +6,7 @@ import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.internal.ArrayListSerializer
|
||||
|
||||
@Serializable
|
||||
data class RawMessageEntity(
|
||||
internal data class RawMessageEntity(
|
||||
val type: String,
|
||||
val offset: Int,
|
||||
val length: Int,
|
||||
@ -34,8 +34,8 @@ data class RawMessageEntity(
|
||||
}
|
||||
}
|
||||
|
||||
typealias RawMessageEntities = List<RawMessageEntity>
|
||||
internal typealias RawMessageEntities = List<RawMessageEntity>
|
||||
|
||||
object RawMessageEntitiesSerializer : KSerializer<List<RawMessageEntity>> by ArrayListSerializer(
|
||||
internal object RawMessageEntitiesSerializer : KSerializer<List<RawMessageEntity>> by ArrayListSerializer(
|
||||
RawMessageEntity.serializer()
|
||||
)
|
||||
|
@ -2,19 +2,14 @@ package com.github.insanusmokrassar.TelegramBotAPI.types
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Deprecated(
|
||||
"Deprecated because incorrect name",
|
||||
ReplaceWith("Response")
|
||||
)
|
||||
typealias ResponseParameters<T> = Response<T>
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
|
||||
@Serializable
|
||||
data class Response<T : Any>(
|
||||
data class Response(
|
||||
val ok: Boolean = false,
|
||||
val description: String? = null,
|
||||
@SerialName("error_code")
|
||||
val errorCode: Int? = null,
|
||||
val result: T? = null,
|
||||
val result: JsonElement? = null,
|
||||
val parameters: ResponseParametersRaw? = null
|
||||
)
|
||||
|
@ -1,10 +1,13 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
interface ExtendedPublicChat : ExtendedChat, PublicChat {
|
||||
val description: String
|
||||
val inviteLink: String?
|
||||
val pinnedMessage: RawMessage?
|
||||
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
|
||||
val pinnedMessage: Message?
|
||||
}
|
@ -2,7 +2,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.chat.extended
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedChannelChat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@ -21,5 +22,6 @@ data class ExtendedChannelChatImpl(
|
||||
@SerialName(inviteLinkField)
|
||||
override val inviteLink: String? = null,
|
||||
@SerialName(pinnedMessageField)
|
||||
override val pinnedMessage: RawMessage? = null
|
||||
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
|
||||
override val pinnedMessage: Message? = null
|
||||
) : ExtendedChannelChat
|
||||
|
@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.chat.extended
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedGroupChat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@ -22,5 +23,6 @@ data class ExtendedGroupChatImpl(
|
||||
@SerialName(inviteLinkField)
|
||||
override val inviteLink: String? = null,
|
||||
@SerialName(pinnedMessageField)
|
||||
override val pinnedMessage: RawMessage? = null
|
||||
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
|
||||
override val pinnedMessage: Message? = null
|
||||
) : ExtendedGroupChat
|
||||
|
@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.chat.extended
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedSupergroupChat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@ -24,7 +25,8 @@ data class ExtendedSupergroupChatImpl(
|
||||
@SerialName(inviteLinkField)
|
||||
override val inviteLink: String? = null,
|
||||
@SerialName(pinnedMessageField)
|
||||
override val pinnedMessage: RawMessage? = null,
|
||||
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
|
||||
override val pinnedMessage: Message? = null,
|
||||
@SerialName(stickerSetNameFullField)
|
||||
override val stickerSetName: StickerSetName? = null,
|
||||
@SerialName(canSetStickerSetField)
|
||||
|
@ -1,16 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.files
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.*
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class TelegramFile(
|
||||
@SerialName(fileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null,
|
||||
@SerialName("file_path")
|
||||
val filePath: String? = null
|
||||
) : TelegramMediaFile
|
@ -1,31 +1,33 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.games
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.*
|
||||
import kotlinx.serialization.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Titled
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AnimationFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Photo
|
||||
import kotlinx.serialization.Transient
|
||||
|
||||
@Serializable
|
||||
data class Game(
|
||||
@SerialName(titleField)
|
||||
val title: String,
|
||||
@SerialName(descriptionField)
|
||||
override val title: String,
|
||||
val description: String,
|
||||
@Serializable(PhotoSerializer::class)
|
||||
@SerialName(photoField)
|
||||
val photo: Photo,
|
||||
@SerialName(textField)
|
||||
val text: String? = null,
|
||||
@Serializable(RawMessageEntitiesSerializer::class)
|
||||
@SerialName(textEntitiesField)
|
||||
private val textEntitiesRaw: RawMessageEntities? = null,
|
||||
@SerialName(animationField)
|
||||
override val caption: String? = null,
|
||||
override val captionEntities: List<MessageEntity> = emptyList(),
|
||||
val animation: AnimationFile? = null
|
||||
) {
|
||||
) : Titled, CaptionedInput {
|
||||
@Deprecated(
|
||||
"Missinterfaced field",
|
||||
ReplaceWith("caption")
|
||||
)
|
||||
@Transient
|
||||
val textEntities: List<MessageEntity>? = text ?.let {
|
||||
textEntitiesRaw ?.map {
|
||||
it.asMessageEntity(text)
|
||||
}
|
||||
}
|
||||
val text: String?
|
||||
get() = caption
|
||||
|
||||
@Deprecated(
|
||||
"Missinterfaced field",
|
||||
ReplaceWith("captionEntities")
|
||||
)
|
||||
@Transient
|
||||
val textEntities: List<MessageEntity>?
|
||||
get() = captionEntities
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.games
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RawMessageEntities
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.*
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
internal data class RawGame(
|
||||
@SerialName(titleField)
|
||||
private val title: String,
|
||||
@SerialName(descriptionField)
|
||||
private val description: String,
|
||||
@Serializable(PhotoSerializer::class)
|
||||
@SerialName(photoField)
|
||||
private val photo: Photo,
|
||||
@SerialName(textField)
|
||||
private val caption: String? = null,
|
||||
@SerialName(textEntitiesField)
|
||||
private val captionEntities: RawMessageEntities = emptyList(),
|
||||
@SerialName(animationField)
|
||||
private val animation: AnimationFile? = null
|
||||
) {
|
||||
@Transient
|
||||
val asGame = Game(
|
||||
title,
|
||||
description,
|
||||
photo,
|
||||
caption,
|
||||
caption ?.let { _ -> captionEntities.map { it.asMessageEntity(caption) } } ?: emptyList(),
|
||||
animation
|
||||
)
|
||||
}
|
@ -2,11 +2,10 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RawMessageEntities
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RawMessageEntitiesSerializer
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.games.Game
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.games.RawGame
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ChatEvents.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ChatEvents.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
@ -24,7 +23,7 @@ import kotlin.reflect.KClass
|
||||
|
||||
// TODO:: add PassportData type
|
||||
@Serializable
|
||||
data class RawMessage(
|
||||
internal data class RawMessage(
|
||||
@SerialName(messageIdField)
|
||||
val messageId: MessageIdentifier,
|
||||
@SerialName(dateField)
|
||||
@ -44,15 +43,13 @@ data class RawMessage(
|
||||
private val media_group_id: MediaGroupIdentifier? = null,
|
||||
private val author_signature: AuthorSignature? = null,
|
||||
private val text: String? = null,
|
||||
@Serializable(RawMessageEntitiesSerializer::class)
|
||||
private val entities: RawMessageEntities? = null,
|
||||
private val caption: String? = null,
|
||||
@Serializable(RawMessageEntitiesSerializer::class)
|
||||
private val caption_entities: RawMessageEntities? = null,
|
||||
private val audio: AudioFile? = null,
|
||||
private val document: DocumentFile? = null,
|
||||
private val animation: AnimationFile? = null,
|
||||
private val game: Game? = null,
|
||||
private val game: RawGame? = null,
|
||||
@Serializable(PhotoSerializer::class)
|
||||
private val photo: Photo? = null,
|
||||
private val sticker: Sticker? = null,
|
||||
@ -128,7 +125,7 @@ data class RawMessage(
|
||||
adaptedCaptionEntities
|
||||
)
|
||||
sticker != null -> StickerContent(sticker)
|
||||
game != null -> GameContent(game)
|
||||
game != null -> GameContent(game.asGame)
|
||||
video_note != null -> VideoNoteContent(video_note)
|
||||
contact != null -> ContactContent(contact)
|
||||
location != null -> LocationContent(location)
|
||||
|
@ -2,6 +2,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.StringDescriptor
|
||||
import org.joda.time.DateTime
|
||||
|
||||
interface Message {
|
||||
@ -9,3 +12,25 @@ interface Message {
|
||||
val chat: Chat
|
||||
val date: DateTime
|
||||
}
|
||||
|
||||
internal object TelegramBotAPIMessageDeserializationStrategy : DeserializationStrategy<Message> {
|
||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("TelegramBotAPIMessageSerializer")
|
||||
|
||||
override fun patch(decoder: Decoder, old: Message): Message = throw UpdateNotSupportedException(descriptor.name)
|
||||
override fun deserialize(decoder: Decoder): Message {
|
||||
return RawMessage.serializer().deserialize(decoder).asMessage
|
||||
}
|
||||
}
|
||||
|
||||
internal object TelegramBotAPIMessageDeserializeOnlySerializer : KSerializer<Message> {
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy.descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): Message {
|
||||
return TelegramBotAPIMessageDeserializationStrategy.deserialize(decoder)
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, obj: Message) {
|
||||
throw UnsupportedOperationException("Currently, Message objects can't be serialized y this serializer")
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendContact
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||
|
||||
data class ContactContent(
|
||||
@ -15,7 +15,7 @@ data class ContactContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<RawMessage> = SendContact(
|
||||
): Request<Message> = SendContact(
|
||||
chatId, contact, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
}
|
@ -6,7 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.games.Game
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||
|
||||
data class GameContent(
|
||||
@ -17,7 +17,7 @@ data class GameContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<RawMessage> = SendGame(
|
||||
): Request<Message> = SendGame(
|
||||
chatId,
|
||||
game.title,
|
||||
disableNotification,
|
||||
|
@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendLocation
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||
|
||||
data class LocationContent(
|
||||
@ -15,7 +15,7 @@ data class LocationContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<RawMessage> = SendLocation(
|
||||
): Request<Message> = SendLocation(
|
||||
chatId,
|
||||
location.latitude,
|
||||
location.longitude,
|
||||
|
@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendPoll
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
||||
|
||||
@ -17,7 +17,7 @@ data class PollContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<RawMessage> = SendPoll(
|
||||
): Request<Message> = SendPoll(
|
||||
chatId,
|
||||
poll.question,
|
||||
poll.options.map { it.text },
|
||||
|
@ -7,7 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEnt
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlTexts
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownTexts
|
||||
@ -21,7 +21,7 @@ data class TextContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<RawMessage> = SendMessage(
|
||||
): Request<Message> = SendMessage(
|
||||
chatId,
|
||||
toHtmlTexts().first(),
|
||||
HTMLParseMode,
|
||||
@ -36,7 +36,7 @@ data class TextContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): List<Request<RawMessage>> = createResends(
|
||||
): List<Request<Message>> = createResends(
|
||||
chatId,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
@ -50,7 +50,7 @@ data class TextContent(
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?,
|
||||
parseMode: ParseMode = HTMLParseMode
|
||||
): List<Request<RawMessage>> = when (parseMode) {
|
||||
): List<Request<Message>> = when (parseMode) {
|
||||
is MarkdownParseMode -> toMarkdownTexts()
|
||||
is HTMLParseMode -> toHtmlTexts()
|
||||
}.map {
|
||||
|
@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendVenue
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||
|
||||
data class VenueContent(
|
||||
@ -15,7 +15,7 @@ data class VenueContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<RawMessage> = SendVenue(
|
||||
): Request<Message> = SendVenue(
|
||||
chatId, venue, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
}
|
@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
|
||||
interface ResendableContent {
|
||||
fun createResend(
|
||||
@ -12,12 +12,12 @@ interface ResendableContent {
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<RawMessage>
|
||||
): Request<Message>
|
||||
|
||||
fun createResends(
|
||||
chatId: ChatIdentifier,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): List<Request<RawMessage>> = listOf(createResend(chatId, disableNotification, replyToMessageId, replyMarkup))
|
||||
): List<Request<Message>> = listOf(createResend(chatId, disableNotification, replyToMessageId, replyMarkup))
|
||||
}
|
@ -7,11 +7,10 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AnimationFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||
|
||||
@ -26,22 +25,12 @@ data class AnimationContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<RawMessage> = createResend(chatId, toHtmlCaptions().firstOrNull(), HTMLParseMode, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
@Deprecated("Will be fully replaced by default method")
|
||||
fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
caption: String?,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<RawMessage> = SendAnimation(
|
||||
): Request<Message> = SendAnimation(
|
||||
chatId,
|
||||
media.fileId,
|
||||
media.thumb ?.fileId,
|
||||
caption,
|
||||
parseMode,
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
HTMLParseMode,
|
||||
media.duration,
|
||||
media.width,
|
||||
media.height,
|
||||
|
@ -9,7 +9,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||
|
||||
@ -23,7 +23,7 @@ data class AudioContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<RawMessage> = SendAudio(
|
||||
): Request<Message> = SendAudio(
|
||||
chatId,
|
||||
media.fileId,
|
||||
media.thumb ?.fileId,
|
||||
|
@ -9,7 +9,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||
|
||||
@ -23,7 +23,7 @@ data class DocumentContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<RawMessage> = SendDocument(
|
||||
): Request<Message> = SendDocument(
|
||||
chatId,
|
||||
media.fileId,
|
||||
media.thumb ?.fileId,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user