1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-29 21:48:43 +00:00

now most part of request have changed return types

This commit is contained in:
InsanusMokrassar 2020-01-15 11:17:53 +06:00
parent 4c60b8fd82
commit 3fa2071847
42 changed files with 304 additions and 196 deletions

View File

@ -3,10 +3,13 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardedMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
import kotlinx.serialization.* import kotlinx.serialization.*
private val AbleToBeForwardedMessageDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<AbleToBeForwardedMessage>()
@Serializable @Serializable
data class ForwardMessage( data class ForwardMessage(
@SerialName(fromChatIdField) @SerialName(fromChatIdField)
@ -17,15 +20,14 @@ data class ForwardMessage(
override val messageId: MessageIdentifier, override val messageId: MessageIdentifier,
@SerialName(disableNotificationField) @SerialName(disableNotificationField)
val disableNotification: Boolean = false val disableNotification: Boolean = false
): SimpleRequest<Message>, MessageAction { ): SimpleRequest<AbleToBeForwardedMessage>, MessageAction {
@Transient
override val chatId: ChatIdentifier override val chatId: ChatIdentifier
get() = fromChatId get() = fromChatId
override fun method(): String = "forwardMessage" override fun method(): String = "forwardMessage"
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<AbleToBeForwardedMessage>
get() = TelegramBotAPIMessageDeserializationStrategy get() = AbleToBeForwardedMessageDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -3,23 +3,22 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMember import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMemberSerializerWithoutDeserialization
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.internal.ArrayListSerializer import kotlinx.serialization.internal.ArrayListSerializer
private val chatMembersListSerializer = ArrayListSerializer( private val chatMembersListSerializer = ArrayListSerializer(
ChatMemberSerializerWithoutDeserialization AdministratorChatMemberSerializerWithoutDeserialization
) )
@Serializable @Serializable
data class GetChatAdministrators( data class GetChatAdministrators(
@SerialName(chatIdField) @SerialName(chatIdField)
override val chatId: ChatIdentifier override val chatId: ChatIdentifier
): ChatRequest, SimpleRequest<List<ChatMember>> { ): ChatRequest, SimpleRequest<List<AdministratorChatMember>> {
override fun method(): String = "getChatAdministrators" override fun method(): String = "getChatAdministrators"
override val resultDeserializer: DeserializationStrategy<List<ChatMember>> override val resultDeserializer: DeserializationStrategy<List<AdministratorChatMember>>
get() = chatMembersListSerializer get() = chatMembersListSerializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()

View File

@ -3,10 +3,15 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
import kotlinx.serialization.* import kotlinx.serialization.*
private val commonResultDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<ContentMessage<LocationContent>>()
@Serializable @Serializable
data class EditChatMessageLiveLocation( data class EditChatMessageLiveLocation(
@SerialName(chatIdField) @SerialName(chatIdField)
@ -19,10 +24,10 @@ data class EditChatMessageLiveLocation(
override val longitude: Double, override val longitude: Double,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditChatMessage, EditReplyMessage, EditLocationMessage { ) : EditChatMessage<LocationContent>, EditReplyMessage, EditLocationMessage {
override fun method(): String = "editMessageLiveLocation" override fun method(): String = "editMessageLiveLocation"
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = commonResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -4,10 +4,14 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
import kotlinx.serialization.* import kotlinx.serialization.*
private val commonResultDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<ContentMessage<LocationContent>>()
@Serializable @Serializable
data class StopChatMessageLiveLocation( data class StopChatMessageLiveLocation(
@SerialName(chatIdField) @SerialName(chatIdField)
@ -16,10 +20,10 @@ data class StopChatMessageLiveLocation(
override val messageId: MessageIdentifier, override val messageId: MessageIdentifier,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditChatMessage, EditReplyMessage { ) : EditChatMessage<LocationContent>, EditReplyMessage {
override fun method(): String = "stopMessageLiveLocation" override fun method(): String = "stopMessageLiveLocation"
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = commonResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -4,12 +4,16 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
import kotlinx.serialization.* import kotlinx.serialization.*
const val editMessageReplyMarkupMethod = "editMessageReplyMarkup" const val editMessageReplyMarkupMethod = "editMessageReplyMarkup"
private val commonResultDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<ContentMessage<MessageContent>>()
@Serializable @Serializable
data class EditChatMessageReplyMarkup( data class EditChatMessageReplyMarkup(
@SerialName(chatIdField) @SerialName(chatIdField)
@ -18,11 +22,11 @@ data class EditChatMessageReplyMarkup(
override val messageId: MessageIdentifier, override val messageId: MessageIdentifier,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditChatMessage, EditReplyMessage { ) : EditChatMessage<MessageContent>, EditReplyMessage {
override fun method(): String = editMessageReplyMarkupMethod override fun method(): String = editMessageReplyMarkupMethod
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<MessageContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = commonResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -2,6 +2,7 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
interface EditChatMessage : SimpleRequest<Message>, MessageAction interface EditChatMessage<MT: MessageContent> : SimpleRequest<ContentMessage<MT>>, MessageAction

View File

@ -1,12 +1,15 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.MediaContentMessageResultDeserializer
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
import kotlinx.serialization.* import kotlinx.serialization.*
const val editMessageCaptionMethod = "editMessageCaption" const val editMessageCaptionMethod = "editMessageCaption"
@ -23,11 +26,11 @@ data class EditChatMessageCaption(
override val parseMode: ParseMode? = null, override val parseMode: ParseMode? = null,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditChatMessage, EditTextChatMessage, EditReplyMessage { ) : EditChatMessage<MediaContent>, EditTextChatMessage, EditReplyMessage {
override fun method(): String = editMessageCaptionMethod override fun method(): String = editMessageCaptionMethod
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<MediaContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = MediaContentMessageResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -5,12 +5,15 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
import kotlinx.serialization.* import kotlinx.serialization.*
const val editMessageMediaMethod = "editMessageMedia" const val editMessageMediaMethod = "editMessageMedia"
internal val MediaContentMessageResultDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<ContentMessage<MediaContent>>()
@Serializable @Serializable
data class EditChatMessageMedia( data class EditChatMessageMedia(
@SerialName(chatIdField) @SerialName(chatIdField)
@ -21,7 +24,7 @@ data class EditChatMessageMedia(
override val media: InputMedia, override val media: InputMedia,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditChatMessage, EditReplyMessage, EditMediaMessage { ) : EditChatMessage<MediaContent>, EditReplyMessage, EditMediaMessage {
init { init {
if (media.file is MultipartFile) { if (media.file is MultipartFile) {
@ -30,8 +33,8 @@ data class EditChatMessageMedia(
} }
override fun method(): String = editMessageMediaMethod override fun method(): String = editMessageMediaMethod
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<MediaContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = MediaContentMessageResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -1,12 +1,14 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.TextContentMessageResultDeserializer
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
import kotlinx.serialization.* import kotlinx.serialization.*
const val editMessageTextMethod = "editMessageText" const val editMessageTextMethod = "editMessageText"
@ -25,11 +27,11 @@ data class EditChatMessageText(
override val disableWebPagePreview: Boolean? = null, override val disableWebPagePreview: Boolean? = null,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage { ) : EditChatMessage<TextContent>, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
override fun method(): String = editMessageTextMethod override fun method(): String = editMessageTextMethod
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<TextContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = TextContentMessageResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -4,10 +4,14 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.ContactContent
import kotlinx.serialization.* import kotlinx.serialization.*
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<ContactContent>>
= TelegramBotAPIMessageDeserializationStrategyClass()
@Serializable @Serializable
data class SendContact( data class SendContact(
@SerialName(chatIdField) @SerialName(chatIdField)
@ -24,8 +28,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<Message>, ) : SendMessageRequest<ContentMessage<ContactContent>>,
ReplyingMarkupSendMessageRequest<Message> ReplyingMarkupSendMessageRequest<ContentMessage<ContactContent>>
{ {
constructor( constructor(
chatId: ChatIdentifier, chatId: ChatIdentifier,
@ -44,8 +48,8 @@ data class SendContact(
) )
override fun method(): String = "sendContact" override fun method(): String = "sendContact"
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<ContactContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = commonResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -3,10 +3,15 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
import kotlinx.serialization.* import kotlinx.serialization.*
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
= TelegramBotAPIMessageDeserializationStrategyClass()
// TODO:: Add location tracker for tracking location // TODO:: Add location tracker for tracking location
@Serializable @Serializable
data class SendLocation( data class SendLocation(
@ -24,14 +29,14 @@ 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<Message>, ) : SendMessageRequest<ContentMessage<LocationContent>>,
ReplyingMarkupSendMessageRequest<Message>, ReplyingMarkupSendMessageRequest<ContentMessage<LocationContent>>,
PositionedSendMessageRequest<Message> PositionedSendMessageRequest<ContentMessage<LocationContent>>
{ {
override fun method(): String = "sendLocation" override fun method(): String = "sendLocation"
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = commonResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -6,12 +6,15 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
import kotlinx.serialization.* import kotlinx.serialization.*
internal val TextContentMessageResultDeserializer: DeserializationStrategy<ContentMessage<TextContent>>
= TelegramBotAPIMessageDeserializationStrategyClass()
@Serializable @Serializable
data class SendMessage( data class SendTextMessage(
@SerialName(chatIdField) @SerialName(chatIdField)
override val chatId: ChatIdentifier, override val chatId: ChatIdentifier,
@SerialName(textField) @SerialName(textField)
@ -26,9 +29,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<Message>, ) : SendMessageRequest<ContentMessage<TextContent>>,
ReplyingMarkupSendMessageRequest<Message>, ReplyingMarkupSendMessageRequest<ContentMessage<TextContent>>,
TextableSendMessageRequest<Message>, TextableSendMessageRequest<ContentMessage<TextContent>>,
DisableWebPagePreview DisableWebPagePreview
{ {
init { init {
@ -38,8 +41,16 @@ data class SendMessage(
} }
override fun method(): String = "sendMessage" override fun method(): String = "sendMessage"
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<TextContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = TextContentMessageResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated(
"This declaration is deprecated due violation of common naming rules",
ReplaceWith(
"SendTextMessage"
)
)
typealias SendMessage = SendTextMessage

View File

@ -4,10 +4,14 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.PollContent
import kotlinx.serialization.* import kotlinx.serialization.*
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PollContent>>
= TelegramBotAPIMessageDeserializationStrategyClass()
@Serializable @Serializable
data class SendPoll( data class SendPoll(
@SerialName(chatIdField) @SerialName(chatIdField)
@ -22,8 +26,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<Message>, ) : SendMessageRequest<ContentMessage<PollContent>>,
ReplyingMarkupSendMessageRequest<Message> { ReplyingMarkupSendMessageRequest<ContentMessage<PollContent>> {
init { init {
if (question.length !in pollQuestionTextLength) { if (question.length !in pollQuestionTextLength) {
@ -40,8 +44,8 @@ data class SendPoll(
} }
override fun method(): String = "sendPoll" override fun method(): String = "sendPoll"
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<PollContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = commonResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -3,10 +3,13 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.VenueContent
import kotlinx.serialization.* import kotlinx.serialization.*
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VenueContent>>
= TelegramBotAPIMessageDeserializationStrategyClass()
@Serializable @Serializable
data class SendVenue( data class SendVenue(
@SerialName(chatIdField) @SerialName(chatIdField)
@ -27,10 +30,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<Message>, ) : SendMessageRequest<ContentMessage<VenueContent>>,
PositionedSendMessageRequest<Message>, PositionedSendMessageRequest<ContentMessage<VenueContent>>,
TitledSendMessageRequest<Message>, TitledSendMessageRequest<ContentMessage<VenueContent>>,
ReplyingMarkupSendMessageRequest<Message> ReplyingMarkupSendMessageRequest<ContentMessage<VenueContent>>
{ {
constructor( constructor(
chatId: ChatIdentifier, chatId: ChatIdentifier,
@ -51,8 +54,8 @@ data class SendVenue(
) )
override fun method(): String = "sendVenue" override fun method(): String = "sendVenue"
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<VenueContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = commonResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -4,10 +4,14 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.GameContent
import kotlinx.serialization.* import kotlinx.serialization.*
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<GameContent>>
= TelegramBotAPIMessageDeserializationStrategyClass()
@Serializable @Serializable
data class SendGame ( data class SendGame (
@SerialName(chatIdField) @SerialName(chatIdField)
@ -20,11 +24,11 @@ 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<Message>, ) : SendMessageRequest<ContentMessage<GameContent>>,
ReplyMarkup { ReplyMarkup {
override fun method(): String = "sendGame" override fun method(): String = "sendGame"
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<GameContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = commonResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -7,8 +7,9 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.AnimationContent
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 SendAnimation(
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<Message> { ): Request<ContentMessage<AnimationContent>> {
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
@ -54,6 +55,9 @@ fun SendAnimation(
} }
} }
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<AnimationContent>>
= TelegramBotAPIMessageDeserializationStrategyClass()
@Serializable @Serializable
data class SendAnimationData internal constructor( data class SendAnimationData internal constructor(
@SerialName(chatIdField) @SerialName(chatIdField)
@ -78,13 +82,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<Message>, ) : DataRequest<ContentMessage<AnimationContent>>,
SendMessageRequest<Message>, SendMessageRequest<ContentMessage<AnimationContent>>,
ReplyingMarkupSendMessageRequest<Message>, ReplyingMarkupSendMessageRequest<ContentMessage<AnimationContent>>,
TextableSendMessageRequest<Message>, TextableSendMessageRequest<ContentMessage<AnimationContent>>,
ThumbedSendMessageRequest<Message>, ThumbedSendMessageRequest<ContentMessage<AnimationContent>>,
DuratedSendMessageRequest<Message>, DuratedSendMessageRequest<ContentMessage<AnimationContent>>,
SizedSendMessageRequest<Message> SizedSendMessageRequest<ContentMessage<AnimationContent>>
{ {
init { init {
text ?.let { text ?.let {
@ -95,8 +99,8 @@ data class SendAnimationData internal constructor(
} }
override fun method(): String = "sendAnimation" override fun method(): String = "sendAnimation"
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<AnimationContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = commonResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -8,8 +8,9 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.AudioContent
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
import kotlinx.serialization.* import kotlinx.serialization.*
@ -25,7 +26,7 @@ fun SendAudio(
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<Message> { ): Request<ContentMessage<AudioContent>> {
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
@ -55,6 +56,9 @@ fun SendAudio(
} }
} }
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<AudioContent>>
= TelegramBotAPIMessageDeserializationStrategyClass()
@Serializable @Serializable
data class SendAudioData internal constructor( data class SendAudioData internal constructor(
@SerialName(chatIdField) @SerialName(chatIdField)
@ -79,13 +83,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<Message>, ) : DataRequest<ContentMessage<AudioContent>>,
SendMessageRequest<Message>, SendMessageRequest<ContentMessage<AudioContent>>,
ReplyingMarkupSendMessageRequest<Message>, ReplyingMarkupSendMessageRequest<ContentMessage<AudioContent>>,
TextableSendMessageRequest<Message>, TextableSendMessageRequest<ContentMessage<AudioContent>>,
ThumbedSendMessageRequest<Message>, ThumbedSendMessageRequest<ContentMessage<AudioContent>>,
TitledSendMessageRequest<Message>, TitledSendMessageRequest<ContentMessage<AudioContent>>,
DuratedSendMessageRequest<Message>, DuratedSendMessageRequest<ContentMessage<AudioContent>>,
Performerable Performerable
{ {
init { init {
@ -97,8 +101,8 @@ data class SendAudioData internal constructor(
} }
override fun method(): String = "sendAudio" override fun method(): String = "sendAudio"
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<AudioContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = commonResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -7,8 +7,9 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.DocumentContent
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 SendDocument(
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<Message> { ): Request<ContentMessage<DocumentContent>> {
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
@ -48,6 +49,9 @@ fun SendDocument(
} }
} }
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<DocumentContent>>
= TelegramBotAPIMessageDeserializationStrategyClass()
@Serializable @Serializable
data class SendDocumentData internal constructor( data class SendDocumentData internal constructor(
@SerialName(chatIdField) @SerialName(chatIdField)
@ -66,11 +70,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<Message>, ) : DataRequest<ContentMessage<DocumentContent>>,
SendMessageRequest<Message>, SendMessageRequest<ContentMessage<DocumentContent>>,
ReplyingMarkupSendMessageRequest<Message>, ReplyingMarkupSendMessageRequest<ContentMessage<DocumentContent>>,
TextableSendMessageRequest<Message>, TextableSendMessageRequest<ContentMessage<DocumentContent>>,
ThumbedSendMessageRequest<Message> ThumbedSendMessageRequest<ContentMessage<DocumentContent>>
{ {
init { init {
text ?.let { text ?.let {
@ -81,8 +85,8 @@ data class SendDocumentData internal constructor(
} }
override fun method(): String = "sendDocument" override fun method(): String = "sendDocument"
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<DocumentContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = commonResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -6,8 +6,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMe
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.* import com.github.insanusmokrassar.TelegramBotAPI.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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.internal.ArrayListSerializer import kotlinx.serialization.internal.ArrayListSerializer
@ -20,7 +20,7 @@ fun SendMediaGroup(
media: List<MediaGroupMemberInputMedia>, media: List<MediaGroupMemberInputMedia>,
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null replyToMessageId: MessageIdentifier? = null
): Request<List<Message>> { ): Request<List<MediaGroupMessage>> {
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")
} }
@ -53,7 +53,8 @@ fun SendMediaGroup(
} }
} }
private val messagesListSerializer = ArrayListSerializer(TelegramBotAPIMessageDeserializeOnlySerializer) private val messagesListSerializer: ArrayListSerializer<MediaGroupMessage>
= ArrayListSerializer(TelegramBotAPIMessageDeserializeOnlySerializerClass())
@Serializable @Serializable
data class SendMediaGroupData internal constructor( data class SendMediaGroupData internal constructor(
@ -64,7 +65,7 @@ data class SendMediaGroupData internal constructor(
override val disableNotification: Boolean = false, override val disableNotification: Boolean = false,
@SerialName(replyToMessageIdField) @SerialName(replyToMessageIdField)
override val replyToMessageId: MessageIdentifier? = null override val replyToMessageId: MessageIdentifier? = null
) : DataRequest<List<Message>>, SendMessageRequest<List<Message>> { ) : DataRequest<List<MediaGroupMessage>>, SendMessageRequest<List<MediaGroupMessage>> {
@SerialName(mediaField) @SerialName(mediaField)
private val convertedMedia: String private val convertedMedia: String
get() = jsonArray { get() = jsonArray {
@ -77,7 +78,7 @@ data class SendMediaGroupData internal constructor(
override fun method(): String = "sendMediaGroup" override fun method(): String = "sendMediaGroup"
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
override val resultDeserializer: DeserializationStrategy<List<Message>> override val resultDeserializer: DeserializationStrategy<List<MediaGroupMessage>>
get() = messagesListSerializer get() = messagesListSerializer
} }

View File

@ -7,8 +7,9 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.PhotoContent
import kotlinx.serialization.* import kotlinx.serialization.*
fun SendPhoto( fun SendPhoto(
@ -19,7 +20,7 @@ fun SendPhoto(
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<Message> { ): Request<ContentMessage<PhotoContent>> {
val data = SendPhotoData( val data = SendPhotoData(
chatId, chatId,
(photo as? FileId) ?.fileId, (photo as? FileId) ?.fileId,
@ -37,6 +38,9 @@ fun SendPhoto(
) )
} }
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PhotoContent>>
= TelegramBotAPIMessageDeserializationStrategyClass()
@Serializable @Serializable
data class SendPhotoData internal constructor( data class SendPhotoData internal constructor(
@SerialName(chatIdField) @SerialName(chatIdField)
@ -53,10 +57,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<Message>, ) : DataRequest<ContentMessage<PhotoContent>>,
SendMessageRequest<Message>, SendMessageRequest<ContentMessage<PhotoContent>>,
ReplyingMarkupSendMessageRequest<Message>, ReplyingMarkupSendMessageRequest<ContentMessage<PhotoContent>>,
TextableSendMessageRequest<Message> TextableSendMessageRequest<ContentMessage<PhotoContent>>
{ {
init { init {
text ?.let { text ?.let {
@ -67,8 +71,8 @@ data class SendPhotoData internal constructor(
} }
override fun method(): String = "sendPhoto" override fun method(): String = "sendPhoto"
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<PhotoContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = commonResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -5,8 +5,9 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.StickerContent
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
@ -17,7 +18,7 @@ fun SendSticker(
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<Message> = SendStickerByFileId( ): Request<ContentMessage<StickerContent>> = SendStickerByFileId(
chatId, chatId,
sticker as? FileId, sticker as? FileId,
disableNotification, disableNotification,
@ -30,6 +31,9 @@ fun SendSticker(
} }
} }
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<StickerContent>>
= TelegramBotAPIMessageDeserializationStrategyClass()
@Serializable @Serializable
data class SendStickerByFileId internal constructor( data class SendStickerByFileId internal constructor(
@SerialName(chatIdField) @SerialName(chatIdField)
@ -42,10 +46,10 @@ 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<Message>, ReplyingMarkupSendMessageRequest<Message> { ) : SendMessageRequest<ContentMessage<StickerContent>>, ReplyingMarkupSendMessageRequest<ContentMessage<StickerContent>> {
override fun method(): String = "sendSticker" override fun method(): String = "sendSticker"
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<StickerContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = commonResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@ -54,7 +58,7 @@ data class SendStickerByFile internal constructor(
@Transient @Transient
private val sendStickerByFileId: SendStickerByFileId, private val sendStickerByFileId: SendStickerByFileId,
val sticker: MultipartFile val sticker: MultipartFile
) : MultipartRequest<Message>, Request<Message> by sendStickerByFileId { ) : MultipartRequest<ContentMessage<StickerContent>>, Request<ContentMessage<StickerContent>> 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,8 +7,9 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.VideoContent
import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull import com.github.insanusmokrassar.TelegramBotAPI.utils.mapOfNotNull
import kotlinx.serialization.* import kotlinx.serialization.*
@ -25,7 +26,7 @@ fun SendVideo(
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<Message> { ): Request<ContentMessage<VideoContent>> {
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
@ -56,6 +57,9 @@ fun SendVideo(
} }
} }
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VideoContent>>
= TelegramBotAPIMessageDeserializationStrategyClass()
@Serializable @Serializable
data class SendVideoData internal constructor( data class SendVideoData internal constructor(
@SerialName(chatIdField) @SerialName(chatIdField)
@ -82,13 +86,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<Message>, ) : DataRequest<ContentMessage<VideoContent>>,
SendMessageRequest<Message>, SendMessageRequest<ContentMessage<VideoContent>>,
ReplyingMarkupSendMessageRequest<Message>, ReplyingMarkupSendMessageRequest<ContentMessage<VideoContent>>,
TextableSendMessageRequest<Message>, TextableSendMessageRequest<ContentMessage<VideoContent>>,
ThumbedSendMessageRequest<Message>, ThumbedSendMessageRequest<ContentMessage<VideoContent>>,
DuratedSendMessageRequest<Message>, DuratedSendMessageRequest<ContentMessage<VideoContent>>,
SizedSendMessageRequest<Message> SizedSendMessageRequest<ContentMessage<VideoContent>>
{ {
init { init {
text ?.let { text ?.let {
@ -99,8 +103,8 @@ data class SendVideoData internal constructor(
} }
override fun method(): String = "sendVideo" override fun method(): String = "sendVideo"
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<VideoContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = commonResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -7,8 +7,9 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.VideoNoteContent
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 SendVideoNote(
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<Message> { ): Request<ContentMessage<VideoNoteContent>> {
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
@ -52,6 +53,9 @@ fun SendVideoNote(
} }
} }
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VideoNoteContent>>
= TelegramBotAPIMessageDeserializationStrategyClass()
@Serializable @Serializable
data class SendVideoNoteData internal constructor( data class SendVideoNoteData internal constructor(
@SerialName(chatIdField) @SerialName(chatIdField)
@ -74,13 +78,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<Message>, ) : DataRequest<ContentMessage<VideoNoteContent>>,
SendMessageRequest<Message>, SendMessageRequest<ContentMessage<VideoNoteContent>>,
ReplyingMarkupSendMessageRequest<Message>, ReplyingMarkupSendMessageRequest<ContentMessage<VideoNoteContent>>,
TextableSendMessageRequest<Message>, TextableSendMessageRequest<ContentMessage<VideoNoteContent>>,
ThumbedSendMessageRequest<Message>, ThumbedSendMessageRequest<ContentMessage<VideoNoteContent>>,
DuratedSendMessageRequest<Message>, DuratedSendMessageRequest<ContentMessage<VideoNoteContent>>,
SizedSendMessageRequest<Message> SizedSendMessageRequest<ContentMessage<VideoNoteContent>>
{ {
override val height: Int? override val height: Int?
get() = width get() = width
@ -94,8 +98,8 @@ data class SendVideoNoteData internal constructor(
} }
override fun method(): String = "sendVideoNote" override fun method(): String = "sendVideoNote"
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<VideoNoteContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = commonResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -7,8 +7,9 @@ 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.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.VoiceContent
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 SendVoice(
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<Message> { ): Request<ContentMessage<VoiceContent>> {
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
@ -50,6 +51,9 @@ fun SendVoice(
} }
} }
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VoiceContent>>
= TelegramBotAPIMessageDeserializationStrategyClass()
@Serializable @Serializable
data class SendVoiceData internal constructor( data class SendVoiceData internal constructor(
@SerialName(chatIdField) @SerialName(chatIdField)
@ -70,12 +74,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<Message>, ) : DataRequest<ContentMessage<VoiceContent>>,
SendMessageRequest<Message>, SendMessageRequest<ContentMessage<VoiceContent>>,
ReplyingMarkupSendMessageRequest<Message>, ReplyingMarkupSendMessageRequest<ContentMessage<VoiceContent>>,
TextableSendMessageRequest<Message>, TextableSendMessageRequest<ContentMessage<VoiceContent>>,
ThumbedSendMessageRequest<Message>, ThumbedSendMessageRequest<ContentMessage<VoiceContent>>,
DuratedSendMessageRequest<Message> DuratedSendMessageRequest<ContentMessage<VoiceContent>>
{ {
init { init {
text ?.let { text ?.let {
@ -86,8 +90,8 @@ data class SendVoiceData internal constructor(
} }
override fun method(): String = "sendVoice" override fun method(): String = "sendVoice"
override val resultDeserializer: DeserializationStrategy<Message> override val resultDeserializer: DeserializationStrategy<ContentMessage<VoiceContent>>
get() = TelegramBotAPIMessageDeserializationStrategy get() = commonResultDeserializer
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -9,11 +9,12 @@ interface ChatMember {
val user: User val user: User
} }
internal object ChatMemberSerializerWithoutDeserialization : KSerializer<ChatMember> { internal object AdministratorChatMemberSerializerWithoutDeserialization : KSerializer<AdministratorChatMember> {
override val descriptor: SerialDescriptor = StringDescriptor.withName("ChatMemberSerializerWithoutDeserialization") override val descriptor: SerialDescriptor = StringDescriptor.withName("ChatMemberSerializerWithoutDeserialization")
override fun deserialize(decoder: Decoder): ChatMember = ChatMemberDeserializationStrategy.deserialize(decoder) override fun deserialize(decoder: Decoder): AdministratorChatMember
override fun serialize(encoder: Encoder, obj: ChatMember) = throw UnsupportedOperationException() = ChatMemberDeserializationStrategy.deserialize(decoder) as AdministratorChatMember
override fun serialize(encoder: Encoder, obj: AdministratorChatMember) = throw UnsupportedOperationException()
} }
internal object ChatMemberDeserializationStrategy : DeserializationStrategy<ChatMember> { internal object ChatMemberDeserializationStrategy : DeserializationStrategy<ChatMember> {

View File

@ -13,24 +13,29 @@ interface Message {
val date: DateTime val date: DateTime
} }
internal object TelegramBotAPIMessageDeserializationStrategy : DeserializationStrategy<Message> { internal class TelegramBotAPIMessageDeserializationStrategyClass<T> : DeserializationStrategy<T> {
override val descriptor: SerialDescriptor = StringDescriptor.withName("TelegramBotAPIMessageSerializer") override val descriptor: SerialDescriptor = StringDescriptor.withName("TelegramBotAPIMessageSerializer")
override fun patch(decoder: Decoder, old: Message): Message = throw UpdateNotSupportedException(descriptor.name) override fun patch(decoder: Decoder, old: T): T = throw UpdateNotSupportedException(descriptor.name)
override fun deserialize(decoder: Decoder): Message { override fun deserialize(decoder: Decoder): T {
return RawMessage.serializer().deserialize(decoder).asMessage return RawMessage.serializer().deserialize(decoder).asMessage as T
} }
} }
internal object TelegramBotAPIMessageDeserializationStrategy
: DeserializationStrategy<Message> by TelegramBotAPIMessageDeserializationStrategyClass()
internal object TelegramBotAPIMessageDeserializeOnlySerializer : KSerializer<Message> { internal class TelegramBotAPIMessageDeserializeOnlySerializerClass<T : Message> : KSerializer<T> {
private val deserializer = TelegramBotAPIMessageDeserializationStrategyClass<T>()
override val descriptor: SerialDescriptor override val descriptor: SerialDescriptor
get() = TelegramBotAPIMessageDeserializationStrategy.descriptor get() = deserializer.descriptor
override fun deserialize(decoder: Decoder): Message { override fun deserialize(decoder: Decoder): T {
return TelegramBotAPIMessageDeserializationStrategy.deserialize(decoder) return deserializer.deserialize(decoder)
} }
override fun serialize(encoder: Encoder, obj: Message) { override fun serialize(encoder: Encoder, obj: T) {
throw UnsupportedOperationException("Currently, Message objects can't be serialized y this serializer") throw UnsupportedOperationException("Currently, Message objects can't be serialized y this serializer")
} }
} }
internal object TelegramBotAPIMessageDeserializeOnlySerializer
: KSerializer<Message> by TelegramBotAPIMessageDeserializeOnlySerializerClass()

View File

@ -4,6 +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.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message 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
@ -15,7 +16,7 @@ data class ContactContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<Message> = SendContact( ): Request<ContentMessage<ContactContent>> = SendContact(
chatId, contact, disableNotification, replyToMessageId, replyMarkup chatId, contact, disableNotification, replyToMessageId, replyMarkup
) )
} }

View File

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

View File

@ -4,6 +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.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message 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
@ -15,7 +16,7 @@ data class LocationContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<Message> = SendLocation( ): Request<ContentMessage<LocationContent>> = SendLocation(
chatId, chatId,
location.latitude, location.latitude,
location.longitude, location.longitude,

View File

@ -5,6 +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.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message 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 +18,7 @@ data class PollContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<Message> = SendPoll( ): Request<ContentMessage<PollContent>> = SendPoll(
chatId, chatId,
poll.question, poll.question,
poll.options.map { it.text }, poll.options.map { it.text },

View File

@ -3,10 +3,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextPart import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextPart
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendMessage import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendMessage
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendTextMessage
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.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.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message 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.* import com.github.insanusmokrassar.TelegramBotAPI.utils.*
@ -20,7 +22,7 @@ data class TextContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<Message> = SendMessage( ): Request<ContentMessage<TextContent>> = SendTextMessage(
chatId, chatId,
toHtmlTexts().first(), toHtmlTexts().first(),
HTMLParseMode, HTMLParseMode,
@ -35,7 +37,7 @@ data class TextContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): List<Request<Message>> = createResends( ): List<Request<ContentMessage<TextContent>>> = createResends(
chatId, chatId,
disableNotification, disableNotification,
replyToMessageId, replyToMessageId,
@ -49,12 +51,12 @@ data class TextContent(
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup?, replyMarkup: KeyboardMarkup?,
parseMode: ParseMode = HTMLParseMode parseMode: ParseMode = HTMLParseMode
): List<Request<Message>> = when (parseMode) { ): List<Request<ContentMessage<TextContent>>> = when (parseMode) {
is MarkdownParseMode -> toMarkdownTexts() is MarkdownParseMode -> toMarkdownTexts()
is MarkdownV2ParseMode -> toMarkdownV2Texts() is MarkdownV2ParseMode -> toMarkdownV2Texts()
is HTMLParseMode -> toHtmlTexts() is HTMLParseMode -> toHtmlTexts()
}.map { }.map {
SendMessage( SendTextMessage(
chatId, chatId,
it, it,
parseMode, parseMode,

View File

@ -4,6 +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.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message 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
@ -15,7 +16,7 @@ data class VenueContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<Message> = SendVenue( ): Request<ContentMessage<VenueContent>> = SendVenue(
chatId, venue, disableNotification, replyToMessageId, replyMarkup chatId, venue, disableNotification, replyToMessageId, replyMarkup
) )
} }

View File

@ -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<Message> ): Request<out 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<Message>> = listOf(createResend(chatId, disableNotification, replyToMessageId, replyMarkup)) ): List<Request<out Message>> = listOf(createResend(chatId, disableNotification, replyToMessageId, replyMarkup))
} }

View File

@ -10,6 +10,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.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.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message 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
@ -25,7 +26,7 @@ data class AnimationContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<Message> = SendAnimation( ): Request<ContentMessage<AnimationContent>> = SendAnimation(
chatId, chatId,
media.fileId, media.fileId,
media.thumb ?.fileId, media.thumb ?.fileId,

View File

@ -9,6 +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.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message 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 +24,7 @@ data class AudioContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<Message> = SendAudio( ): Request<ContentMessage<AudioContent>> = SendAudio(
chatId, chatId,
media.fileId, media.fileId,
media.thumb ?.fileId, media.thumb ?.fileId,

View File

@ -9,6 +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.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message 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 +24,7 @@ data class DocumentContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<Message> = SendDocument( ): Request<ContentMessage<DocumentContent>> = SendDocument(
chatId, chatId,
media.fileId, media.fileId,
media.thumb ?.fileId, media.thumb ?.fileId,

View File

@ -11,6 +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.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message 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
@ -28,7 +29,7 @@ data class PhotoContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<Message> = SendPhoto( ): Request<ContentMessage<PhotoContent>> = SendPhoto(
chatId, chatId,
media.fileId, media.fileId,
toHtmlCaptions().firstOrNull(), toHtmlCaptions().firstOrNull(),

View File

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

View File

@ -10,6 +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.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message 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 +25,7 @@ data class VideoContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<Message> = SendVideo( ): Request<ContentMessage<VideoContent>> = SendVideo(
chatId, chatId,
media.fileId, media.fileId,
media.thumb ?.fileId, media.thumb ?.fileId,

View File

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

View File

@ -9,6 +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.abstracts.ContentMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message 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 +24,7 @@ data class VoiceContent(
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<Message> = SendVoice( ): Request<ContentMessage<VoiceContent>> = SendVoice(
chatId, chatId,
media.fileId, media.fileId,
null, null,