mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
commit
c909774403
19
CHANGELOG.md
19
CHANGELOG.md
@ -49,6 +49,25 @@
|
|||||||
* `closePollExactAfter`
|
* `closePollExactAfter`
|
||||||
* `closePollAfter`
|
* `closePollAfter`
|
||||||
|
|
||||||
|
### 0.27.6
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* Versions:
|
||||||
|
* `Kotlin Coroutines`: `1.3.6` -> `1.3.7`
|
||||||
|
* `TelegramBotAPI`:
|
||||||
|
* Interface `PossiblySentViaBot` has been added
|
||||||
|
* Additional interface `PossiblySentViaBotCommonMessage` was added for more explicit typing declaration for
|
||||||
|
compiler
|
||||||
|
* Currently, only `ChannelMessage` and `CommonMessageImpl` are implementing the interface
|
||||||
|
`PossiblySentViaBotCommonMessage`. It could be changed in future
|
||||||
|
* Factory `buildMimeType` was added
|
||||||
|
* `BuiltinMimeTypes` was added
|
||||||
|
* Abstraction `ThumbedWithMimeTypeInlineQueryResult` with `thumbMimeType` field was added
|
||||||
|
* `InlineQueryResultGif` and `InlineQueryResultMpeg4Gif` now extend `ThumbedWithMimeTypeInlineQueryResult`
|
||||||
|
instead of `ThumbedInlineQueryResult`
|
||||||
|
* `TelegramBotAPI-extensions-utils`:
|
||||||
|
* New extensions `onlyCommonMessages`, `onlySentViaBot` and `withoutSentViaBot` was added
|
||||||
|
|
||||||
### 0.27.5
|
### 0.27.5
|
||||||
|
|
||||||
* `Common`:
|
* `Common`:
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.CommonMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.PossiblySentViaBotCommonMessage
|
||||||
|
import kotlinx.coroutines.flow.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple factory to convert [ContentMessage] to a [CommonMessage]
|
||||||
|
*/
|
||||||
|
fun <C: MessageContent, T : ContentMessage<C>> Flow<T>.onlyCommonMessages() = filterIsInstance<CommonMessage<C>>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the messages and checking that incoming [CommonMessage] is [PossiblySentViaBotCommonMessage] and its
|
||||||
|
* [PossiblySentViaBotCommonMessage.senderBot] is not null
|
||||||
|
*/
|
||||||
|
fun <T : MessageContent> Flow<CommonMessage<T>>.onlySentViaBot() = mapNotNull {
|
||||||
|
(it as? PossiblySentViaBotCommonMessage) ?.let { possiblySentViaBot ->
|
||||||
|
if (possiblySentViaBot.senderBot != null) {
|
||||||
|
possiblySentViaBot
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the messages and checking that incoming [CommonMessage] not is [PossiblySentViaBotCommonMessage] or its
|
||||||
|
* [PossiblySentViaBotCommonMessage.senderBot] is null
|
||||||
|
*/
|
||||||
|
fun <T : MessageContent> Flow<CommonMessage<T>>.withoutSentViaBot() = filter {
|
||||||
|
it !is PossiblySentViaBotCommonMessage || it.senderBot == null
|
||||||
|
}
|
@ -12,6 +12,13 @@ fun <T : BaseSentMessageUpdate> Flow<T>.asContentMessagesFlow() = mapNotNull {
|
|||||||
it.data as? ContentMessage<*>
|
it.data as? ContentMessage<*>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will map incoming [BaseSentMessageUpdate]s to [CommonMessage] from [BaseSentMessageUpdate.data]
|
||||||
|
*/
|
||||||
|
fun <T : BaseSentMessageUpdate> Flow<T>.asCommonMessagesFlow() = mapNotNull {
|
||||||
|
it.data as? CommonMessage<*>
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will map incoming [BaseSentMessageUpdate]s to [ChatEventMessage] from [BaseSentMessageUpdate.data]
|
* Will map incoming [BaseSentMessageUpdate]s to [ChatEventMessage] from [BaseSentMessageUpdate.data]
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types
|
package com.github.insanusmokrassar.TelegramBotAPI.types
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.BuiltinMimeTypes
|
||||||
|
|
||||||
typealias Identifier = Long
|
typealias Identifier = Long
|
||||||
typealias MessageIdentifier = Long
|
typealias MessageIdentifier = Long
|
||||||
typealias InlineQueryIdentifier = String
|
typealias InlineQueryIdentifier = String
|
||||||
@ -63,6 +65,12 @@ val quizPollExplanationLimit = explanationLimit
|
|||||||
|
|
||||||
val openPeriodPollSecondsLimit = 5 .. 600
|
val openPeriodPollSecondsLimit = 5 .. 600
|
||||||
|
|
||||||
|
val telegramInlineModeGifPermittedMimeTypes = listOf(
|
||||||
|
BuiltinMimeTypes.Image.Jpg,
|
||||||
|
BuiltinMimeTypes.Image.Gif,
|
||||||
|
BuiltinMimeTypes.Video.MP4
|
||||||
|
)
|
||||||
|
|
||||||
const val chatIdField = "chat_id"
|
const val chatIdField = "chat_id"
|
||||||
const val messageIdField = "message_id"
|
const val messageIdField = "message_id"
|
||||||
const val updateIdField = "update_id"
|
const val updateIdField = "update_id"
|
||||||
@ -177,6 +185,7 @@ const val stickerFileIdField = "sticker_file_id"
|
|||||||
const val gameShortNameField = "game_short_name"
|
const val gameShortNameField = "game_short_name"
|
||||||
|
|
||||||
const val thumbUrlField = "thumb_url"
|
const val thumbUrlField = "thumb_url"
|
||||||
|
const val thumbMimeTypeField = "thumb_mime_type"
|
||||||
const val thumbWidthField = "thumb_width"
|
const val thumbWidthField = "thumb_width"
|
||||||
const val thumbHeightField = "thumb_height"
|
const val thumbHeightField = "thumb_height"
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.
|
|||||||
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.utils.MimeType
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@ -18,6 +19,8 @@ data class InlineQueryResultGifImpl(
|
|||||||
override val url: String,
|
override val url: String,
|
||||||
@SerialName(thumbUrlField)
|
@SerialName(thumbUrlField)
|
||||||
override val thumbUrl: String,
|
override val thumbUrl: String,
|
||||||
|
@SerialName(thumbMimeTypeField)
|
||||||
|
override val thumbMimeType: MimeType? = null,
|
||||||
@SerialName(gifWidthField)
|
@SerialName(gifWidthField)
|
||||||
override val width: Int? = null,
|
override val width: Int? = null,
|
||||||
@SerialName(gifHeightField)
|
@SerialName(gifHeightField)
|
||||||
@ -36,4 +39,10 @@ data class InlineQueryResultGifImpl(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultGif {
|
) : InlineQueryResultGif {
|
||||||
override val type: String = inlineQueryResultGifType
|
override val type: String = inlineQueryResultGifType
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (thumbMimeType != null && thumbMimeType !in telegramInlineModeGifPermittedMimeTypes) {
|
||||||
|
error("Passed thumb mime type is not permitted in Telegram Bot API. Passed $thumbMimeType, but permitted $telegramInlineModeGifPermittedMimeTypes")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.
|
|||||||
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.utils.MimeType
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@ -18,6 +19,8 @@ data class InlineQueryResultMpeg4GifImpl(
|
|||||||
override val url: String,
|
override val url: String,
|
||||||
@SerialName(thumbUrlField)
|
@SerialName(thumbUrlField)
|
||||||
override val thumbUrl: String,
|
override val thumbUrl: String,
|
||||||
|
@SerialName(thumbMimeTypeField)
|
||||||
|
override val thumbMimeType: MimeType? = null,
|
||||||
@SerialName(mpeg4GifWidthField)
|
@SerialName(mpeg4GifWidthField)
|
||||||
override val width: Int? = null,
|
override val width: Int? = null,
|
||||||
@SerialName(mpeg4GifHeightField)
|
@SerialName(mpeg4GifHeightField)
|
||||||
@ -36,4 +39,10 @@ data class InlineQueryResultMpeg4GifImpl(
|
|||||||
override val inputMessageContent: InputMessageContent? = null
|
override val inputMessageContent: InputMessageContent? = null
|
||||||
) : InlineQueryResultMpeg4Gif {
|
) : InlineQueryResultMpeg4Gif {
|
||||||
override val type: String = inlineQueryResultMpeg4GifType
|
override val type: String = inlineQueryResultMpeg4GifType
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (thumbMimeType != null && thumbMimeType !in telegramInlineModeGifPermittedMimeTypes) {
|
||||||
|
error("Passed thumb mime type is not permitted in Telegram Bot API. Passed $thumbMimeType, but permitted $telegramInlineModeGifPermittedMimeTypes")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts
|
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.MimeType
|
||||||
|
|
||||||
interface ThumbedInlineQueryResult : InlineQueryResult {
|
interface ThumbedInlineQueryResult : InlineQueryResult {
|
||||||
val thumbUrl: String?
|
val thumbUrl: String?
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ThumbedWithMimeTypeInlineQueryResult : ThumbedInlineQueryResult {
|
||||||
|
val thumbMimeType: MimeType?
|
||||||
}
|
}
|
@ -2,4 +2,4 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQue
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.*
|
||||||
|
|
||||||
interface InlineQueryResultGif : InlineQueryResultGifCommon, UrlInlineQueryResult, ThumbedInlineQueryResult, SizedInlineQueryResult, DuratedInlineResultQuery
|
interface InlineQueryResultGif : InlineQueryResultGifCommon, UrlInlineQueryResult, ThumbedWithMimeTypeInlineQueryResult, SizedInlineQueryResult, DuratedInlineResultQuery
|
@ -2,4 +2,4 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQue
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.*
|
||||||
|
|
||||||
interface InlineQueryResultMpeg4Gif : InlineQueryResultMpeg4GifCommon, UrlInlineQueryResult, ThumbedInlineQueryResult, SizedInlineQueryResult, DuratedInlineResultQuery
|
interface InlineQueryResultMpeg4Gif : InlineQueryResultMpeg4GifCommon, UrlInlineQueryResult, ThumbedWithMimeTypeInlineQueryResult, SizedInlineQueryResult, DuratedInlineResultQuery
|
@ -1,12 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.AuthorSignature
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.CommonMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
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.message.content.abstracts.PossiblySentViaBotCommonMessage
|
||||||
import com.soywiz.klock.DateTime
|
import com.soywiz.klock.DateTime
|
||||||
|
|
||||||
data class ChannelMessage<T: MessageContent>(
|
data class ChannelMessage<T: MessageContent>(
|
||||||
@ -18,5 +17,6 @@ data class ChannelMessage<T: MessageContent>(
|
|||||||
override val forwardInfo: ForwardInfo?,
|
override val forwardInfo: ForwardInfo?,
|
||||||
override val replyTo: Message?,
|
override val replyTo: Message?,
|
||||||
override val replyMarkup: InlineKeyboardMarkup?,
|
override val replyMarkup: InlineKeyboardMarkup?,
|
||||||
|
override val senderBot: CommonBot?,
|
||||||
val authorSignature: AuthorSignature?
|
val authorSignature: AuthorSignature?
|
||||||
) : CommonMessage<T>
|
) : PossiblySentViaBotCommonMessage<T>
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
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.message.content.abstracts.PossiblySentViaBotCommonMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.SuccessfulPaymentInfo
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.SuccessfulPaymentInfo
|
||||||
import com.soywiz.klock.DateTime
|
import com.soywiz.klock.DateTime
|
||||||
|
|
||||||
@ -19,5 +19,6 @@ data class CommonMessageImpl<T: MessageContent>(
|
|||||||
override val forwardInfo: ForwardInfo?,
|
override val forwardInfo: ForwardInfo?,
|
||||||
override val replyTo: Message?,
|
override val replyTo: Message?,
|
||||||
override val replyMarkup: InlineKeyboardMarkup?,
|
override val replyMarkup: InlineKeyboardMarkup?,
|
||||||
|
override val senderBot: CommonBot?,
|
||||||
val paymentInfo: SuccessfulPaymentInfo?
|
val paymentInfo: SuccessfulPaymentInfo?
|
||||||
) : Message, CommonMessage<T>, FromUserMessage
|
) : PossiblySentViaBotCommonMessage<T>, FromUserMessage
|
@ -42,6 +42,7 @@ internal data class RawMessage(
|
|||||||
private val forward_sender_name: ForwardSenderName? = null,
|
private val forward_sender_name: ForwardSenderName? = null,
|
||||||
private val forward_date: TelegramDate? = null,
|
private val forward_date: TelegramDate? = null,
|
||||||
private val reply_to_message: RawMessage? = null,
|
private val reply_to_message: RawMessage? = null,
|
||||||
|
private val via_bot: CommonBot? = null,
|
||||||
private val edit_date: TelegramDate? = null,
|
private val edit_date: TelegramDate? = null,
|
||||||
private val media_group_id: MediaGroupIdentifier? = null,
|
private val media_group_id: MediaGroupIdentifier? = null,
|
||||||
private val author_signature: AuthorSignature? = null,
|
private val author_signature: AuthorSignature? = null,
|
||||||
@ -147,7 +148,7 @@ internal data class RawMessage(
|
|||||||
)
|
)
|
||||||
forward_from_chat is ChannelChat -> ForwardFromChannelInfo(
|
forward_from_chat is ChannelChat -> ForwardFromChannelInfo(
|
||||||
forward_date,
|
forward_date,
|
||||||
forward_from_message_id ?: throw IllegalStateException("Channel forwarded message must contain message id, but was not"),
|
forward_from_message_id ?: error("Channel forwarded message must contain message id, but was not"),
|
||||||
forward_from_chat,
|
forward_from_chat,
|
||||||
forward_signature
|
forward_signature
|
||||||
)
|
)
|
||||||
@ -208,7 +209,7 @@ internal data class RawMessage(
|
|||||||
chatEvent as? ChannelEvent ?: throwWrongChatEvent(ChannelEvent::class, chatEvent),
|
chatEvent as? ChannelEvent ?: throwWrongChatEvent(ChannelEvent::class, chatEvent),
|
||||||
date.asDate
|
date.asDate
|
||||||
)
|
)
|
||||||
else -> throw IllegalStateException("Expected one of the public chats, but was $chat (in extracting of chat event message)")
|
else -> error("Expected one of the public chats, but was $chat (in extracting of chat event message)")
|
||||||
}
|
}
|
||||||
} ?: content?.let { content ->
|
} ?: content?.let { content ->
|
||||||
media_group_id?.let {
|
media_group_id?.let {
|
||||||
@ -221,7 +222,7 @@ internal data class RawMessage(
|
|||||||
when (content) {
|
when (content) {
|
||||||
is PhotoContent -> content
|
is PhotoContent -> content
|
||||||
is VideoContent -> content
|
is VideoContent -> content
|
||||||
else -> throw IllegalStateException("Unsupported content for media group")
|
else -> error("Unsupported content for media group")
|
||||||
},
|
},
|
||||||
edit_date?.asDate,
|
edit_date?.asDate,
|
||||||
forwarded,
|
forwarded,
|
||||||
@ -237,7 +238,7 @@ internal data class RawMessage(
|
|||||||
when (content) {
|
when (content) {
|
||||||
is PhotoContent -> content
|
is PhotoContent -> content
|
||||||
is VideoContent -> content
|
is VideoContent -> content
|
||||||
else -> throw IllegalStateException("Unsupported content for media group")
|
else -> error("Unsupported content for media group")
|
||||||
},
|
},
|
||||||
edit_date?.asDate,
|
edit_date?.asDate,
|
||||||
forwarded,
|
forwarded,
|
||||||
@ -255,12 +256,12 @@ internal data class RawMessage(
|
|||||||
forwarded,
|
forwarded,
|
||||||
reply_to_message?.asMessage,
|
reply_to_message?.asMessage,
|
||||||
reply_markup,
|
reply_markup,
|
||||||
|
via_bot,
|
||||||
author_signature
|
author_signature
|
||||||
)
|
)
|
||||||
else -> CommonMessageImpl(
|
else -> CommonMessageImpl(
|
||||||
messageId,
|
messageId,
|
||||||
from
|
from ?: error("Was detected common message, but owner (sender) of the message was not found"),
|
||||||
?: throw IllegalStateException("Was detected common message, but owner (sender) of the message was not found"),
|
|
||||||
chat,
|
chat,
|
||||||
content,
|
content,
|
||||||
date.asDate,
|
date.asDate,
|
||||||
@ -268,10 +269,11 @@ internal data class RawMessage(
|
|||||||
forwarded,
|
forwarded,
|
||||||
reply_to_message?.asMessage,
|
reply_to_message?.asMessage,
|
||||||
reply_markup,
|
reply_markup,
|
||||||
|
via_bot,
|
||||||
paymentInfo
|
paymentInfo
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} ?: throw IllegalStateException("Was not found supported type of data")
|
} ?: error("Was not found supported type of data")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
UnknownMessageType(
|
UnknownMessageType(
|
||||||
messageId,
|
messageId,
|
||||||
@ -283,6 +285,6 @@ internal data class RawMessage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun throwWrongChatEvent(expected: KClass<*>, but: ChatEvent): CommonEvent {
|
private fun throwWrongChatEvent(expected: KClass<*>, but: ChatEvent): CommonEvent {
|
||||||
throw IllegalStateException("Wrong type of chat event: expected $expected, but was $but")
|
error("Wrong type of chat event: expected $expected, but was $but")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.CommonBot
|
||||||
|
|
||||||
|
interface PossiblySentViaBot {
|
||||||
|
val senderBot: CommonBot?
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.CommonMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.PossiblySentViaBot
|
||||||
|
|
||||||
|
interface PossiblySentViaBotCommonMessage<T: MessageContent> : CommonMessage<T>, PossiblySentViaBot
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.utils
|
||||||
|
|
||||||
|
object BuiltinMimeTypes {
|
||||||
|
object Image {
|
||||||
|
val Jpg = buildMimeType("image/jpeg")
|
||||||
|
val Gif = buildMimeType("image/gif")
|
||||||
|
}
|
||||||
|
object Video {
|
||||||
|
val MP4 = buildMimeType("video/mp4")
|
||||||
|
}
|
||||||
|
}
|
@ -7,5 +7,7 @@ expect class MimeType {
|
|||||||
val raw: String
|
val raw: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expect fun buildMimeType(raw: String): MimeType
|
||||||
|
|
||||||
@Serializer(MimeType::class)
|
@Serializer(MimeType::class)
|
||||||
internal expect object MimeTypeSerializer : KSerializer<MimeType>
|
internal expect object MimeTypeSerializer : KSerializer<MimeType>
|
||||||
|
@ -23,7 +23,7 @@ internal actual object MimeTypeSerializer : KSerializer<MimeType> {
|
|||||||
override fun deserialize(decoder: Decoder): MimeType {
|
override fun deserialize(decoder: Decoder): MimeType {
|
||||||
val mimeType = decoder.decodeString()
|
val mimeType = decoder.decodeString()
|
||||||
return mimesCache.getOrPut(mimeType) {
|
return mimesCache.getOrPut(mimeType) {
|
||||||
MimeType(mimeType)
|
buildMimeType(mimeType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,3 +31,5 @@ internal actual object MimeTypeSerializer : KSerializer<MimeType> {
|
|||||||
encoder.encodeString(value.raw)
|
encoder.encodeString(value.raw)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actual fun buildMimeType(raw: String) = MimeType(raw)
|
||||||
|
@ -24,3 +24,5 @@ internal actual object MimeTypeSerializer : KSerializer<MimeType> {
|
|||||||
encoder.encodeString(value.raw)
|
encoder.encodeString(value.raw)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actual fun buildMimeType(raw: String): MimeType = MimeType(raw)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
kotlin_version=1.3.72
|
kotlin_version=1.3.72
|
||||||
kotlin_coroutines_version=1.3.6
|
kotlin_coroutines_version=1.3.7
|
||||||
kotlin_serialisation_runtime_version=0.20.0
|
kotlin_serialisation_runtime_version=0.20.0
|
||||||
klock_version=1.11.3
|
klock_version=1.11.3
|
||||||
uuid_version=0.1.0
|
uuid_version=0.1.0
|
||||||
@ -9,6 +9,6 @@ ktor_version=1.3.2
|
|||||||
javax_activation_version=1.1.1
|
javax_activation_version=1.1.1
|
||||||
|
|
||||||
library_group=com.github.insanusmokrassar
|
library_group=com.github.insanusmokrassar
|
||||||
library_version=0.27.5
|
library_version=0.27.6
|
||||||
|
|
||||||
gradle_bintray_plugin_version=1.8.4
|
gradle_bintray_plugin_version=1.8.4
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
|
||||||
|
Loading…
Reference in New Issue
Block a user