1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

"RawMessage" usages replaced by "Message" usages

This commit is contained in:
InsanusMokrassar 2019-08-17 11:50:46 +06:00
parent 8330aa1b3d
commit 56f36523db
96 changed files with 319 additions and 256 deletions

View File

@ -2,6 +2,12 @@
## 0.18.0 ## 0.18.0
* `RawMessage` now is internal class
* All `RawMessage` usages was replaced with `Message` interface
* `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
## 0.17.0 ## 0.17.0
Libraries updates: Libraries updates:

View File

@ -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.EmptyLimiter
import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.RequestLimiter import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.RequestLimiter
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request 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.Response
import com.github.insanusmokrassar.TelegramBotAPI.types.RetryAfterError import com.github.insanusmokrassar.TelegramBotAPI.types.RetryAfterError
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
@ -16,6 +17,7 @@ import io.ktor.client.engine.HttpClientEngine
import io.ktor.util.cio.toByteArray import io.ktor.util.cio.toByteArray
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonElementSerializer
class KtorRequestsExecutor( class KtorRequestsExecutor(
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper, telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
@ -74,11 +76,11 @@ class KtorRequestsExecutor(
val content = call.response.use { val content = call.response.use {
it.content.toByteArray().toString(Charsets.UTF_8) it.content.toByteArray().toString(Charsets.UTF_8)
} }
val responseObject = jsonFormatter.parse( val responseObject = jsonFormatter.extractResult(content)
Response.serializer(request.resultSerializer()),
content val result = responseObject.result ?.let {
) jsonFormatter.fromJson(request.resultDeserializer(), it)
responseObject.result ?: responseObject.parameters ?.let { } ?: responseObject.parameters ?.let {
val error = it.error val error = it.error
if (error is RetryAfterError) { if (error is RetryAfterError) {
delay(error.leftToRetry) delay(error.leftToRetry)
@ -93,6 +95,7 @@ class KtorRequestsExecutor(
"Can't get result object from $content" "Can't get result object from $content"
) )
} }
result
} }
} }

View File

@ -3,9 +3,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapWithCommonValues import com.github.insanusmokrassar.TelegramBotAPI.utils.mapWithCommonValues
import io.ktor.client.HttpClient 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.Headers
import io.ktor.http.HttpHeaders import io.ktor.http.HttpHeaders
import kotlinx.io.core.readBytes
class MultipartRequestCallFactory : AbstractRequestCallFactory() { class MultipartRequestCallFactory : AbstractRequestCallFactory() {
@ -21,9 +23,7 @@ class MultipartRequestCallFactory : AbstractRequestCallFactory() {
when (value) { when (value) {
is MultipartFile -> append( is MultipartFile -> append(
key, key,
InputProvider { value.file.asInput().readBytes(),
value.file.asInput()
},
Headers.build { Headers.build {
append(HttpHeaders.ContentType, value.mimeType) append(HttpHeaders.ContentType, value.mimeType)
append(HttpHeaders.ContentDisposition, "filename=${value.fileId}") append(HttpHeaders.ContentDisposition, "filename=${value.fileId}")

View File

@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.Response
import java.io.IOException import java.io.IOException
fun newRequestException( fun newRequestException(
response: Response<*>, response: Response,
plainAnswer: String, plainAnswer: String,
message: String? = null, message: String? = null,
cause: Throwable? = null cause: Throwable? = null
@ -15,7 +15,7 @@ fun newRequestException(
} }
sealed class RequestException constructor( sealed class RequestException constructor(
val response: Response<*>, val response: Response,
val plainAnswer: String, val plainAnswer: String,
message: String? = null, message: String? = null,
cause: Throwable? = null cause: Throwable? = null
@ -24,13 +24,13 @@ sealed class RequestException constructor(
cause 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) 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) 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) RequestException(response, plainAnswer, message, cause)
@Deprecated( @Deprecated(

View File

@ -15,5 +15,5 @@ data class DeleteMessage(
) : SimpleRequest<Boolean>, MessageAction { ) : SimpleRequest<Boolean>, MessageAction {
override fun method(): String = "deleteMessage" override fun method(): String = "deleteMessage"
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
} }

View File

@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
import kotlinx.serialization.* import kotlinx.serialization.*
@Serializable @Serializable
@ -16,12 +17,12 @@ data class ForwardMessage(
override val messageId: MessageIdentifier, override val messageId: MessageIdentifier,
@SerialName(disableNotificationField) @SerialName(disableNotificationField)
val disableNotification: Boolean = false val disableNotification: Boolean = false
): SimpleRequest<RawMessage>, MessageAction { ): SimpleRequest<Message>, MessageAction {
@Transient @Transient
override val chatId: ChatIdentifier override val chatId: ChatIdentifier
get() = fromChatId get() = fromChatId
override fun method(): String = "forwardMessage" override fun method(): String = "forwardMessage"
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }

View File

@ -8,5 +8,5 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
class GetMe : SimpleRequest<User> { class GetMe : SimpleRequest<User> {
override fun method(): String = "getMe" override fun method(): String = "getMe"
override fun resultSerializer(): KSerializer<User> = User.serializer() override fun resultDeserializer(): KSerializer<User> = User.serializer()
} }

View File

@ -38,5 +38,5 @@ data class GetUpdates(
): SimpleRequest<List<RawUpdate>> { ): SimpleRequest<List<RawUpdate>> {
override fun method(): String = "getUpdates" override fun method(): String = "getUpdates"
override fun resultSerializer(): KSerializer<List<RawUpdate>> = ArrayListSerializer(RawUpdate.serializer()) override fun resultDeserializer(): KSerializer<List<RawUpdate>> = ArrayListSerializer(RawUpdate.serializer())
} }

View File

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

View File

@ -8,14 +8,13 @@ import kotlinx.serialization.json.JsonObject
@Serializable(RequestSerializer::class) @Serializable(RequestSerializer::class)
interface Request<T: Any> { interface Request<T: Any> {
fun method(): String fun method(): String
fun resultSerializer(): KSerializer<T> fun resultDeserializer(): DeserializationStrategy<T>
fun json(): JsonObject = toJsonWithoutNulls(RequestSerializer) fun json(): JsonObject = toJsonWithoutNulls(RequestSerializer)
} }
object RequestSerializer : KSerializer<Request<*>> by ContextSerializer(Request::class) object RequestSerializer : KSerializer<Request<*>> by ContextSerializer(Request::class)
fun <T : Any> StringFormat.extractResult( fun StringFormat.extractResult(
from: String, from: String
dataSerializer: KSerializer<T> ): Response {
): Response<T> { return parse(Response.serializer(), from)
return parse(Response.serializer(dataSerializer), from)
} }

View File

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

View File

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

View File

@ -7,7 +7,7 @@ import kotlinx.serialization.serializer
interface AnswerPreCheckoutQuery : SimpleRequest<Boolean> { interface AnswerPreCheckoutQuery : SimpleRequest<Boolean> {
override fun method(): String = "answerPreCheckoutQuery" override fun method(): String = "answerPreCheckoutQuery"
override fun resultSerializer(): KSerializer<Boolean> = Boolean.serializer() override fun resultDeserializer(): KSerializer<Boolean> = Boolean.serializer()
val preCheckoutQueryId: PreCheckoutQueryId val preCheckoutQueryId: PreCheckoutQueryId
val isOk: Boolean val isOk: Boolean

View File

@ -7,7 +7,7 @@ import kotlinx.serialization.serializer
interface AnswerShippingQuery : SimpleRequest<Boolean> { interface AnswerShippingQuery : SimpleRequest<Boolean> {
override fun method(): String = "answerShippingQuery" override fun method(): String = "answerShippingQuery"
override fun resultSerializer(): KSerializer<Boolean> = Boolean.serializer() override fun resultDeserializer(): KSerializer<Boolean> = Boolean.serializer()
val shippingQueryId: ShippingQueryIdentifier val shippingQueryId: ShippingQueryIdentifier
val isOk: Boolean val isOk: Boolean

View File

@ -13,5 +13,5 @@ data class ExportChatInviteLink(
override val chatId: ChatIdentifier override val chatId: ChatIdentifier
): ChatRequest, SimpleRequest<String> { ): ChatRequest, SimpleRequest<String> {
override fun method(): String = "exportChatInviteLink" override fun method(): String = "exportChatInviteLink"
override fun resultSerializer(): KSerializer<String> = StringSerializer override fun resultDeserializer(): KSerializer<String> = StringSerializer
} }

View File

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

View File

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

View File

@ -14,5 +14,5 @@ data class GetChatAdministrators(
override val chatId: ChatIdentifier override val chatId: ChatIdentifier
): ChatRequest, SimpleRequest<List<RawChatMember>> { ): ChatRequest, SimpleRequest<List<RawChatMember>> {
override fun method(): String = "getChatAdministrators" override fun method(): String = "getChatAdministrators"
override fun resultSerializer(): KSerializer<List<RawChatMember>> = ArrayListSerializer(RawChatMember.serializer()) override fun resultDeserializer(): KSerializer<List<RawChatMember>> = ArrayListSerializer(RawChatMember.serializer())
} }

View File

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

View File

@ -13,5 +13,5 @@ data class GetChatMember(
override val userId: UserId override val userId: UserId
) : ChatMemberRequest<RawChatMember> { ) : ChatMemberRequest<RawChatMember> {
override fun method(): String = "getChatMember" override fun method(): String = "getChatMember"
override fun resultSerializer(): KSerializer<RawChatMember> = RawChatMember.serializer() override fun resultDeserializer(): KSerializer<RawChatMember> = RawChatMember.serializer()
} }

View File

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

View File

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

View File

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

View File

@ -13,5 +13,5 @@ data class UnbanChatMember(
override val userId: UserId override val userId: UserId
) : ChatMemberRequest<Boolean> { ) : ChatMemberRequest<Boolean> {
override fun method(): String = "unbanChatMember" override fun method(): String = "unbanChatMember"
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
} }

View File

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

View File

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

View File

@ -20,5 +20,5 @@ data class SetChatDescription (
} }
override fun method(): String = "setChatDescription" override fun method(): String = "setChatDescription"
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
} }

View File

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

View File

@ -16,7 +16,7 @@ data class SetChatPhoto (
val photo: MultipartFile = throw IllegalArgumentException("Unfortunately, this type of objects can't be parsed automatically") val photo: MultipartFile = throw IllegalArgumentException("Unfortunately, this type of objects can't be parsed automatically")
): ChatRequest, MultipartRequest<Boolean> { ): ChatRequest, MultipartRequest<Boolean> {
override fun method(): String = "setChatPhoto" override fun method(): String = "setChatPhoto"
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
override val mediaMap: Map<String, MultipartFile> = mapOf(photoField to photo) override val mediaMap: Map<String, MultipartFile> = mapOf(photoField to photo)
override val paramsJson: JsonObject = toJson(serializer()) override val paramsJson: JsonObject = toJson(serializer())
} }

View File

@ -20,5 +20,5 @@ data class SetChatTitle (
} }
override fun method(): String = "setChatTitle" override fun method(): String = "setChatTitle"
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
} }

View File

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

View File

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

View File

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

View File

@ -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.requests.edit.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import 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.* import kotlinx.serialization.*
@Serializable @Serializable
@ -20,5 +21,5 @@ data class EditChatMessageLiveLocation(
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditChatMessage, EditReplyMessage, EditLocationMessage { ) : EditChatMessage, EditReplyMessage, EditLocationMessage {
override fun method(): String = "editMessageLiveLocation" override fun method(): String = "editMessageLiveLocation"
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }

View File

@ -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.requests.edit.abstracts.EditReplyMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import 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.* import kotlinx.serialization.*
@Serializable @Serializable
@ -17,5 +18,5 @@ data class StopChatMessageLiveLocation(
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditChatMessage, EditReplyMessage { ) : EditChatMessage, EditReplyMessage {
override fun method(): String = "stopMessageLiveLocation" override fun method(): String = "stopMessageLiveLocation"
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }

View File

@ -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.requests.edit.abstracts.EditReplyMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import 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.* import kotlinx.serialization.*
const val editMessageReplyMarkupMethod = "editMessageReplyMarkup" const val editMessageReplyMarkupMethod = "editMessageReplyMarkup"
@ -20,5 +21,5 @@ data class EditChatMessageReplyMarkup(
) : EditChatMessage, EditReplyMessage { ) : EditChatMessage, EditReplyMessage {
override fun method(): String = editMessageReplyMarkupMethod override fun method(): String = editMessageReplyMarkupMethod
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }

View File

@ -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.CommonAbstracts.types.MessageAction
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest 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

View File

@ -7,5 +7,5 @@ import kotlinx.serialization.internal.BooleanSerializer
interface EditInlineMessage : SimpleRequest<Boolean> { interface EditInlineMessage : SimpleRequest<Boolean> {
val inlineMessageId: InlineMessageIdentifier val inlineMessageId: InlineMessageIdentifier
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
} }

View File

@ -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.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import 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.* import kotlinx.serialization.*
const val editMessageCaptionMethod = "editMessageCaption" const val editMessageCaptionMethod = "editMessageCaption"
@ -25,5 +26,5 @@ data class EditChatMessageCaption(
) : EditChatMessage, EditTextChatMessage, EditReplyMessage { ) : EditChatMessage, EditTextChatMessage, EditReplyMessage {
override fun method(): String = editMessageCaptionMethod override fun method(): String = editMessageCaptionMethod
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }

View File

@ -5,7 +5,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import 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.* import kotlinx.serialization.*
const val editMessageMediaMethod = "editMessageMedia" const val editMessageMediaMethod = "editMessageMedia"
@ -29,5 +30,5 @@ data class EditChatMessageMedia(
} }
override fun method(): String = editMessageMediaMethod override fun method(): String = editMessageMediaMethod
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }

View File

@ -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.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import 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.* import kotlinx.serialization.*
const val editMessageTextMethod = "editMessageText" const val editMessageTextMethod = "editMessageText"
@ -27,5 +28,5 @@ data class EditChatMessageText(
) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage { ) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
override fun method(): String = editMessageTextMethod override fun method(): String = editMessageTextMethod
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }

View File

@ -10,7 +10,7 @@ interface GetGameHighScores : SimpleRequest<List<GameHighScore>> {
val userId: UserId val userId: UserId
override fun method(): String = "getGameHighScores" 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()) object GameHighScoresSerializer : KSerializer<List<GameHighScore>> by ArrayListSerializer(GameHighScore.serializer())

View File

@ -12,5 +12,5 @@ interface SetGameScore : SimpleRequest<Boolean> {
val disableEditMessage: Boolean val disableEditMessage: Boolean
override fun method(): String = "setGameScore" override fun method(): String = "setGameScore"
override fun resultSerializer(): KSerializer<Boolean> = Boolean.serializer() override fun resultDeserializer(): KSerializer<Boolean> = Boolean.serializer()
} }

View File

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

View File

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

View File

@ -23,5 +23,5 @@ data class GetUserProfilePhotos(
} }
override fun method(): String = "getUserProfilePhotos" override fun method(): String = "getUserProfilePhotos"
override fun resultSerializer(): KSerializer<UserProfilePhotos> = UserProfilePhotos.serializer() override fun resultDeserializer(): KSerializer<UserProfilePhotos> = UserProfilePhotos.serializer()
} }

View File

@ -17,5 +17,5 @@ data class SendAction(
val action: BotAction val action: BotAction
): SendChatMessageRequest<Boolean> { ): SendChatMessageRequest<Boolean> {
override fun method(): String = "sendChatAction" override fun method(): String = "sendChatAction"
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
} }

View File

@ -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.requests.send.abstracts.SendMessageRequest
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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.* import kotlinx.serialization.*
@Serializable @Serializable
@ -23,8 +24,8 @@ data class SendContact(
override val replyToMessageId: MessageIdentifier? = null, override val replyToMessageId: MessageIdentifier? = null,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: KeyboardMarkup? = null override val replyMarkup: KeyboardMarkup? = null
) : SendMessageRequest<RawMessage>, ) : SendMessageRequest<Message>,
ReplyingMarkupSendMessageRequest<RawMessage> ReplyingMarkupSendMessageRequest<Message>
{ {
constructor( constructor(
chatId: ChatIdentifier, chatId: ChatIdentifier,
@ -43,7 +44,7 @@ data class SendContact(
) )
override fun method(): String = "sendContact" override fun method(): String = "sendContact"
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }
fun Contact.toRequest( fun Contact.toRequest(

View File

@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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.* import kotlinx.serialization.*
// TODO:: Add location tracker for tracking location // TODO:: Add location tracker for tracking location
@ -23,11 +24,11 @@ data class SendLocation(
override val replyToMessageId: MessageIdentifier? = null, override val replyToMessageId: MessageIdentifier? = null,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: KeyboardMarkup? = null override val replyMarkup: KeyboardMarkup? = null
) : SendMessageRequest<RawMessage>, ) : SendMessageRequest<Message>,
ReplyingMarkupSendMessageRequest<RawMessage>, ReplyingMarkupSendMessageRequest<Message>,
PositionedSendMessageRequest<RawMessage> PositionedSendMessageRequest<Message>
{ {
override fun method(): String = "sendLocation" override fun method(): String = "sendLocation"
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }

View File

@ -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.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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.* import kotlinx.serialization.*
@Serializable @Serializable
@ -25,9 +26,9 @@ data class SendMessage(
override val replyToMessageId: MessageIdentifier? = null, override val replyToMessageId: MessageIdentifier? = null,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: KeyboardMarkup? = null override val replyMarkup: KeyboardMarkup? = null
) : SendMessageRequest<RawMessage>, ) : SendMessageRequest<Message>,
ReplyingMarkupSendMessageRequest<RawMessage>, ReplyingMarkupSendMessageRequest<Message>,
TextableSendMessageRequest<RawMessage>, TextableSendMessageRequest<Message>,
DisableWebPagePreview DisableWebPagePreview
{ {
init { init {
@ -37,5 +38,5 @@ data class SendMessage(
} }
override fun method(): String = "sendMessage" override fun method(): String = "sendMessage"
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }

View File

@ -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.requests.send.abstracts.SendMessageRequest
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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.* import kotlinx.serialization.*
@Serializable @Serializable
@ -21,8 +22,8 @@ data class SendPoll(
override val replyToMessageId: MessageIdentifier? = null, override val replyToMessageId: MessageIdentifier? = null,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: KeyboardMarkup? = null override val replyMarkup: KeyboardMarkup? = null
) : SendMessageRequest<RawMessage>, ) : SendMessageRequest<Message>,
ReplyingMarkupSendMessageRequest<RawMessage> { ReplyingMarkupSendMessageRequest<Message> {
init { init {
if (question.length !in pollQuestionTextLength) { if (question.length !in pollQuestionTextLength) {
@ -39,5 +40,5 @@ data class SendPoll(
} }
override fun method(): String = "sendPoll" override fun method(): String = "sendPoll"
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }

View File

@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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.* import kotlinx.serialization.*
@Serializable @Serializable
@ -26,10 +27,10 @@ data class SendVenue(
override val replyToMessageId: MessageIdentifier? = null, override val replyToMessageId: MessageIdentifier? = null,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: KeyboardMarkup? = null override val replyMarkup: KeyboardMarkup? = null
) : SendMessageRequest<RawMessage>, ) : SendMessageRequest<Message>,
PositionedSendMessageRequest<RawMessage>, PositionedSendMessageRequest<Message>,
TitledSendMessageRequest<RawMessage>, TitledSendMessageRequest<Message>,
ReplyingMarkupSendMessageRequest<RawMessage> ReplyingMarkupSendMessageRequest<Message>
{ {
constructor( constructor(
chatId: ChatIdentifier, chatId: ChatIdentifier,
@ -50,7 +51,7 @@ data class SendVenue(
) )
override fun method(): String = "sendVenue" override fun method(): String = "sendVenue"
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }
fun Venue.toRequest( fun Venue.toRequest(

View File

@ -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.requests.send.abstracts.SendMessageRequest
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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.* import kotlinx.serialization.*
@Serializable @Serializable
@ -19,8 +20,8 @@ data class SendGame (
override val replyToMessageId: MessageIdentifier? = null, override val replyToMessageId: MessageIdentifier? = null,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: KeyboardMarkup? = null override val replyMarkup: KeyboardMarkup? = null
) : SendMessageRequest<RawMessage>, ) : SendMessageRequest<Message>,
ReplyMarkup { ReplyMarkup {
override fun method(): String = "sendGame" override fun method(): String = "sendGame"
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }

View File

@ -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.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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 com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
import kotlinx.serialization.* import kotlinx.serialization.*
@ -23,7 +24,7 @@ fun SendAnimation(
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<RawMessage> { ): Request<Message> {
val animationAsFileId = (animation as? FileId) ?.fileId val animationAsFileId = (animation as? FileId) ?.fileId
val animationAsFile = animation as? MultipartFile val animationAsFile = animation as? MultipartFile
val thumbAsFileId = (thumb as? FileId) ?.fileId val thumbAsFileId = (thumb as? FileId) ?.fileId
@ -77,13 +78,13 @@ data class SendAnimationData internal constructor(
override val replyToMessageId: MessageIdentifier? = null, override val replyToMessageId: MessageIdentifier? = null,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: KeyboardMarkup? = null override val replyMarkup: KeyboardMarkup? = null
) : DataRequest<RawMessage>, ) : DataRequest<Message>,
SendMessageRequest<RawMessage>, SendMessageRequest<Message>,
ReplyingMarkupSendMessageRequest<RawMessage>, ReplyingMarkupSendMessageRequest<Message>,
TextableSendMessageRequest<RawMessage>, TextableSendMessageRequest<Message>,
ThumbedSendMessageRequest<RawMessage>, ThumbedSendMessageRequest<Message>,
DuratedSendMessageRequest<RawMessage>, DuratedSendMessageRequest<Message>,
SizedSendMessageRequest<RawMessage> SizedSendMessageRequest<Message>
{ {
init { init {
text ?.let { text ?.let {
@ -94,7 +95,7 @@ data class SendAnimationData internal constructor(
} }
override fun method(): String = "sendAnimation" override fun method(): String = "sendAnimation"
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }
data class SendAnimationFiles internal constructor( data class SendAnimationFiles internal constructor(

View File

@ -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.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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 com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
import kotlinx.serialization.* import kotlinx.serialization.*
@ -24,7 +25,7 @@ fun SendAudio(
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<RawMessage> { ): Request<Message> {
val audioAsFileId = (audio as? FileId) ?.fileId val audioAsFileId = (audio as? FileId) ?.fileId
val audioAsFile = audio as? MultipartFile val audioAsFile = audio as? MultipartFile
val thumbAsFileId = (thumb as? FileId) ?.fileId val thumbAsFileId = (thumb as? FileId) ?.fileId
@ -78,13 +79,13 @@ data class SendAudioData internal constructor(
override val replyToMessageId: MessageIdentifier? = null, override val replyToMessageId: MessageIdentifier? = null,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: KeyboardMarkup? = null override val replyMarkup: KeyboardMarkup? = null
) : DataRequest<RawMessage>, ) : DataRequest<Message>,
SendMessageRequest<RawMessage>, SendMessageRequest<Message>,
ReplyingMarkupSendMessageRequest<RawMessage>, ReplyingMarkupSendMessageRequest<Message>,
TextableSendMessageRequest<RawMessage>, TextableSendMessageRequest<Message>,
ThumbedSendMessageRequest<RawMessage>, ThumbedSendMessageRequest<Message>,
TitledSendMessageRequest<RawMessage>, TitledSendMessageRequest<Message>,
DuratedSendMessageRequest<RawMessage>, DuratedSendMessageRequest<Message>,
Performerable Performerable
{ {
init { init {
@ -96,7 +97,7 @@ data class SendAudioData internal constructor(
} }
override fun method(): String = "sendAudio" override fun method(): String = "sendAudio"
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }
data class SendAudioFiles internal constructor( data class SendAudioFiles internal constructor(

View File

@ -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.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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 com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
import kotlinx.serialization.* import kotlinx.serialization.*
@ -20,7 +21,7 @@ fun SendDocument(
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<RawMessage> { ): Request<Message> {
val documentAsFileId = (document as? FileId) ?.fileId val documentAsFileId = (document as? FileId) ?.fileId
val documentAsFile = document as? MultipartFile val documentAsFile = document as? MultipartFile
val thumbAsFileId = (thumb as? FileId) ?.fileId val thumbAsFileId = (thumb as? FileId) ?.fileId
@ -65,11 +66,11 @@ data class SendDocumentData internal constructor(
override val replyToMessageId: MessageIdentifier? = null, override val replyToMessageId: MessageIdentifier? = null,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: KeyboardMarkup? = null override val replyMarkup: KeyboardMarkup? = null
) : DataRequest<RawMessage>, ) : DataRequest<Message>,
SendMessageRequest<RawMessage>, SendMessageRequest<Message>,
ReplyingMarkupSendMessageRequest<RawMessage>, ReplyingMarkupSendMessageRequest<Message>,
TextableSendMessageRequest<RawMessage>, TextableSendMessageRequest<Message>,
ThumbedSendMessageRequest<RawMessage> ThumbedSendMessageRequest<Message>
{ {
init { init {
text ?.let { text ?.let {
@ -80,7 +81,7 @@ data class SendDocumentData internal constructor(
} }
override fun method(): String = "sendDocument" override fun method(): String = "sendDocument"
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }
data class SendDocumentFiles internal constructor( data class SendDocumentFiles internal constructor(

View File

@ -6,7 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMe
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.* import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.internal.ArrayListSerializer import kotlinx.serialization.internal.ArrayListSerializer
@ -19,7 +19,7 @@ fun SendMediaGroup(
media: List<MediaGroupMemberInputMedia>, media: List<MediaGroupMemberInputMedia>,
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null replyToMessageId: MessageIdentifier? = null
): Request<List<RawMessage>> { ): Request<List<Message>> {
if (media.size !in membersCountInMediaGroup) { if (media.size !in membersCountInMediaGroup) {
throw IllegalArgumentException("Count of members for media group must be in $membersCountInMediaGroup range") throw IllegalArgumentException("Count of members for media group must be in $membersCountInMediaGroup range")
} }
@ -52,7 +52,7 @@ fun SendMediaGroup(
} }
} }
private val serializer = ArrayListSerializer(RawMessage.serializer()) private val serializer = ArrayListSerializer(TelegramBotAPIMessageDeserializeOnlySerializer)
@Serializable @Serializable
data class SendMediaGroupData internal constructor( data class SendMediaGroupData internal constructor(
@ -63,8 +63,8 @@ data class SendMediaGroupData internal constructor(
override val disableNotification: Boolean = false, override val disableNotification: Boolean = false,
@SerialName(replyToMessageIdField) @SerialName(replyToMessageIdField)
override val replyToMessageId: MessageIdentifier? = null override val replyToMessageId: MessageIdentifier? = null
) : DataRequest<List<RawMessage>>, ) : DataRequest<List<Message>>,
SendMessageRequest<List<RawMessage>> SendMessageRequest<List<Message>>
{ {
@SerialName(mediaField) @SerialName(mediaField)
private val convertedMedia: String private val convertedMedia: String
@ -76,7 +76,7 @@ data class SendMediaGroupData internal constructor(
override fun method(): String = "sendMediaGroup" override fun method(): String = "sendMediaGroup"
override fun resultSerializer(): KSerializer<List<RawMessage>> = serializer override fun resultDeserializer(): DeserializationStrategy<List<Message>> = serializer
} }
data class SendMediaGroupFiles internal constructor( data class SendMediaGroupFiles internal constructor(

View File

@ -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.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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.* import kotlinx.serialization.*
fun SendPhoto( fun SendPhoto(
@ -18,7 +19,7 @@ fun SendPhoto(
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<RawMessage> { ): Request<Message> {
val data = SendPhotoData( val data = SendPhotoData(
chatId, chatId,
(photo as? FileId) ?.fileId, (photo as? FileId) ?.fileId,
@ -52,10 +53,10 @@ data class SendPhotoData internal constructor(
override val replyToMessageId: MessageIdentifier? = null, override val replyToMessageId: MessageIdentifier? = null,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: KeyboardMarkup? = null override val replyMarkup: KeyboardMarkup? = null
) : DataRequest<RawMessage>, ) : DataRequest<Message>,
SendMessageRequest<RawMessage>, SendMessageRequest<Message>,
ReplyingMarkupSendMessageRequest<RawMessage>, ReplyingMarkupSendMessageRequest<Message>,
TextableSendMessageRequest<RawMessage> TextableSendMessageRequest<Message>
{ {
init { init {
text ?.let { text ?.let {
@ -66,7 +67,7 @@ data class SendPhotoData internal constructor(
} }
override fun method(): String = "sendPhoto" override fun method(): String = "sendPhoto"
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }
data class SendPhotoFiles internal constructor( data class SendPhotoFiles internal constructor(

View File

@ -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.requests.send.abstracts.SendMessageRequest
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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 com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonObject
@ -16,7 +17,7 @@ fun SendSticker(
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<RawMessage> = SendStickerByFileId( ): Request<Message> = SendStickerByFileId(
chatId, chatId,
sticker as? FileId, sticker as? FileId,
disableNotification, disableNotification,
@ -41,16 +42,16 @@ data class SendStickerByFileId internal constructor(
override val replyToMessageId: MessageIdentifier? = null, override val replyToMessageId: MessageIdentifier? = null,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: KeyboardMarkup? = null override val replyMarkup: KeyboardMarkup? = null
) : SendMessageRequest<RawMessage>, ReplyingMarkupSendMessageRequest<RawMessage> { ) : SendMessageRequest<Message>, ReplyingMarkupSendMessageRequest<Message> {
override fun method(): String = "sendSticker" override fun method(): String = "sendSticker"
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }
data class SendStickerByFile internal constructor( data class SendStickerByFile internal constructor(
@Transient @Transient
private val sendStickerByFileId: SendStickerByFileId, private val sendStickerByFileId: SendStickerByFileId,
val sticker: MultipartFile 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 mediaMap: Map<String, MultipartFile> = mapOf(stickerField to sticker)
override val paramsJson: JsonObject = sendStickerByFileId.toJsonWithoutNulls(SendStickerByFileId.serializer()) override val paramsJson: JsonObject = sendStickerByFileId.toJsonWithoutNulls(SendStickerByFileId.serializer())
} }

View File

@ -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.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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 com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
import kotlinx.serialization.* import kotlinx.serialization.*
@ -24,7 +25,7 @@ fun SendVideo(
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<RawMessage> { ): Request<Message> {
val videoAsFileId = (video as? FileId) ?.fileId val videoAsFileId = (video as? FileId) ?.fileId
val videoAsFile = video as? MultipartFile val videoAsFile = video as? MultipartFile
val thumbAsFileId = (thumb as? FileId) ?.fileId val thumbAsFileId = (thumb as? FileId) ?.fileId
@ -81,13 +82,13 @@ data class SendVideoData internal constructor(
override val replyToMessageId: MessageIdentifier? = null, override val replyToMessageId: MessageIdentifier? = null,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: KeyboardMarkup? = null override val replyMarkup: KeyboardMarkup? = null
) : DataRequest<RawMessage>, ) : DataRequest<Message>,
SendMessageRequest<RawMessage>, SendMessageRequest<Message>,
ReplyingMarkupSendMessageRequest<RawMessage>, ReplyingMarkupSendMessageRequest<Message>,
TextableSendMessageRequest<RawMessage>, TextableSendMessageRequest<Message>,
ThumbedSendMessageRequest<RawMessage>, ThumbedSendMessageRequest<Message>,
DuratedSendMessageRequest<RawMessage>, DuratedSendMessageRequest<Message>,
SizedSendMessageRequest<RawMessage> SizedSendMessageRequest<Message>
{ {
init { init {
text ?.let { text ?.let {
@ -98,7 +99,7 @@ data class SendVideoData internal constructor(
} }
override fun method(): String = "sendVideo" override fun method(): String = "sendVideo"
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }
data class SendVideoFiles internal constructor( data class SendVideoFiles internal constructor(

View File

@ -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.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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 com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
import kotlinx.serialization.* import kotlinx.serialization.*
@ -22,7 +23,7 @@ fun SendVideoNote(
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<RawMessage> { ): Request<Message> {
val videoNoteAsFileId = (videoNote as? FileId) ?.fileId val videoNoteAsFileId = (videoNote as? FileId) ?.fileId
val videoNoteAsFile = videoNote as? MultipartFile val videoNoteAsFile = videoNote as? MultipartFile
val thumbAsFileId = (thumb as? FileId) ?.fileId val thumbAsFileId = (thumb as? FileId) ?.fileId
@ -73,13 +74,13 @@ data class SendVideoNoteData internal constructor(
override val replyToMessageId: MessageIdentifier? = null, override val replyToMessageId: MessageIdentifier? = null,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: KeyboardMarkup? = null override val replyMarkup: KeyboardMarkup? = null
) : DataRequest<RawMessage>, ) : DataRequest<Message>,
SendMessageRequest<RawMessage>, SendMessageRequest<Message>,
ReplyingMarkupSendMessageRequest<RawMessage>, ReplyingMarkupSendMessageRequest<Message>,
TextableSendMessageRequest<RawMessage>, TextableSendMessageRequest<Message>,
ThumbedSendMessageRequest<RawMessage>, ThumbedSendMessageRequest<Message>,
DuratedSendMessageRequest<RawMessage>, DuratedSendMessageRequest<Message>,
SizedSendMessageRequest<RawMessage> SizedSendMessageRequest<Message>
{ {
@Transient @Transient
override val height: Int? override val height: Int?
@ -94,7 +95,7 @@ data class SendVideoNoteData internal constructor(
} }
override fun method(): String = "sendVideoNote" override fun method(): String = "sendVideoNote"
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }
data class SendVideoNoteFiles internal constructor( data class SendVideoNoteFiles internal constructor(

View File

@ -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.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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 com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
import kotlinx.serialization.* import kotlinx.serialization.*
@ -21,7 +22,7 @@ fun SendVoice(
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<RawMessage> { ): Request<Message> {
val voiceAsFileId = (voice as? FileId) ?.fileId val voiceAsFileId = (voice as? FileId) ?.fileId
val voiceAsFile = voice as? MultipartFile val voiceAsFile = voice as? MultipartFile
val thumbAsFileId = (thumb as? FileId) ?.fileId val thumbAsFileId = (thumb as? FileId) ?.fileId
@ -69,12 +70,12 @@ data class SendVoiceData internal constructor(
override val replyToMessageId: MessageIdentifier? = null, override val replyToMessageId: MessageIdentifier? = null,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: KeyboardMarkup? = null override val replyMarkup: KeyboardMarkup? = null
) : DataRequest<RawMessage>, ) : DataRequest<Message>,
SendMessageRequest<RawMessage>, SendMessageRequest<Message>,
ReplyingMarkupSendMessageRequest<RawMessage>, ReplyingMarkupSendMessageRequest<Message>,
TextableSendMessageRequest<RawMessage>, TextableSendMessageRequest<Message>,
ThumbedSendMessageRequest<RawMessage>, ThumbedSendMessageRequest<Message>,
DuratedSendMessageRequest<RawMessage> DuratedSendMessageRequest<Message>
{ {
init { init {
text ?.let { text ?.let {
@ -85,7 +86,7 @@ data class SendVoiceData internal constructor(
} }
override fun method(): String = "sendVoice" override fun method(): String = "sendVoice"
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
} }
data class SendVoiceFiles internal constructor( data class SendVoiceFiles internal constructor(

View File

@ -2,6 +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.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartRequest
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.KSerializer import kotlinx.serialization.KSerializer
import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonObject
@ -13,7 +14,7 @@ class MultipartRequestImpl<D: DataRequest<R>, F: Files, R: Any>(
val files: F val files: F
) : MultipartRequest<R> { ) : MultipartRequest<R> {
override fun method(): String = data.method() override fun method(): String = data.method()
override fun resultSerializer(): KSerializer<R> = data.resultSerializer() override fun resultDeserializer(): DeserializationStrategy<R> = data.resultDeserializer()
override val paramsJson: JsonObject = data.json() override val paramsJson: JsonObject = data.json()
override val mediaMap: Map<String, MultipartFile> = files override val mediaMap: Map<String, MultipartFile> = files
} }

View File

@ -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.requests.send.abstracts.SendMessageRequest
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import 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.LabeledPrice
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPricesSerializer import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPricesSerializer
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.payments.abstracts.*
@ -62,9 +63,9 @@ data class SendInvoice(
DisableNotification, DisableNotification,
ReplyMessageId, ReplyMessageId,
ReplyMarkup, ReplyMarkup,
SendMessageRequest<RawMessage> { SendMessageRequest<Message> {
override fun method(): String = "sendInvoice" override fun method(): String = "sendInvoice"
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer() override fun resultDeserializer(): DeserializationStrategy<Message> = TelegramBotAPIMessageDeserializationStrategy
@SerialName(photoUrlField) @SerialName(photoUrlField)
var photoUrl: String? = null var photoUrl: String? = null

View File

@ -12,5 +12,5 @@ data class DeleteStickerFromSet(
val sticker: FileId val sticker: FileId
) : SimpleRequest<Boolean> { ) : SimpleRequest<Boolean> {
override fun method(): String = "deleteStickerFromSet" override fun method(): String = "deleteStickerFromSet"
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
} }

View File

@ -21,5 +21,5 @@ data class SetStickerPositionInSet(
} }
override fun method(): String = "setStickerPositionInSet" override fun method(): String = "setStickerPositionInSet"
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
} }

View File

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

View File

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

View File

@ -9,5 +9,5 @@ import kotlinx.serialization.internal.BooleanSerializer
class DeleteWebhook : SimpleRequest<Boolean> { class DeleteWebhook : SimpleRequest<Boolean> {
override fun method(): String = "deleteWebhook" override fun method(): String = "deleteWebhook"
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer override fun resultDeserializer(): KSerializer<Boolean> = BooleanSerializer
} }

View File

@ -9,5 +9,5 @@ import kotlinx.serialization.Serializable
class GetWebhookInfo : SimpleRequest<WebhookInfo> { class GetWebhookInfo : SimpleRequest<WebhookInfo> {
override fun method(): String = "getWebhookInfo" override fun method(): String = "getWebhookInfo"
override fun resultSerializer(): KSerializer<WebhookInfo> = WebhookInfo.serializer() override fun resultDeserializer(): KSerializer<WebhookInfo> = WebhookInfo.serializer()
} }

View File

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

View File

@ -2,6 +2,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage 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.* import kotlinx.serialization.*
@Serializable @Serializable
@ -10,7 +12,8 @@ data class RawCallbackQuery(
val id: CallbackQueryIdentifier, val id: CallbackQueryIdentifier,
@SerialName(fromField) @SerialName(fromField)
val from: User, val from: User,
val message: RawMessage? = null, @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
val message: Message? = null,
@SerialName(inlineMessageIdField) @SerialName(inlineMessageIdField)
val inlineMessageId: InlineMessageIdentifier? = null, val inlineMessageId: InlineMessageIdentifier? = null,
@SerialName("chat_instance") @SerialName("chat_instance")
@ -22,8 +25,8 @@ data class RawCallbackQuery(
@Transient @Transient
val asCallbackQuery: CallbackQuery by lazy { val asCallbackQuery: CallbackQuery by lazy {
when { when {
message != null && data != null -> MessageDataCallbackQuery(id, from, chatInstance, message.asMessage, data) message != null && data != null -> MessageDataCallbackQuery(id, from, chatInstance, message, data)
message != null && gameShortName != null -> MessageGameShortNameCallbackQuery(id, from, chatInstance, message.asMessage, gameShortName) message != null && gameShortName != null -> MessageGameShortNameCallbackQuery(id, from, chatInstance, message, gameShortName)
inlineMessageId != null && data != null -> InlineMessageIdDataCallbackQuery(id, from, chatInstance, inlineMessageId, data) inlineMessageId != null && data != null -> InlineMessageIdDataCallbackQuery(id, from, chatInstance, inlineMessageId, data)
inlineMessageId != null && gameShortName != null -> InlineMessageIdGameShortNameCallbackQuery(id, from, chatInstance, inlineMessageId, gameShortName) inlineMessageId != null && gameShortName != null -> InlineMessageIdGameShortNameCallbackQuery(id, from, chatInstance, inlineMessageId, gameShortName)
else -> throw IllegalStateException("Strange answer from server, can't create callback query") else -> throw IllegalStateException("Strange answer from server, can't create callback query")

View File

@ -2,19 +2,14 @@ package com.github.insanusmokrassar.TelegramBotAPI.types
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonElement
@Deprecated(
"Deprecated because incorrect name",
ReplaceWith("Response")
)
typealias ResponseParameters<T> = Response<T>
@Serializable @Serializable
data class Response<T : Any>( data class Response(
val ok: Boolean = false, val ok: Boolean = false,
val description: String? = null, val description: String? = null,
@SerialName("error_code") @SerialName("error_code")
val errorCode: Int? = null, val errorCode: Int? = null,
val result: T? = null, val result: JsonElement? = null,
val parameters: ResponseParametersRaw? = null val parameters: ResponseParametersRaw? = null
) )

View File

@ -2,9 +2,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.chat.abstracts.PublicChat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage 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 { interface ExtendedPublicChat : ExtendedChat, PublicChat {
val description: String val description: String
val inviteLink: String? val inviteLink: String?
val pinnedMessage: RawMessage? @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
val pinnedMessage: Message?
} }

View File

@ -3,6 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.chat.extended
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedChannelChat 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.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.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@ -21,5 +23,6 @@ data class ExtendedChannelChatImpl(
@SerialName(inviteLinkField) @SerialName(inviteLinkField)
override val inviteLink: String? = null, override val inviteLink: String? = null,
@SerialName(pinnedMessageField) @SerialName(pinnedMessageField)
override val pinnedMessage: RawMessage? = null @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
override val pinnedMessage: Message? = null
) : ExtendedChannelChat ) : ExtendedChannelChat

View File

@ -4,6 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedGroupChat 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.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.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@ -22,5 +24,6 @@ data class ExtendedGroupChatImpl(
@SerialName(inviteLinkField) @SerialName(inviteLinkField)
override val inviteLink: String? = null, override val inviteLink: String? = null,
@SerialName(pinnedMessageField) @SerialName(pinnedMessageField)
override val pinnedMessage: RawMessage? = null @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
override val pinnedMessage: Message? = null
) : ExtendedGroupChat ) : ExtendedGroupChat

View File

@ -4,6 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedSupergroupChat 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.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.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@ -24,7 +26,8 @@ data class ExtendedSupergroupChatImpl(
@SerialName(inviteLinkField) @SerialName(inviteLinkField)
override val inviteLink: String? = null, override val inviteLink: String? = null,
@SerialName(pinnedMessageField) @SerialName(pinnedMessageField)
override val pinnedMessage: RawMessage? = null, @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
override val pinnedMessage: Message? = null,
@SerialName(stickerSetNameFullField) @SerialName(stickerSetNameFullField)
override val stickerSetName: StickerSetName? = null, override val stickerSetName: StickerSetName? = null,
@SerialName(canSetStickerSetField) @SerialName(canSetStickerSetField)

View File

@ -24,7 +24,7 @@ import kotlin.reflect.KClass
// TODO:: add PassportData type // TODO:: add PassportData type
@Serializable @Serializable
data class RawMessage( internal data class RawMessage(
@SerialName(messageIdField) @SerialName(messageIdField)
val messageId: MessageIdentifier, val messageId: MessageIdentifier,
@SerialName(dateField) @SerialName(dateField)

View File

@ -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.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
import kotlinx.serialization.*
import kotlinx.serialization.internal.StringDescriptor
import org.joda.time.DateTime import org.joda.time.DateTime
interface Message { interface Message {
@ -9,3 +12,25 @@ interface Message {
val chat: Chat val chat: Chat
val date: DateTime val date: DateTime
} }
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
}
}
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 IllegalStateException("Currently, Message objects can't be serialized y this serializer")
}
}

View File

@ -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.requests.send.SendContact
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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.message.content.abstracts.MessageContent
data class ContactContent( data class ContactContent(
@ -15,7 +15,7 @@ data class ContactContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<RawMessage> = SendContact( ): Request<Message> = SendContact(
chatId, contact, disableNotification, replyToMessageId, replyMarkup chatId, contact, disableNotification, replyToMessageId, replyMarkup
) )
} }

View File

@ -6,7 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.games.Game 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 import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
data class GameContent( data class GameContent(
@ -17,7 +17,7 @@ data class GameContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<RawMessage> = SendGame( ): Request<Message> = SendGame(
chatId, chatId,
game.title, game.title,
disableNotification, disableNotification,

View File

@ -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.requests.send.SendLocation
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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.message.content.abstracts.MessageContent
data class LocationContent( data class LocationContent(
@ -15,7 +15,7 @@ data class LocationContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<RawMessage> = SendLocation( ): Request<Message> = SendLocation(
chatId, chatId,
location.latitude, location.latitude,
location.longitude, location.longitude,

View File

@ -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.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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.message.content.abstracts.MessageContent
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
@ -17,7 +17,7 @@ data class PollContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<RawMessage> = SendPoll( ): Request<Message> = SendPoll(
chatId, chatId,
poll.question, poll.question,
poll.options.map { it.text }, poll.options.map { it.text },

View File

@ -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.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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.message.content.abstracts.MessageContent
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlTexts import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlTexts
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownTexts import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownTexts
@ -21,7 +21,7 @@ data class TextContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<RawMessage> = SendMessage( ): Request<Message> = SendMessage(
chatId, chatId,
toHtmlTexts().first(), toHtmlTexts().first(),
HTMLParseMode, HTMLParseMode,
@ -36,7 +36,7 @@ data class TextContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): List<Request<RawMessage>> = createResends( ): List<Request<Message>> = createResends(
chatId, chatId,
disableNotification, disableNotification,
replyToMessageId, replyToMessageId,
@ -50,7 +50,7 @@ data class TextContent(
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup?, replyMarkup: KeyboardMarkup?,
parseMode: ParseMode = HTMLParseMode parseMode: ParseMode = HTMLParseMode
): List<Request<RawMessage>> = when (parseMode) { ): List<Request<Message>> = when (parseMode) {
is MarkdownParseMode -> toMarkdownTexts() is MarkdownParseMode -> toMarkdownTexts()
is HTMLParseMode -> toHtmlTexts() is HTMLParseMode -> toHtmlTexts()
}.map { }.map {

View File

@ -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.requests.send.SendVenue
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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.message.content.abstracts.MessageContent
data class VenueContent( data class VenueContent(
@ -15,7 +15,7 @@ data class VenueContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<RawMessage> = SendVenue( ): Request<Message> = SendVenue(
chatId, venue, disableNotification, replyToMessageId, replyMarkup chatId, venue, disableNotification, replyToMessageId, replyMarkup
) )
} }

View File

@ -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.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup 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 { interface ResendableContent {
fun createResend( fun createResend(
@ -12,12 +12,12 @@ interface ResendableContent {
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<RawMessage> ): Request<Message>
fun createResends( fun createResends(
chatId: ChatIdentifier, chatId: ChatIdentifier,
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): List<Request<RawMessage>> = listOf(createResend(chatId, disableNotification, replyToMessageId, replyMarkup)) ): List<Request<Message>> = listOf(createResend(chatId, disableNotification, replyToMessageId, replyMarkup))
} }

View File

@ -11,7 +11,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AnimationFile import com.github.insanusmokrassar.TelegramBotAPI.types.files.AnimationFile
import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile 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.types.message.content.abstracts.MediaContent
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
@ -26,22 +26,12 @@ data class AnimationContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<RawMessage> = createResend(chatId, toHtmlCaptions().firstOrNull(), HTMLParseMode, disableNotification, replyToMessageId, replyMarkup) ): Request<Message> = SendAnimation(
@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(
chatId, chatId,
media.fileId, media.fileId,
media.thumb ?.fileId, media.thumb ?.fileId,
caption, toHtmlCaptions().firstOrNull(),
parseMode, HTMLParseMode,
media.duration, media.duration,
media.width, media.width,
media.height, media.height,

View File

@ -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.ParseMode.HTMLParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile 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.types.message.content.abstracts.MediaContent
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
@ -23,7 +23,7 @@ data class AudioContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<RawMessage> = SendAudio( ): Request<Message> = SendAudio(
chatId, chatId,
media.fileId, media.fileId,
media.thumb ?.fileId, media.thumb ?.fileId,

View File

@ -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.ParseMode.HTMLParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile 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.types.message.content.abstracts.MediaContent
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
@ -23,7 +23,7 @@ data class DocumentContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<RawMessage> = SendDocument( ): Request<Message> = SendDocument(
chatId, chatId,
media.fileId, media.fileId,
media.thumb ?.fileId, media.thumb ?.fileId,

View File

@ -11,7 +11,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
import com.github.insanusmokrassar.TelegramBotAPI.types.files.biggest import com.github.insanusmokrassar.TelegramBotAPI.types.files.biggest
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.MediaCollectionContent import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaCollectionContent
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaGroupContent import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaGroupContent
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
@ -28,7 +28,7 @@ data class PhotoContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<RawMessage> = SendPhoto( ): Request<Message> = SendPhoto(
chatId, chatId,
media.fileId, media.fileId,
toHtmlCaptions().firstOrNull(), toHtmlCaptions().firstOrNull(),

View File

@ -6,7 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
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.types.message.content.abstracts.MediaContent
data class StickerContent( data class StickerContent(
@ -17,7 +17,7 @@ data class StickerContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<RawMessage> = SendSticker( ): Request<Message> = SendSticker(
chatId, chatId,
media.fileId, media.fileId,
disableNotification, disableNotification,

View File

@ -10,7 +10,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile
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.MediaGroupContent import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaGroupContent
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
@ -24,7 +24,7 @@ data class VideoContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<RawMessage> = SendVideo( ): Request<Message> = SendVideo(
chatId, chatId,
media.fileId, media.fileId,
media.thumb ?.fileId, media.thumb ?.fileId,

View File

@ -7,7 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoNoteFile import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoNoteFile
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.types.message.content.abstracts.MediaContent
data class VideoNoteContent( data class VideoNoteContent(
@ -18,7 +18,7 @@ data class VideoNoteContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<RawMessage> = createResend(chatId, null, null, disableNotification, replyToMessageId, replyMarkup) ): Request<Message> = createResend(chatId, null, null, disableNotification, replyToMessageId, replyMarkup)
fun createResend( fun createResend(
chatId: ChatIdentifier, chatId: ChatIdentifier,
@ -27,7 +27,7 @@ data class VideoNoteContent(
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<RawMessage> = SendVideoNote( ): Request<Message> = SendVideoNote(
chatId, chatId,
media.fileId, media.fileId,
media.thumb ?.fileId, media.thumb ?.fileId,

View File

@ -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.ParseMode.HTMLParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VoiceFile import com.github.insanusmokrassar.TelegramBotAPI.types.files.VoiceFile
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.types.message.content.abstracts.MediaContent
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
@ -23,7 +23,7 @@ data class VoiceContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<RawMessage> = SendVoice( ): Request<Message> = SendVoice(
chatId, chatId,
media.fileId, media.fileId,
null, null,

View File

@ -5,6 +5,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.ChosenInli
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.query.RawInlineQuery import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.query.RawInlineQuery
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage 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.types.payments.PreCheckoutQuery import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
@ -18,10 +20,14 @@ import kotlinx.serialization.*
data class RawUpdate constructor( data class RawUpdate constructor(
@SerialName(updateIdField) @SerialName(updateIdField)
val updateId: UpdateIdentifier, val updateId: UpdateIdentifier,
private val edited_message: RawMessage? = null, @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
private val message: RawMessage? = null, private val edited_message: Message? = null,
private val edited_channel_post: RawMessage? = null, @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
private val channel_post: RawMessage? = null, private val message: Message? = null,
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
private val edited_channel_post: Message? = null,
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
private val channel_post: Message? = null,
private val inline_query: RawInlineQuery? = null, private val inline_query: RawInlineQuery? = null,
private val chosen_inline_result: RawChosenInlineResult? = null, private val chosen_inline_result: RawChosenInlineResult? = null,
private val callback_query: RawCallbackQuery? = null, private val callback_query: RawCallbackQuery? = null,
@ -32,10 +38,10 @@ data class RawUpdate constructor(
@Transient @Transient
val asUpdate: Update by lazy { val asUpdate: Update by lazy {
when { when {
edited_message != null -> EditMessageUpdate(updateId, edited_message.asMessage) edited_message != null -> EditMessageUpdate(updateId, edited_message)
message != null -> MessageUpdate(updateId, message.asMessage) message != null -> MessageUpdate(updateId, message)
edited_channel_post != null -> EditChannelPostUpdate(updateId, edited_channel_post.asMessage) edited_channel_post != null -> EditChannelPostUpdate(updateId, edited_channel_post)
channel_post != null -> ChannelPostUpdate(updateId, channel_post.asMessage) channel_post != null -> ChannelPostUpdate(updateId, channel_post)
chosen_inline_result != null -> ChosenInlineResultUpdate(updateId, chosen_inline_result.asChosenInlineResult) chosen_inline_result != null -> ChosenInlineResultUpdate(updateId, chosen_inline_result.asChosenInlineResult)
inline_query != null -> InlineQueryUpdate(updateId, inline_query.asInlineQuery) inline_query != null -> InlineQueryUpdate(updateId, inline_query.asInlineQuery)

View File

@ -9,7 +9,7 @@ import kotlinx.coroutines.*
fun <T: Any> RequestsExecutor.executeAsync( fun <T: Any> RequestsExecutor.executeAsync(
request: Request<T>, request: Request<T>,
onFail: (suspend (Response<*>) -> Unit)? = null, onFail: (suspend (Response) -> Unit)? = null,
scope: CoroutineScope = GlobalScope, scope: CoroutineScope = GlobalScope,
onSuccess: (suspend (T) -> Unit)? = null onSuccess: (suspend (T) -> Unit)? = null
): Job { ): Job {