mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-23 00:57:13 +00:00
now most part of request have changed return types
This commit is contained in:
parent
4c60b8fd82
commit
3fa2071847
@ -3,10 +3,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.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 kotlinx.serialization.*
|
||||
|
||||
private val AbleToBeForwardedMessageDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<AbleToBeForwardedMessage>()
|
||||
|
||||
@Serializable
|
||||
data class ForwardMessage(
|
||||
@SerialName(fromChatIdField)
|
||||
@ -17,15 +20,14 @@ data class ForwardMessage(
|
||||
override val messageId: MessageIdentifier,
|
||||
@SerialName(disableNotificationField)
|
||||
val disableNotification: Boolean = false
|
||||
): SimpleRequest<Message>, MessageAction {
|
||||
@Transient
|
||||
): SimpleRequest<AbleToBeForwardedMessage>, MessageAction {
|
||||
override val chatId: ChatIdentifier
|
||||
get() = fromChatId
|
||||
|
||||
override fun method(): String = "forwardMessage"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<AbleToBeForwardedMessage>
|
||||
get() = AbleToBeForwardedMessageDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -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.requests.abstracts.SimpleRequest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMember
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.ChatMemberSerializerWithoutDeserialization
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chatIdField
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.ArrayListSerializer
|
||||
|
||||
private val chatMembersListSerializer = ArrayListSerializer(
|
||||
ChatMemberSerializerWithoutDeserialization
|
||||
AdministratorChatMemberSerializerWithoutDeserialization
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class GetChatAdministrators(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier
|
||||
): ChatRequest, SimpleRequest<List<ChatMember>> {
|
||||
): ChatRequest, SimpleRequest<List<AdministratorChatMember>> {
|
||||
override fun method(): String = "getChatAdministrators"
|
||||
override val resultDeserializer: DeserializationStrategy<List<ChatMember>>
|
||||
override val resultDeserializer: DeserializationStrategy<List<AdministratorChatMember>>
|
||||
get() = chatMembersListSerializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
@ -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.types.*
|
||||
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.LocationContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
||||
import kotlinx.serialization.*
|
||||
|
||||
private val commonResultDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<ContentMessage<LocationContent>>()
|
||||
|
||||
@Serializable
|
||||
data class EditChatMessageLiveLocation(
|
||||
@SerialName(chatIdField)
|
||||
@ -19,10 +24,10 @@ data class EditChatMessageLiveLocation(
|
||||
override val longitude: Double,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : EditChatMessage, EditReplyMessage, EditLocationMessage {
|
||||
) : EditChatMessage<LocationContent>, EditReplyMessage, EditLocationMessage {
|
||||
override fun method(): String = "editMessageLiveLocation"
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
|
||||
get() = commonResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -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.types.*
|
||||
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.LocationContent
|
||||
import kotlinx.serialization.*
|
||||
|
||||
private val commonResultDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<ContentMessage<LocationContent>>()
|
||||
|
||||
@Serializable
|
||||
data class StopChatMessageLiveLocation(
|
||||
@SerialName(chatIdField)
|
||||
@ -16,10 +20,10 @@ data class StopChatMessageLiveLocation(
|
||||
override val messageId: MessageIdentifier,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : EditChatMessage, EditReplyMessage {
|
||||
) : EditChatMessage<LocationContent>, EditReplyMessage {
|
||||
override fun method(): String = "stopMessageLiveLocation"
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
|
||||
get() = commonResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -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.types.*
|
||||
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.content.abstracts.MediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||
import kotlinx.serialization.*
|
||||
|
||||
const val editMessageReplyMarkupMethod = "editMessageReplyMarkup"
|
||||
|
||||
private val commonResultDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<ContentMessage<MessageContent>>()
|
||||
|
||||
@Serializable
|
||||
data class EditChatMessageReplyMarkup(
|
||||
@SerialName(chatIdField)
|
||||
@ -18,11 +22,11 @@ data class EditChatMessageReplyMarkup(
|
||||
override val messageId: MessageIdentifier,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : EditChatMessage, EditReplyMessage {
|
||||
) : EditChatMessage<MessageContent>, EditReplyMessage {
|
||||
|
||||
override fun method(): String = editMessageReplyMarkupMethod
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<MessageContent>>
|
||||
get() = commonResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -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.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
|
||||
|
@ -1,12 +1,15 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption
|
||||
|
||||
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.ParseMode.ParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.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 com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||
import kotlinx.serialization.*
|
||||
|
||||
const val editMessageCaptionMethod = "editMessageCaption"
|
||||
@ -23,11 +26,11 @@ data class EditChatMessageCaption(
|
||||
override val parseMode: ParseMode? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : EditChatMessage, EditTextChatMessage, EditReplyMessage {
|
||||
) : EditChatMessage<MediaContent>, EditTextChatMessage, EditReplyMessage {
|
||||
|
||||
override fun method(): String = editMessageCaptionMethod
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<MediaContent>>
|
||||
get() = MediaContentMessageResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -5,12 +5,15 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||
import kotlinx.serialization.*
|
||||
|
||||
const val editMessageMediaMethod = "editMessageMedia"
|
||||
|
||||
internal val MediaContentMessageResultDeserializer = TelegramBotAPIMessageDeserializationStrategyClass<ContentMessage<MediaContent>>()
|
||||
|
||||
@Serializable
|
||||
data class EditChatMessageMedia(
|
||||
@SerialName(chatIdField)
|
||||
@ -21,7 +24,7 @@ data class EditChatMessageMedia(
|
||||
override val media: InputMedia,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : EditChatMessage, EditReplyMessage, EditMediaMessage {
|
||||
) : EditChatMessage<MediaContent>, EditReplyMessage, EditMediaMessage {
|
||||
|
||||
init {
|
||||
if (media.file is MultipartFile) {
|
||||
@ -30,8 +33,8 @@ data class EditChatMessageMedia(
|
||||
}
|
||||
|
||||
override fun method(): String = editMessageMediaMethod
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<MediaContent>>
|
||||
get() = MediaContentMessageResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -1,12 +1,14 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text
|
||||
|
||||
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.ParseMode.ParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.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.*
|
||||
|
||||
const val editMessageTextMethod = "editMessageText"
|
||||
@ -25,11 +27,11 @@ data class EditChatMessageText(
|
||||
override val disableWebPagePreview: Boolean? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : EditChatMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
||||
) : EditChatMessage<TextContent>, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
||||
|
||||
override fun method(): String = editMessageTextMethod
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<TextContent>>
|
||||
get() = TextContentMessageResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -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.types.*
|
||||
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.ContactContent
|
||||
import kotlinx.serialization.*
|
||||
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<ContactContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@Serializable
|
||||
data class SendContact(
|
||||
@SerialName(chatIdField)
|
||||
@ -24,8 +28,8 @@ data class SendContact(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>
|
||||
) : SendMessageRequest<ContentMessage<ContactContent>>,
|
||||
ReplyingMarkupSendMessageRequest<ContentMessage<ContactContent>>
|
||||
{
|
||||
constructor(
|
||||
chatId: ChatIdentifier,
|
||||
@ -44,8 +48,8 @@ data class SendContact(
|
||||
)
|
||||
|
||||
override fun method(): String = "sendContact"
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<ContactContent>>
|
||||
get() = commonResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -3,10 +3,15 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.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.LocationContent
|
||||
import kotlinx.serialization.*
|
||||
|
||||
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
// TODO:: Add location tracker for tracking location
|
||||
@Serializable
|
||||
data class SendLocation(
|
||||
@ -24,14 +29,14 @@ data class SendLocation(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>,
|
||||
PositionedSendMessageRequest<Message>
|
||||
) : SendMessageRequest<ContentMessage<LocationContent>>,
|
||||
ReplyingMarkupSendMessageRequest<ContentMessage<LocationContent>>,
|
||||
PositionedSendMessageRequest<ContentMessage<LocationContent>>
|
||||
{
|
||||
|
||||
override fun method(): String = "sendLocation"
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<LocationContent>>
|
||||
get() = commonResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -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.parseModeField
|
||||
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.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
||||
import kotlinx.serialization.*
|
||||
|
||||
internal val TextContentMessageResultDeserializer: DeserializationStrategy<ContentMessage<TextContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@Serializable
|
||||
data class SendMessage(
|
||||
data class SendTextMessage(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@SerialName(textField)
|
||||
@ -26,9 +29,9 @@ data class SendMessage(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>,
|
||||
TextableSendMessageRequest<Message>,
|
||||
) : SendMessageRequest<ContentMessage<TextContent>>,
|
||||
ReplyingMarkupSendMessageRequest<ContentMessage<TextContent>>,
|
||||
TextableSendMessageRequest<ContentMessage<TextContent>>,
|
||||
DisableWebPagePreview
|
||||
{
|
||||
init {
|
||||
@ -38,8 +41,16 @@ data class SendMessage(
|
||||
}
|
||||
|
||||
override fun method(): String = "sendMessage"
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<TextContent>>
|
||||
get() = TextContentMessageResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
"This declaration is deprecated due violation of common naming rules",
|
||||
ReplaceWith(
|
||||
"SendTextMessage"
|
||||
)
|
||||
)
|
||||
typealias SendMessage = SendTextMessage
|
||||
|
@ -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.types.*
|
||||
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.PollContent
|
||||
import kotlinx.serialization.*
|
||||
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PollContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@Serializable
|
||||
data class SendPoll(
|
||||
@SerialName(chatIdField)
|
||||
@ -22,8 +26,8 @@ data class SendPoll(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message> {
|
||||
) : SendMessageRequest<ContentMessage<PollContent>>,
|
||||
ReplyingMarkupSendMessageRequest<ContentMessage<PollContent>> {
|
||||
|
||||
init {
|
||||
if (question.length !in pollQuestionTextLength) {
|
||||
@ -40,8 +44,8 @@ data class SendPoll(
|
||||
}
|
||||
|
||||
override fun method(): String = "sendPoll"
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<PollContent>>
|
||||
get() = commonResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
@ -3,10 +3,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.VenueContent
|
||||
import kotlinx.serialization.*
|
||||
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VenueContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@Serializable
|
||||
data class SendVenue(
|
||||
@SerialName(chatIdField)
|
||||
@ -27,10 +30,10 @@ data class SendVenue(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : SendMessageRequest<Message>,
|
||||
PositionedSendMessageRequest<Message>,
|
||||
TitledSendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>
|
||||
) : SendMessageRequest<ContentMessage<VenueContent>>,
|
||||
PositionedSendMessageRequest<ContentMessage<VenueContent>>,
|
||||
TitledSendMessageRequest<ContentMessage<VenueContent>>,
|
||||
ReplyingMarkupSendMessageRequest<ContentMessage<VenueContent>>
|
||||
{
|
||||
constructor(
|
||||
chatId: ChatIdentifier,
|
||||
@ -51,8 +54,8 @@ data class SendVenue(
|
||||
)
|
||||
|
||||
override fun method(): String = "sendVenue"
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<VenueContent>>
|
||||
get() = commonResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -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.types.*
|
||||
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.GameContent
|
||||
import kotlinx.serialization.*
|
||||
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<GameContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@Serializable
|
||||
data class SendGame (
|
||||
@SerialName(chatIdField)
|
||||
@ -20,11 +24,11 @@ data class SendGame (
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : SendMessageRequest<Message>,
|
||||
) : SendMessageRequest<ContentMessage<GameContent>>,
|
||||
ReplyMarkup {
|
||||
override fun method(): String = "sendGame"
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<GameContent>>
|
||||
get() = commonResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
@ -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.parseModeField
|
||||
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.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
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 kotlinx.serialization.*
|
||||
|
||||
@ -24,7 +25,7 @@ fun SendAnimation(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<Message> {
|
||||
): Request<ContentMessage<AnimationContent>> {
|
||||
val animationAsFileId = (animation as? FileId) ?.fileId
|
||||
val animationAsFile = animation as? MultipartFile
|
||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
||||
@ -54,6 +55,9 @@ fun SendAnimation(
|
||||
}
|
||||
}
|
||||
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<AnimationContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@Serializable
|
||||
data class SendAnimationData internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
@ -78,13 +82,13 @@ data class SendAnimationData internal constructor(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : DataRequest<Message>,
|
||||
SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>,
|
||||
TextableSendMessageRequest<Message>,
|
||||
ThumbedSendMessageRequest<Message>,
|
||||
DuratedSendMessageRequest<Message>,
|
||||
SizedSendMessageRequest<Message>
|
||||
) : DataRequest<ContentMessage<AnimationContent>>,
|
||||
SendMessageRequest<ContentMessage<AnimationContent>>,
|
||||
ReplyingMarkupSendMessageRequest<ContentMessage<AnimationContent>>,
|
||||
TextableSendMessageRequest<ContentMessage<AnimationContent>>,
|
||||
ThumbedSendMessageRequest<ContentMessage<AnimationContent>>,
|
||||
DuratedSendMessageRequest<ContentMessage<AnimationContent>>,
|
||||
SizedSendMessageRequest<ContentMessage<AnimationContent>>
|
||||
{
|
||||
init {
|
||||
text ?.let {
|
||||
@ -95,8 +99,8 @@ data class SendAnimationData internal constructor(
|
||||
}
|
||||
|
||||
override fun method(): String = "sendAnimation"
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<AnimationContent>>
|
||||
get() = commonResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -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.parseModeField
|
||||
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.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
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 kotlinx.serialization.*
|
||||
|
||||
@ -25,7 +26,7 @@ fun SendAudio(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<Message> {
|
||||
): Request<ContentMessage<AudioContent>> {
|
||||
val audioAsFileId = (audio as? FileId) ?.fileId
|
||||
val audioAsFile = audio as? MultipartFile
|
||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
||||
@ -55,6 +56,9 @@ fun SendAudio(
|
||||
}
|
||||
}
|
||||
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<AudioContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@Serializable
|
||||
data class SendAudioData internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
@ -79,13 +83,13 @@ data class SendAudioData internal constructor(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : DataRequest<Message>,
|
||||
SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>,
|
||||
TextableSendMessageRequest<Message>,
|
||||
ThumbedSendMessageRequest<Message>,
|
||||
TitledSendMessageRequest<Message>,
|
||||
DuratedSendMessageRequest<Message>,
|
||||
) : DataRequest<ContentMessage<AudioContent>>,
|
||||
SendMessageRequest<ContentMessage<AudioContent>>,
|
||||
ReplyingMarkupSendMessageRequest<ContentMessage<AudioContent>>,
|
||||
TextableSendMessageRequest<ContentMessage<AudioContent>>,
|
||||
ThumbedSendMessageRequest<ContentMessage<AudioContent>>,
|
||||
TitledSendMessageRequest<ContentMessage<AudioContent>>,
|
||||
DuratedSendMessageRequest<ContentMessage<AudioContent>>,
|
||||
Performerable
|
||||
{
|
||||
init {
|
||||
@ -97,8 +101,8 @@ data class SendAudioData internal constructor(
|
||||
}
|
||||
|
||||
override fun method(): String = "sendAudio"
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<AudioContent>>
|
||||
get() = commonResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -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.parseModeField
|
||||
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.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
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 kotlinx.serialization.*
|
||||
|
||||
@ -21,7 +22,7 @@ fun SendDocument(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<Message> {
|
||||
): Request<ContentMessage<DocumentContent>> {
|
||||
val documentAsFileId = (document as? FileId) ?.fileId
|
||||
val documentAsFile = document as? MultipartFile
|
||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
||||
@ -48,6 +49,9 @@ fun SendDocument(
|
||||
}
|
||||
}
|
||||
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<DocumentContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@Serializable
|
||||
data class SendDocumentData internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
@ -66,11 +70,11 @@ data class SendDocumentData internal constructor(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : DataRequest<Message>,
|
||||
SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>,
|
||||
TextableSendMessageRequest<Message>,
|
||||
ThumbedSendMessageRequest<Message>
|
||||
) : DataRequest<ContentMessage<DocumentContent>>,
|
||||
SendMessageRequest<ContentMessage<DocumentContent>>,
|
||||
ReplyingMarkupSendMessageRequest<ContentMessage<DocumentContent>>,
|
||||
TextableSendMessageRequest<ContentMessage<DocumentContent>>,
|
||||
ThumbedSendMessageRequest<ContentMessage<DocumentContent>>
|
||||
{
|
||||
init {
|
||||
text ?.let {
|
||||
@ -81,8 +85,8 @@ data class SendDocumentData internal constructor(
|
||||
}
|
||||
|
||||
override fun method(): String = "sendDocument"
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<DocumentContent>>
|
||||
get() = commonResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -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.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.ArrayListSerializer
|
||||
@ -20,7 +20,7 @@ fun SendMediaGroup(
|
||||
media: List<MediaGroupMemberInputMedia>,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null
|
||||
): Request<List<Message>> {
|
||||
): Request<List<MediaGroupMessage>> {
|
||||
if (media.size !in membersCountInMediaGroup) {
|
||||
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
|
||||
data class SendMediaGroupData internal constructor(
|
||||
@ -64,7 +65,7 @@ data class SendMediaGroupData internal constructor(
|
||||
override val disableNotification: Boolean = false,
|
||||
@SerialName(replyToMessageIdField)
|
||||
override val replyToMessageId: MessageIdentifier? = null
|
||||
) : DataRequest<List<Message>>, SendMessageRequest<List<Message>> {
|
||||
) : DataRequest<List<MediaGroupMessage>>, SendMessageRequest<List<MediaGroupMessage>> {
|
||||
@SerialName(mediaField)
|
||||
private val convertedMedia: String
|
||||
get() = jsonArray {
|
||||
@ -77,7 +78,7 @@ data class SendMediaGroupData internal constructor(
|
||||
override fun method(): String = "sendMediaGroup"
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
override val resultDeserializer: DeserializationStrategy<List<Message>>
|
||||
override val resultDeserializer: DeserializationStrategy<List<MediaGroupMessage>>
|
||||
get() = messagesListSerializer
|
||||
}
|
||||
|
||||
|
@ -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.parseModeField
|
||||
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.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media.PhotoContent
|
||||
import kotlinx.serialization.*
|
||||
|
||||
fun SendPhoto(
|
||||
@ -19,7 +20,7 @@ fun SendPhoto(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<Message> {
|
||||
): Request<ContentMessage<PhotoContent>> {
|
||||
val data = SendPhotoData(
|
||||
chatId,
|
||||
(photo as? FileId) ?.fileId,
|
||||
@ -37,6 +38,9 @@ fun SendPhoto(
|
||||
)
|
||||
}
|
||||
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PhotoContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@Serializable
|
||||
data class SendPhotoData internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
@ -53,10 +57,10 @@ data class SendPhotoData internal constructor(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : DataRequest<Message>,
|
||||
SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>,
|
||||
TextableSendMessageRequest<Message>
|
||||
) : DataRequest<ContentMessage<PhotoContent>>,
|
||||
SendMessageRequest<ContentMessage<PhotoContent>>,
|
||||
ReplyingMarkupSendMessageRequest<ContentMessage<PhotoContent>>,
|
||||
TextableSendMessageRequest<ContentMessage<PhotoContent>>
|
||||
{
|
||||
init {
|
||||
text ?.let {
|
||||
@ -67,8 +71,8 @@ data class SendPhotoData internal constructor(
|
||||
}
|
||||
|
||||
override fun method(): String = "sendPhoto"
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<PhotoContent>>
|
||||
get() = commonResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -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.types.*
|
||||
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.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
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 kotlinx.serialization.*
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
@ -17,7 +18,7 @@ fun SendSticker(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<Message> = SendStickerByFileId(
|
||||
): Request<ContentMessage<StickerContent>> = SendStickerByFileId(
|
||||
chatId,
|
||||
sticker as? FileId,
|
||||
disableNotification,
|
||||
@ -30,6 +31,9 @@ fun SendSticker(
|
||||
}
|
||||
}
|
||||
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<StickerContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@Serializable
|
||||
data class SendStickerByFileId internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
@ -42,10 +46,10 @@ data class SendStickerByFileId internal constructor(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : SendMessageRequest<Message>, ReplyingMarkupSendMessageRequest<Message> {
|
||||
) : SendMessageRequest<ContentMessage<StickerContent>>, ReplyingMarkupSendMessageRequest<ContentMessage<StickerContent>> {
|
||||
override fun method(): String = "sendSticker"
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<StickerContent>>
|
||||
get() = commonResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@ -54,7 +58,7 @@ data class SendStickerByFile internal constructor(
|
||||
@Transient
|
||||
private val sendStickerByFileId: SendStickerByFileId,
|
||||
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 paramsJson: JsonObject = sendStickerByFileId.toJsonWithoutNulls(SendStickerByFileId.serializer())
|
||||
}
|
||||
|
@ -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.parseModeField
|
||||
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.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
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 kotlinx.serialization.*
|
||||
|
||||
@ -25,7 +26,7 @@ fun SendVideo(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<Message> {
|
||||
): Request<ContentMessage<VideoContent>> {
|
||||
val videoAsFileId = (video as? FileId) ?.fileId
|
||||
val videoAsFile = video as? MultipartFile
|
||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
||||
@ -56,6 +57,9 @@ fun SendVideo(
|
||||
}
|
||||
}
|
||||
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VideoContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@Serializable
|
||||
data class SendVideoData internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
@ -82,13 +86,13 @@ data class SendVideoData internal constructor(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : DataRequest<Message>,
|
||||
SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>,
|
||||
TextableSendMessageRequest<Message>,
|
||||
ThumbedSendMessageRequest<Message>,
|
||||
DuratedSendMessageRequest<Message>,
|
||||
SizedSendMessageRequest<Message>
|
||||
) : DataRequest<ContentMessage<VideoContent>>,
|
||||
SendMessageRequest<ContentMessage<VideoContent>>,
|
||||
ReplyingMarkupSendMessageRequest<ContentMessage<VideoContent>>,
|
||||
TextableSendMessageRequest<ContentMessage<VideoContent>>,
|
||||
ThumbedSendMessageRequest<ContentMessage<VideoContent>>,
|
||||
DuratedSendMessageRequest<ContentMessage<VideoContent>>,
|
||||
SizedSendMessageRequest<ContentMessage<VideoContent>>
|
||||
{
|
||||
init {
|
||||
text ?.let {
|
||||
@ -99,8 +103,8 @@ data class SendVideoData internal constructor(
|
||||
}
|
||||
|
||||
override fun method(): String = "sendVideo"
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<VideoContent>>
|
||||
get() = commonResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -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.parseModeField
|
||||
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.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
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 kotlinx.serialization.*
|
||||
|
||||
@ -23,7 +24,7 @@ fun SendVideoNote(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<Message> {
|
||||
): Request<ContentMessage<VideoNoteContent>> {
|
||||
val videoNoteAsFileId = (videoNote as? FileId) ?.fileId
|
||||
val videoNoteAsFile = videoNote as? MultipartFile
|
||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
||||
@ -52,6 +53,9 @@ fun SendVideoNote(
|
||||
}
|
||||
}
|
||||
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VideoNoteContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@Serializable
|
||||
data class SendVideoNoteData internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
@ -74,13 +78,13 @@ data class SendVideoNoteData internal constructor(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : DataRequest<Message>,
|
||||
SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>,
|
||||
TextableSendMessageRequest<Message>,
|
||||
ThumbedSendMessageRequest<Message>,
|
||||
DuratedSendMessageRequest<Message>,
|
||||
SizedSendMessageRequest<Message>
|
||||
) : DataRequest<ContentMessage<VideoNoteContent>>,
|
||||
SendMessageRequest<ContentMessage<VideoNoteContent>>,
|
||||
ReplyingMarkupSendMessageRequest<ContentMessage<VideoNoteContent>>,
|
||||
TextableSendMessageRequest<ContentMessage<VideoNoteContent>>,
|
||||
ThumbedSendMessageRequest<ContentMessage<VideoNoteContent>>,
|
||||
DuratedSendMessageRequest<ContentMessage<VideoNoteContent>>,
|
||||
SizedSendMessageRequest<ContentMessage<VideoNoteContent>>
|
||||
{
|
||||
override val height: Int?
|
||||
get() = width
|
||||
@ -94,8 +98,8 @@ data class SendVideoNoteData internal constructor(
|
||||
}
|
||||
|
||||
override fun method(): String = "sendVideoNote"
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<VideoNoteContent>>
|
||||
get() = commonResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -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.parseModeField
|
||||
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.TelegramBotAPIMessageDeserializationStrategy
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
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 kotlinx.serialization.*
|
||||
|
||||
@ -22,7 +23,7 @@ fun SendVoice(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<Message> {
|
||||
): Request<ContentMessage<VoiceContent>> {
|
||||
val voiceAsFileId = (voice as? FileId) ?.fileId
|
||||
val voiceAsFile = voice as? MultipartFile
|
||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
||||
@ -50,6 +51,9 @@ fun SendVoice(
|
||||
}
|
||||
}
|
||||
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VoiceContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@Serializable
|
||||
data class SendVoiceData internal constructor(
|
||||
@SerialName(chatIdField)
|
||||
@ -70,12 +74,12 @@ data class SendVoiceData internal constructor(
|
||||
override val replyToMessageId: MessageIdentifier? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : DataRequest<Message>,
|
||||
SendMessageRequest<Message>,
|
||||
ReplyingMarkupSendMessageRequest<Message>,
|
||||
TextableSendMessageRequest<Message>,
|
||||
ThumbedSendMessageRequest<Message>,
|
||||
DuratedSendMessageRequest<Message>
|
||||
) : DataRequest<ContentMessage<VoiceContent>>,
|
||||
SendMessageRequest<ContentMessage<VoiceContent>>,
|
||||
ReplyingMarkupSendMessageRequest<ContentMessage<VoiceContent>>,
|
||||
TextableSendMessageRequest<ContentMessage<VoiceContent>>,
|
||||
ThumbedSendMessageRequest<ContentMessage<VoiceContent>>,
|
||||
DuratedSendMessageRequest<ContentMessage<VoiceContent>>
|
||||
{
|
||||
init {
|
||||
text ?.let {
|
||||
@ -86,8 +90,8 @@ data class SendVoiceData internal constructor(
|
||||
}
|
||||
|
||||
override fun method(): String = "sendVoice"
|
||||
override val resultDeserializer: DeserializationStrategy<Message>
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<VoiceContent>>
|
||||
get() = commonResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
@ -9,11 +9,12 @@ interface ChatMember {
|
||||
val user: User
|
||||
}
|
||||
|
||||
internal object ChatMemberSerializerWithoutDeserialization : KSerializer<ChatMember> {
|
||||
internal object AdministratorChatMemberSerializerWithoutDeserialization : KSerializer<AdministratorChatMember> {
|
||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("ChatMemberSerializerWithoutDeserialization")
|
||||
|
||||
override fun deserialize(decoder: Decoder): ChatMember = ChatMemberDeserializationStrategy.deserialize(decoder)
|
||||
override fun serialize(encoder: Encoder, obj: ChatMember) = throw UnsupportedOperationException()
|
||||
override fun deserialize(decoder: Decoder): AdministratorChatMember
|
||||
= ChatMemberDeserializationStrategy.deserialize(decoder) as AdministratorChatMember
|
||||
override fun serialize(encoder: Encoder, obj: AdministratorChatMember) = throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
internal object ChatMemberDeserializationStrategy : DeserializationStrategy<ChatMember> {
|
||||
|
@ -13,24 +13,29 @@ interface Message {
|
||||
val date: DateTime
|
||||
}
|
||||
|
||||
internal object TelegramBotAPIMessageDeserializationStrategy : DeserializationStrategy<Message> {
|
||||
internal class TelegramBotAPIMessageDeserializationStrategyClass<T> : DeserializationStrategy<T> {
|
||||
override val descriptor: SerialDescriptor = StringDescriptor.withName("TelegramBotAPIMessageSerializer")
|
||||
|
||||
override fun patch(decoder: Decoder, old: Message): Message = throw UpdateNotSupportedException(descriptor.name)
|
||||
override fun deserialize(decoder: Decoder): Message {
|
||||
return RawMessage.serializer().deserialize(decoder).asMessage
|
||||
override fun patch(decoder: Decoder, old: T): T = throw UpdateNotSupportedException(descriptor.name)
|
||||
override fun deserialize(decoder: Decoder): T {
|
||||
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
|
||||
get() = TelegramBotAPIMessageDeserializationStrategy.descriptor
|
||||
get() = deserializer.descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): Message {
|
||||
return TelegramBotAPIMessageDeserializationStrategy.deserialize(decoder)
|
||||
override fun deserialize(decoder: Decoder): T {
|
||||
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")
|
||||
}
|
||||
}
|
||||
internal object TelegramBotAPIMessageDeserializeOnlySerializer
|
||||
: KSerializer<Message> by TelegramBotAPIMessageDeserializeOnlySerializerClass()
|
||||
|
@ -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.types.*
|
||||
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.content.abstracts.MessageContent
|
||||
|
||||
@ -15,7 +16,7 @@ data class ContactContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<Message> = SendContact(
|
||||
): Request<ContentMessage<ContactContent>> = SendContact(
|
||||
chatId, contact, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
}
|
@ -6,6 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.games.Game
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||
|
||||
@ -17,7 +18,7 @@ data class GameContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<Message> = SendGame(
|
||||
): Request<ContentMessage<GameContent>> = SendGame(
|
||||
chatId,
|
||||
game.title,
|
||||
disableNotification,
|
||||
|
@ -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.types.*
|
||||
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.content.abstracts.MessageContent
|
||||
|
||||
@ -15,7 +16,7 @@ data class LocationContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<Message> = SendLocation(
|
||||
): Request<ContentMessage<LocationContent>> = SendLocation(
|
||||
chatId,
|
||||
location.latitude,
|
||||
location.longitude,
|
||||
|
@ -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.MessageIdentifier
|
||||
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.content.abstracts.MessageContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
||||
@ -17,7 +18,7 @@ data class PollContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<Message> = SendPoll(
|
||||
): Request<ContentMessage<PollContent>> = SendPoll(
|
||||
chatId,
|
||||
poll.question,
|
||||
poll.options.map { it.text },
|
||||
|
@ -3,10 +3,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextPart
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||
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.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.*
|
||||
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.content.abstracts.MessageContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
|
||||
@ -20,7 +22,7 @@ data class TextContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<Message> = SendMessage(
|
||||
): Request<ContentMessage<TextContent>> = SendTextMessage(
|
||||
chatId,
|
||||
toHtmlTexts().first(),
|
||||
HTMLParseMode,
|
||||
@ -35,7 +37,7 @@ data class TextContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): List<Request<Message>> = createResends(
|
||||
): List<Request<ContentMessage<TextContent>>> = createResends(
|
||||
chatId,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
@ -49,12 +51,12 @@ data class TextContent(
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?,
|
||||
parseMode: ParseMode = HTMLParseMode
|
||||
): List<Request<Message>> = when (parseMode) {
|
||||
): List<Request<ContentMessage<TextContent>>> = when (parseMode) {
|
||||
is MarkdownParseMode -> toMarkdownTexts()
|
||||
is MarkdownV2ParseMode -> toMarkdownV2Texts()
|
||||
is HTMLParseMode -> toHtmlTexts()
|
||||
}.map {
|
||||
SendMessage(
|
||||
SendTextMessage(
|
||||
chatId,
|
||||
it,
|
||||
parseMode,
|
||||
|
@ -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.types.*
|
||||
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.content.abstracts.MessageContent
|
||||
|
||||
@ -15,7 +16,7 @@ data class VenueContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<Message> = SendVenue(
|
||||
): Request<ContentMessage<VenueContent>> = SendVenue(
|
||||
chatId, venue, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
}
|
@ -12,12 +12,12 @@ interface ResendableContent {
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<Message>
|
||||
): Request<out Message>
|
||||
|
||||
fun createResends(
|
||||
chatId: ChatIdentifier,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): List<Request<Message>> = listOf(createResend(chatId, disableNotification, replyToMessageId, replyMarkup))
|
||||
): List<Request<out Message>> = listOf(createResend(chatId, disableNotification, replyToMessageId, replyMarkup))
|
||||
}
|
@ -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.files.AnimationFile
|
||||
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.content.abstracts.MediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||
@ -25,7 +26,7 @@ data class AnimationContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<Message> = SendAnimation(
|
||||
): Request<ContentMessage<AnimationContent>> = SendAnimation(
|
||||
chatId,
|
||||
media.fileId,
|
||||
media.thumb ?.fileId,
|
||||
|
@ -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.buttons.KeyboardMarkup
|
||||
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.content.abstracts.MediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||
@ -23,7 +24,7 @@ data class AudioContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<Message> = SendAudio(
|
||||
): Request<ContentMessage<AudioContent>> = SendAudio(
|
||||
chatId,
|
||||
media.fileId,
|
||||
media.thumb ?.fileId,
|
||||
|
@ -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.buttons.KeyboardMarkup
|
||||
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.content.abstracts.MediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||
@ -23,7 +24,7 @@ data class DocumentContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<Message> = SendDocument(
|
||||
): Request<ContentMessage<DocumentContent>> = SendDocument(
|
||||
chatId,
|
||||
media.fileId,
|
||||
media.thumb ?.fileId,
|
||||
|
@ -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.files.PhotoSize
|
||||
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.content.abstracts.MediaCollectionContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaGroupContent
|
||||
@ -28,7 +29,7 @@ data class PhotoContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<Message> = SendPhoto(
|
||||
): Request<ContentMessage<PhotoContent>> = SendPhoto(
|
||||
chatId,
|
||||
media.fileId,
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
|
@ -6,6 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.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.content.abstracts.MediaContent
|
||||
|
||||
@ -17,7 +18,7 @@ data class StickerContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<Message> = SendSticker(
|
||||
): Request<ContentMessage<StickerContent>> = SendSticker(
|
||||
chatId,
|
||||
media.fileId,
|
||||
disableNotification,
|
||||
|
@ -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.buttons.KeyboardMarkup
|
||||
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.content.abstracts.MediaGroupContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||
@ -24,7 +25,7 @@ data class VideoContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<Message> = SendVideo(
|
||||
): Request<ContentMessage<VideoContent>> = SendVideo(
|
||||
chatId,
|
||||
media.fileId,
|
||||
media.thumb ?.fileId,
|
||||
|
@ -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.buttons.KeyboardMarkup
|
||||
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.content.abstracts.MediaContent
|
||||
|
||||
@ -18,7 +19,7 @@ data class VideoNoteContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<Message> = createResend(chatId, null, null, disableNotification, replyToMessageId, replyMarkup)
|
||||
): Request<ContentMessage<VideoNoteContent>> = createResend(chatId, null, null, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
@ -27,7 +28,7 @@ data class VideoNoteContent(
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): Request<Message> = SendVideoNote(
|
||||
): Request<ContentMessage<VideoNoteContent>> = SendVideoNote(
|
||||
chatId,
|
||||
media.fileId,
|
||||
media.thumb ?.fileId,
|
||||
|
@ -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.buttons.KeyboardMarkup
|
||||
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.content.abstracts.MediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||
@ -23,7 +24,7 @@ data class VoiceContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<Message> = SendVoice(
|
||||
): Request<ContentMessage<VoiceContent>> = SendVoice(
|
||||
chatId,
|
||||
media.fileId,
|
||||
null,
|
||||
|
Loading…
Reference in New Issue
Block a user