1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-09 09:53:47 +00:00

temporal progress on adding support of paid media

This commit is contained in:
InsanusMokrassar 2024-07-08 00:18:54 +06:00
parent 0d4452d0f5
commit 1eef5bb239
33 changed files with 535 additions and 140 deletions

View File

@ -12,7 +12,7 @@ import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.location.LiveLocation import dev.inmo.tgbotapi.types.location.LiveLocation
import dev.inmo.tgbotapi.types.media.TelegramMedia import dev.inmo.tgbotapi.types.media.TelegramFreeMedia
import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
@ -145,7 +145,7 @@ suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit( suspend fun TelegramBot.edit(
chatId: ChatIdentifier, chatId: ChatIdentifier,
messageId: MessageId, messageId: MessageId,
media: TelegramMedia, media: TelegramFreeMedia,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = editMessageMedia(chatId, messageId, media, businessConnectionId, replyMarkup) ) = editMessageMedia(chatId, messageId, media, businessConnectionId, replyMarkup)
@ -157,7 +157,7 @@ suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit( suspend fun TelegramBot.edit(
chat: Chat, chat: Chat,
messageId: MessageId, messageId: MessageId,
media: TelegramMedia, media: TelegramFreeMedia,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId, businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = editMessageMedia(chat, messageId, media, businessConnectionId, replyMarkup) ) = editMessageMedia(chat, messageId, media, businessConnectionId, replyMarkup)
@ -168,7 +168,7 @@ suspend fun TelegramBot.edit(
*/ */
suspend fun TelegramBot.edit( suspend fun TelegramBot.edit(
message: ContentMessage<MediaContent>, message: ContentMessage<MediaContent>,
media: TelegramMedia, media: TelegramFreeMedia,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId, businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = editMessageMedia(message, media, businessConnectionId, replyMarkup) ) = editMessageMedia(message, media, businessConnectionId, replyMarkup)

View File

@ -8,7 +8,7 @@ import dev.inmo.tgbotapi.extensions.api.edit.text.editMessageText
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.location.LiveLocation import dev.inmo.tgbotapi.types.location.LiveLocation
import dev.inmo.tgbotapi.types.media.TelegramMedia import dev.inmo.tgbotapi.types.media.TelegramFreeMedia
import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.message.textsources.TextSource import dev.inmo.tgbotapi.types.message.textsources.TextSource
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
@ -47,7 +47,7 @@ suspend fun TelegramBot.edit(
*/ */
suspend fun TelegramBot.edit( suspend fun TelegramBot.edit(
messageId: InlineMessageId, messageId: InlineMessageId,
media: TelegramMedia, media: TelegramFreeMedia,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = editMessageMedia(messageId, media, replyMarkup) ) = editMessageMedia(messageId, media, replyMarkup)

View File

@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.edit.media
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.edit.media.EditChatMessageMedia import dev.inmo.tgbotapi.requests.edit.media.EditChatMessageMedia
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.media.TelegramMedia import dev.inmo.tgbotapi.types.media.TelegramFreeMedia
import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.businessConnectionId import dev.inmo.tgbotapi.types.businessConnectionId
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
@ -19,7 +19,7 @@ import dev.inmo.tgbotapi.types.message.content.MediaContent
suspend fun TelegramBot.editMessageMedia( suspend fun TelegramBot.editMessageMedia(
chatId: ChatIdentifier, chatId: ChatIdentifier,
messageId: MessageId, messageId: MessageId,
media: TelegramMedia, media: TelegramFreeMedia,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = execute( ) = execute(
@ -33,7 +33,7 @@ suspend fun TelegramBot.editMessageMedia(
suspend fun TelegramBot.editMessageMedia( suspend fun TelegramBot.editMessageMedia(
chat: Chat, chat: Chat,
messageId: MessageId, messageId: MessageId,
media: TelegramMedia, media: TelegramFreeMedia,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId, businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = editMessageMedia(chat.id, messageId, media, businessConnectionId, replyMarkup) ) = editMessageMedia(chat.id, messageId, media, businessConnectionId, replyMarkup)
@ -44,7 +44,7 @@ suspend fun TelegramBot.editMessageMedia(
*/ */
suspend fun TelegramBot.editMessageMedia( suspend fun TelegramBot.editMessageMedia(
message: ContentMessage<out MediaContent>, message: ContentMessage<out MediaContent>,
media: TelegramMedia, media: TelegramFreeMedia,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId, businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = editMessageMedia(message.chat.id, message.messageId, media, businessConnectionId, replyMarkup) ) = editMessageMedia(message.chat.id, message.messageId, media, businessConnectionId, replyMarkup)

View File

@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.edit.media
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.edit.media.EditInlineMessageMedia import dev.inmo.tgbotapi.requests.edit.media.EditInlineMessageMedia
import dev.inmo.tgbotapi.types.InlineMessageId import dev.inmo.tgbotapi.types.InlineMessageId
import dev.inmo.tgbotapi.types.media.TelegramMedia import dev.inmo.tgbotapi.types.media.TelegramFreeMedia
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
/** /**
@ -12,6 +12,6 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
*/ */
suspend fun TelegramBot.editMessageMedia( suspend fun TelegramBot.editMessageMedia(
inlineMessageId: InlineMessageId, inlineMessageId: InlineMessageId,
media: TelegramMedia, media: TelegramFreeMedia,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = execute(EditInlineMessageMedia(inlineMessageId, media, replyMarkup)) ) = execute(EditInlineMessageMedia(inlineMessageId, media, replyMarkup))

View File

@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.requests.edit.abstracts package dev.inmo.tgbotapi.requests.edit.abstracts
import dev.inmo.tgbotapi.types.media.TelegramMedia import dev.inmo.tgbotapi.types.media.TelegramFreeMedia
interface EditMediaMessage { interface EditMediaMessage {
val media: TelegramMedia val media: TelegramFreeMedia
} }

View File

@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.requests.edit.abstracts.*
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.media.TelegramMedia import dev.inmo.tgbotapi.types.media.TelegramFreeMedia
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
@ -22,7 +22,7 @@ data class EditChatMessageMedia(
@SerialName(messageIdField) @SerialName(messageIdField)
override val messageId: MessageId, override val messageId: MessageId,
@SerialName(mediaField) @SerialName(mediaField)
override val media: TelegramMedia, override val media: TelegramFreeMedia,
@SerialName(businessConnectionIdField) @SerialName(businessConnectionIdField)
override val businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, override val businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)

View File

@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.requests.edit.media
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.requests.edit.abstracts.*
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.media.TelegramMedia import dev.inmo.tgbotapi.types.media.TelegramFreeMedia
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import kotlinx.serialization.* import kotlinx.serialization.*
@ -12,7 +12,7 @@ data class EditInlineMessageMedia(
@SerialName(inlineMessageIdField) @SerialName(inlineMessageIdField)
override val inlineMessageId: InlineMessageId, override val inlineMessageId: InlineMessageId,
@SerialName(mediaField) @SerialName(mediaField)
override val media: TelegramMedia, override val media: TelegramFreeMedia,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditInlineMessage, EditReplyMessage, EditMediaMessage { ) : EditInlineMessage, EditReplyMessage, EditMediaMessage {

View File

@ -4,7 +4,6 @@ import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
import dev.inmo.tgbotapi.requests.send.abstracts.SendContentMessageRequest import dev.inmo.tgbotapi.requests.send.abstracts.SendContentMessageRequest
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
import dev.inmo.tgbotapi.requests.send.media.base.* import dev.inmo.tgbotapi.requests.send.media.base.*
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
@ -193,7 +192,7 @@ data class SendMediaGroupData internal constructor(
private val convertedMedia: String private val convertedMedia: String
get() = buildJsonArray { get() = buildJsonArray {
media.forEach { media.forEach {
add(it.toJsonWithoutNulls(MediaGroupMemberTelegramMediaSerializer)) add(it.toJsonWithoutNulls(MediaGroupMemberTelegramFreeMediaSerializer))
} }
}.toString() }.toString()

View File

@ -0,0 +1,209 @@
package dev.inmo.tgbotapi.requests.send.media
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
import dev.inmo.tgbotapi.requests.send.abstracts.SendContentMessageRequest
import dev.inmo.tgbotapi.requests.send.media.base.*
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.media.*
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupPartContent
import dev.inmo.tgbotapi.types.message.content.AudioContent
import dev.inmo.tgbotapi.types.message.content.DocumentContent
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
import dev.inmo.tgbotapi.utils.*
import dev.inmo.tgbotapi.utils.extensions.asMediaGroupMessage
import kotlinx.serialization.*
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.buildJsonArray
const val rawSendingMediaGroupsWarning = "Media groups contains restrictions related to combinations of media" +
" types. Currently it is possible to combine photo + video OR audio OR documents"
@RiskFeature(rawSendingMediaGroupsWarning)
fun <T : MediaGroupPartContent> SendMediaGroup(
chatId: ChatIdentifier,
media: List<MediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
effectId: EffectId? = null,
replyParameters: ReplyParameters? = null
): Request<ContentMessage<MediaGroupContent<T>>> {
if (media.size !in mediaCountInMediaGroup) {
throwRangeError("Count of members in media group", mediaCountInMediaGroup, media.size)
}
val files: List<MultipartFile> = media.flatMap {
listOfNotNull(
it.file as? MultipartFile,
if (it is ThumbedTelegramMedia) {
it.thumb as? MultipartFile
} else {
null
}
)
}
val data = SendMediaGroupData(
chatId = chatId,
media = media,
threadId = threadId,
businessConnectionId = businessConnectionId,
disableNotification = disableNotification,
protectContent = protectContent,
effectId = effectId,
replyParameters = replyParameters
)
return (if (files.isEmpty()) {
data
} else {
CommonMultipartFileRequest(
data,
files.associateBy { it.fileId }
)
}) as Request<ContentMessage<MediaGroupContent<T>>>
}
/**
* Use this method to be sure that you are correctly sending playlist with audios
*
* @see TelegramMediaAudio
*/
@Suppress("NOTHING_TO_INLINE")
inline fun SendPlaylist(
chatId: ChatIdentifier,
media: List<AudioMediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
effectId: EffectId? = null,
replyParameters: ReplyParameters? = null
) = SendMediaGroup<AudioContent>(
chatId = chatId,
media = media,
threadId = threadId,
businessConnectionId = businessConnectionId,
disableNotification = disableNotification,
protectContent = protectContent,
effectId = effectId,
replyParameters = replyParameters
)
/**
* Use this method to be sure that you are correctly sending documents media group
*
* @see TelegramMediaDocument
*/
@Suppress("NOTHING_TO_INLINE")
inline fun SendDocumentsGroup(
chatId: ChatIdentifier,
media: List<DocumentMediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
effectId: EffectId? = null,
replyParameters: ReplyParameters? = null
) = SendMediaGroup<DocumentContent>(
chatId = chatId,
media = media,
threadId = threadId,
businessConnectionId = businessConnectionId,
disableNotification = disableNotification,
protectContent = protectContent,
effectId = effectId,
replyParameters = replyParameters
)
/**
* Use this method to be sure that you are correctly sending visual media group
*
* @see TelegramMediaPhoto
* @see TelegramMediaVideo
*/
@Suppress("NOTHING_TO_INLINE")
inline fun SendVisualMediaGroup(
chatId: ChatIdentifier,
media: List<VisualMediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
effectId: EffectId? = null,
replyParameters: ReplyParameters? = null,
) = SendMediaGroup<VisualMediaGroupPartContent>(
chatId = chatId,
media = media,
threadId = threadId,
businessConnectionId = businessConnectionId,
disableNotification = disableNotification,
protectContent = protectContent,
effectId = effectId,
replyParameters = replyParameters
)
private object MessagesListSerializer: KSerializer<PossiblySentViaBotCommonMessage<MediaGroupContent<MediaGroupPartContent>>> {
private val serializer = ListSerializer(TelegramBotAPIMessageDeserializeOnlySerializerClass<PossiblySentViaBotCommonMessage<MediaGroupPartContent>>())
override val descriptor: SerialDescriptor = serializer.descriptor
override fun deserialize(decoder: Decoder): PossiblySentViaBotCommonMessage<MediaGroupContent<MediaGroupPartContent>> {
val messages = serializer.deserialize(decoder)
return messages.asMediaGroupMessage()
}
override fun serialize(encoder: Encoder, value: PossiblySentViaBotCommonMessage<MediaGroupContent<MediaGroupPartContent>>) {
serializer.serialize(encoder, value.content.group.map { it.sourceMessage })
}
}
@Serializable
data class SendMediaGroupData internal constructor(
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
val media: List<MediaGroupMemberTelegramPaidMedia> = emptyList(),
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = chatId.threadId,
@SerialName(businessConnectionIdField)
override val businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
@SerialName(disableNotificationField)
override val disableNotification: Boolean = false,
@SerialName(protectContentField)
override val protectContent: Boolean = false,
@SerialName(messageEffectIdField)
override val effectId: EffectId? = null,
@SerialName(replyParametersField)
override val replyParameters: ReplyParameters? = null,
) : DataRequest<PossiblySentViaBotCommonMessage<MediaGroupContent<MediaGroupPartContent>>>,
SendContentMessageRequest<PossiblySentViaBotCommonMessage<MediaGroupContent<MediaGroupPartContent>>> {
@SerialName(mediaField)
private val convertedMedia: String
get() = buildJsonArray {
media.forEach {
add(it.toJsonWithoutNulls(MediaGroupMemberTelegramFreeMediaSerializer))
}
}.toString()
override fun method(): String = "sendMediaGroup"
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
override val resultDeserializer: DeserializationStrategy<PossiblySentViaBotCommonMessage<MediaGroupContent<MediaGroupPartContent>>>
get() = MessagesListSerializer
}
data class SendMediaGroupFiles internal constructor(
val files: List<MultipartFile>
) : Files by (files.map { it.fileId to it }.toMap())

View File

@ -229,6 +229,7 @@ const val canDeleteStoriesField = "can_delete_stories"
const val captionEntitiesField = "caption_entities" const val captionEntitiesField = "caption_entities"
const val hasSpoilerField = "has_spoiler" const val hasSpoilerField = "has_spoiler"
const val showCaptionAboveMediaField = "show_caption_above_media" const val showCaptionAboveMediaField = "show_caption_above_media"
const val supportsStreamingField = "supports_streaming"
const val loginUrlField = "login_url" const val loginUrlField = "login_url"
const val forwardTextField = "forward_text" const val forwardTextField = "forward_text"
const val botUsernameField = "bot_username" const val botUsernameField = "bot_username"

View File

@ -10,7 +10,7 @@ import kotlin.jvm.JvmInline
@JvmInline @JvmInline
value class Photo( value class Photo(
val photos: List<PhotoSize> val photos: List<PhotoSize>
) : List<PhotoSize> by photos, MediaContentVariant { ) : List<PhotoSize> by photos, MediaContentVariant, UsefulAsPaidMediaFile {
val biggest: PhotoSize val biggest: PhotoSize
get() = biggest()!! get() = biggest()!!
override val fileId: FileId override val fileId: FileId

View File

@ -0,0 +1,3 @@
package dev.inmo.tgbotapi.types.files
sealed interface UsefulAsPaidMediaFile : MediaContentVariant

View File

@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.requests.abstracts.FileId
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.media.TelegramMediaVideo import dev.inmo.tgbotapi.types.media.TelegramMediaVideo
import dev.inmo.tgbotapi.types.media.TelegramPaidMediaVideo
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.utils.MimeType import dev.inmo.tgbotapi.utils.MimeType
@ -30,7 +31,7 @@ data class VideoFile(
@SerialName(fileSizeField) @SerialName(fileSizeField)
override val fileSize: Long? = null override val fileSize: Long? = null
) : TelegramMediaFile, CustomNamedMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile, ) : TelegramMediaFile, CustomNamedMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile,
MediaContentVariant MediaContentVariant, UsefulAsPaidMediaFile
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun VideoFile.toTelegramMediaVideo( inline fun VideoFile.toTelegramMediaVideo(
@ -65,3 +66,11 @@ inline fun VideoFile.toTelegramMediaVideo(
duration = duration, duration = duration,
thumb = thumbnail ?.fileId thumb = thumbnail ?.fileId
) )
@Suppress("NOTHING_TO_INLINE")
inline fun VideoFile.toTelegramPaidMediaVideo() = TelegramPaidMediaVideo(
file = fileId,
width = width,
height = height,
duration = duration,
thumb = thumbnail ?.fileId
)

View File

@ -11,10 +11,10 @@ import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.* import kotlinx.serialization.json.*
@RiskFeature @RiskFeature
object MediaGroupMemberTelegramMediaSerializer : KSerializer<MediaGroupMemberTelegramMedia> { object MediaGroupMemberTelegramFreeMediaSerializer : KSerializer<MediaGroupMemberTelegramFreeMedia> {
@OptIn(InternalSerializationApi::class) @OptIn(InternalSerializationApi::class)
override val descriptor: SerialDescriptor = buildSerialDescriptor(MediaGroupMemberTelegramMedia::class.toString(), PolymorphicKind.OPEN) override val descriptor: SerialDescriptor = buildSerialDescriptor(MediaGroupMemberTelegramMedia::class.toString(), PolymorphicKind.OPEN)
override fun serialize(encoder: Encoder, value: MediaGroupMemberTelegramMedia) { override fun serialize(encoder: Encoder, value: MediaGroupMemberTelegramFreeMedia) {
when (value) { when (value) {
is TelegramMediaPhoto -> TelegramMediaPhoto.serializer().serialize(encoder, value) is TelegramMediaPhoto -> TelegramMediaPhoto.serializer().serialize(encoder, value)
is TelegramMediaVideo -> TelegramMediaVideo.serializer().serialize(encoder, value) is TelegramMediaVideo -> TelegramMediaVideo.serializer().serialize(encoder, value)
@ -23,7 +23,7 @@ object MediaGroupMemberTelegramMediaSerializer : KSerializer<MediaGroupMemberTel
} }
} }
override fun deserialize(decoder: Decoder): MediaGroupMemberTelegramMedia { override fun deserialize(decoder: Decoder): MediaGroupMemberTelegramFreeMedia {
val json = JsonObject.serializer().deserialize(decoder) val json = JsonObject.serializer().deserialize(decoder)
return when (json[typeField] ?.jsonPrimitive ?.contentOrNull) { return when (json[typeField] ?.jsonPrimitive ?.contentOrNull) {
@ -35,3 +35,5 @@ object MediaGroupMemberTelegramMediaSerializer : KSerializer<MediaGroupMemberTel
} }
} }
} }
typealias MediaGroupMemberTelegramMediaSerializer = MediaGroupMemberTelegramFreeMediaSerializer

View File

@ -3,21 +3,25 @@ package dev.inmo.tgbotapi.types.media
import dev.inmo.tgbotapi.abstracts.TextedOutput import dev.inmo.tgbotapi.abstracts.TextedOutput
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.StringFormat import kotlinx.serialization.StringFormat
import kotlinx.serialization.json.Json
internal val argumentsFormatter by lazy { @Serializable(MediaGroupMemberTelegramFreeMediaSerializer::class)
Json { sealed interface MediaGroupMemberTelegramMedia : TelegramMedia {
encodeDefaults = true
}
}
@Serializable(MediaGroupMemberTelegramMediaSerializer::class)
sealed interface MediaGroupMemberTelegramMedia : TelegramMedia, TextedOutput {
fun serialize(format: StringFormat): String fun serialize(format: StringFormat): String
} }
sealed interface AudioMediaGroupMemberTelegramMedia: MediaGroupMemberTelegramMedia @Serializable(MediaGroupMemberTelegramFreeMediaSerializer::class)
sealed interface DocumentMediaGroupMemberTelegramMedia: MediaGroupMemberTelegramMedia sealed interface MediaGroupMemberTelegramFreeMedia : MediaGroupMemberTelegramMedia, TextedOutput
@Serializable(MediaGroupMemberTelegramFreeMediaSerializer::class)
sealed interface MediaGroupMemberTelegramPaidMedia : MediaGroupMemberTelegramMedia
@Serializable(MediaGroupMemberTelegramMediaSerializer::class) sealed interface AudioMediaGroupMemberTelegramMedia: MediaGroupMemberTelegramFreeMedia
sealed interface VisualMediaGroupMemberTelegramMedia : MediaGroupMemberTelegramMedia, SpoilerableTelegramMedia, WithCustomizableCaptionTelegramMedia sealed interface DocumentMediaGroupMemberTelegramMedia: MediaGroupMemberTelegramFreeMedia
@Serializable(MediaGroupMemberTelegramFreeMediaSerializer::class)
sealed interface VisualMediaGroupMemberTelegramMedia : MediaGroupMemberTelegramMedia
@Serializable(MediaGroupMemberTelegramFreeMediaSerializer::class)
sealed interface VisualMediaGroupMemberTelegramFreeMedia : MediaGroupMemberTelegramFreeMedia, VisualMediaGroupMemberTelegramMedia, SpoilerableTelegramMedia, WithCustomizableCaptionTelegramMedia
@Serializable(MediaGroupMemberTelegramPaidMediaSerializer::class)
sealed interface VisualMediaGroupMemberTelegramPaidMedia : MediaGroupMemberTelegramPaidMedia, VisualMediaGroupMemberTelegramMedia

View File

@ -0,0 +1,38 @@
package dev.inmo.tgbotapi.types.media
import dev.inmo.tgbotapi.types.typeField
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
import kotlinx.serialization.InternalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.PolymorphicKind
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.descriptors.buildSerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.contentOrNull
import kotlinx.serialization.json.jsonPrimitive
@RiskFeature
object MediaGroupMemberTelegramPaidMediaSerializer : KSerializer<MediaGroupMemberTelegramPaidMedia> {
@OptIn(InternalSerializationApi::class)
override val descriptor: SerialDescriptor =
buildSerialDescriptor(MediaGroupMemberTelegramMedia::class.toString(), PolymorphicKind.OPEN)
override fun serialize(encoder: Encoder, value: MediaGroupMemberTelegramPaidMedia) {
when (value) {
is TelegramPaidMediaPhoto -> TelegramPaidMediaPhoto.serializer().serialize(encoder, value)
is TelegramPaidMediaVideo -> TelegramPaidMediaVideo.serializer().serialize(encoder, value)
}
}
override fun deserialize(decoder: Decoder): MediaGroupMemberTelegramPaidMedia {
val json = JsonObject.serializer().deserialize(decoder)
return when (json[typeField] ?.jsonPrimitive ?.contentOrNull) {
photoTelegramPaidMediaType -> nonstrictJsonFormat.decodeFromJsonElement(TelegramPaidMediaPhoto.serializer(), json)
videoTelegramPaidMediaType -> nonstrictJsonFormat.decodeFromJsonElement(TelegramPaidMediaVideo.serializer(), json)
else -> error("Illegal type of incoming MediaGroupMemberTelegramMedia")
}
}
}

View File

@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.types.payments.stars package dev.inmo.tgbotapi.types.media
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.PhotoSize import dev.inmo.tgbotapi.types.files.VideoFile
import dev.inmo.tgbotapi.utils.decodeDataAndJson import dev.inmo.tgbotapi.utils.decodeDataAndJson
import kotlinx.serialization.EncodeDefault import kotlinx.serialization.EncodeDefault
import kotlinx.serialization.KSerializer import kotlinx.serialization.KSerializer
@ -13,9 +13,7 @@ import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.JsonElement
@Serializable(PaidMedia.Companion::class) @Serializable(PaidMedia.Companion::class)
sealed interface PaidMedia { sealed interface PaidMedia : TelegramMedia {
val type: String
@Serializable @Serializable
data class Preview( data class Preview(
@SerialName(widthField) @SerialName(widthField)
@ -51,7 +49,7 @@ sealed interface PaidMedia {
@Serializable @Serializable
data class Video( data class Video(
@SerialName(videoField) @SerialName(videoField)
val video: Video val video: VideoFile
) : PaidMedia { ) : PaidMedia {
@EncodeDefault @EncodeDefault
@SerialName(typeField) @SerialName(typeField)
@ -62,7 +60,7 @@ sealed interface PaidMedia {
} }
} }
@Serializable(PaidMedia.Companion::class) @Serializable(Companion::class)
data class Unknown( data class Unknown(
@SerialName(typeField) @SerialName(typeField)
override val type: String, override val type: String,

View File

@ -0,0 +1,9 @@
package dev.inmo.tgbotapi.types.media
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.requests.abstracts.InputFile
import kotlinx.serialization.Serializable
@Serializable(TelegramMediaSerializer::class)
@ClassCastsIncluded
sealed interface TelegramFreeMedia : TelegramMedia

View File

@ -65,7 +65,7 @@ data class TelegramMediaAnimation internal constructor(
override val height: Int? = null, override val height: Int? = null,
override val duration: Long? = null, override val duration: Long? = null,
override val thumb: InputFile? = null override val thumb: InputFile? = null
) : TelegramMedia, SizedTelegramMedia, DuratedTelegramMedia, ThumbedTelegramMedia, TextedOutput, SpoilerableTelegramMedia, WithCustomizableCaptionTelegramMedia { ) : TelegramFreeMedia, SizedTelegramMedia, DuratedTelegramMedia, ThumbedTelegramMedia, TextedOutput, SpoilerableTelegramMedia, WithCustomizableCaptionTelegramMedia {
override val type: String = "animation" override val type: String = "animation"
override val textSources: TextSourcesList? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)

View File

@ -52,7 +52,7 @@ data class TelegramMediaAudio internal constructor(
override val performer: String? = null, override val performer: String? = null,
override val title: String? = null, override val title: String? = null,
override val thumb: InputFile? = null override val thumb: InputFile? = null
) : TelegramMedia, AudioMediaGroupMemberTelegramMedia, DuratedTelegramMedia, ThumbedTelegramMedia, TitledTelegramMedia, ) : TelegramFreeMedia, AudioMediaGroupMemberTelegramMedia, DuratedTelegramMedia, ThumbedTelegramMedia, TitledTelegramMedia,
Performerable { Performerable {
override val type: String = audioTelegramMediaType override val type: String = audioTelegramMediaType
override val textSources: TextSourcesList? by lazy { override val textSources: TextSourcesList? by lazy {

View File

@ -58,7 +58,7 @@ data class TelegramMediaDocument internal constructor(
override val thumb: InputFile? = null, override val thumb: InputFile? = null,
@SerialName(disableContentTypeDetectionField) @SerialName(disableContentTypeDetectionField)
val disableContentTypeDetection: Boolean? = null val disableContentTypeDetection: Boolean? = null
) : TelegramMedia, DocumentMediaGroupMemberTelegramMedia, ThumbedTelegramMedia { ) : TelegramFreeMedia, DocumentMediaGroupMemberTelegramMedia, ThumbedTelegramMedia {
override val type: String = documentTelegramMediaType override val type: String = documentTelegramMediaType
override val textSources: TextSourcesList? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)

View File

@ -43,7 +43,7 @@ data class TelegramMediaPhoto internal constructor(
override val spoilered: Boolean = false, override val spoilered: Boolean = false,
@SerialName(showCaptionAboveMediaField) @SerialName(showCaptionAboveMediaField)
override val showCaptionAboveMedia: Boolean = false, override val showCaptionAboveMedia: Boolean = false,
) : TelegramMedia, VisualMediaGroupMemberTelegramMedia { ) : TelegramFreeMedia, VisualMediaGroupMemberTelegramFreeMedia {
override val type: String = photoTelegramMediaType override val type: String = photoTelegramMediaType
override val textSources: TextSourcesList? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)

View File

@ -18,6 +18,8 @@ object TelegramMediaSerializer : KSerializer<TelegramMedia> {
is TelegramMediaPhoto -> TelegramMediaPhoto.serializer().serialize(encoder, value) is TelegramMediaPhoto -> TelegramMediaPhoto.serializer().serialize(encoder, value)
is TelegramMediaAnimation -> TelegramMediaAnimation.serializer().serialize(encoder, value) is TelegramMediaAnimation -> TelegramMediaAnimation.serializer().serialize(encoder, value)
is TelegramMediaDocument -> TelegramMediaDocument.serializer().serialize(encoder, value) is TelegramMediaDocument -> TelegramMediaDocument.serializer().serialize(encoder, value)
is TelegramPaidMediaVideo -> TelegramPaidMediaVideo.serializer().serialize(encoder, value)
is TelegramPaidMediaPhoto -> TelegramPaidMediaPhoto.serializer().serialize(encoder, value)
} }
} }

View File

@ -76,7 +76,7 @@ data class TelegramMediaVideo internal constructor (
override val height: Int? = null, override val height: Int? = null,
override val duration: Long? = null, override val duration: Long? = null,
override val thumb: InputFile? = null override val thumb: InputFile? = null
) : TelegramMedia, SizedTelegramMedia, DuratedTelegramMedia, ThumbedTelegramMedia, VisualMediaGroupMemberTelegramMedia { ) : TelegramFreeMedia, SizedTelegramMedia, DuratedTelegramMedia, ThumbedTelegramMedia, VisualMediaGroupMemberTelegramFreeMedia {
override val type: String = videoTelegramMediaType override val type: String = videoTelegramMediaType
override val textSources: TextSourcesList? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null) rawEntities ?.asTextSources(text ?: return@lazy null)

View File

@ -0,0 +1,9 @@
package dev.inmo.tgbotapi.types.media
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.requests.abstracts.InputFile
import kotlinx.serialization.Serializable
@Serializable(TelegramMediaSerializer::class)
@ClassCastsIncluded
sealed interface TelegramPaidMedia : TelegramMedia

View File

@ -0,0 +1,33 @@
package dev.inmo.tgbotapi.types.media
import dev.inmo.tgbotapi.requests.abstracts.InputFile
import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.message.parseModeField
import dev.inmo.tgbotapi.types.files.PhotoSize
import dev.inmo.tgbotapi.types.message.*
import dev.inmo.tgbotapi.types.message.RawMessageEntity
import dev.inmo.tgbotapi.types.message.toRawMessageEntities
import dev.inmo.tgbotapi.utils.extensions.makeString
import kotlinx.serialization.*
internal const val photoTelegramPaidMediaType = "photo"
@Serializable
data class TelegramPaidMediaPhoto internal constructor(
override val file: InputFile,
) : TelegramPaidMedia, VisualMediaGroupMemberTelegramPaidMedia {
override val type: String = photoTelegramPaidMediaType
override fun serialize(format: StringFormat): String = format.encodeToString(serializer(), this)
@SerialName(mediaField)
override val media: String
init { media = file.fileIdToSend } // crutch until js compiling will be fixed
}
fun PhotoSize.toTelegramPaidMediaPhoto(): TelegramPaidMediaPhoto = TelegramPaidMediaPhoto(
file = fileId,
)

View File

@ -0,0 +1,38 @@
package dev.inmo.tgbotapi.types.media
import dev.inmo.tgbotapi.requests.abstracts.InputFile
import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.VideoFile
import kotlinx.serialization.*
internal const val videoTelegramPaidMediaType = "video"
@Serializable
data class TelegramPaidMediaVideo (
override val file: InputFile,
override val thumb: InputFile? = null,
override val width: Int? = null,
override val height: Int? = null,
override val duration: Long? = null,
@SerialName(supportsStreamingField)
val supportsStreaming: Boolean = false,
) : TelegramPaidMedia, SizedTelegramMedia, DuratedTelegramMedia, ThumbedTelegramMedia, VisualMediaGroupMemberTelegramPaidMedia {
override val type: String = videoTelegramPaidMediaType
override fun serialize(format: StringFormat): String = format.encodeToString(serializer(), this)
@SerialName(mediaField)
override val media: String
init { media = file.fileIdToSend } // crutch until js compiling will be fixed
}
fun VideoFile.toTelegramPaidMediaVideo(): TelegramPaidMediaVideo = TelegramPaidMediaVideo(
file = fileId,
thumb = thumbnail ?.fileId,
width = width,
height = height,
duration = duration
)
fun PaidMedia.Video.toTelegramPaidMediaVideo(): TelegramPaidMediaVideo = video.toTelegramPaidMediaVideo()

View File

@ -9,6 +9,7 @@ import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.files.TelegramMediaFile import dev.inmo.tgbotapi.types.files.TelegramMediaFile
import dev.inmo.tgbotapi.types.media.TelegramFreeMedia
import dev.inmo.tgbotapi.types.media.TelegramMedia import dev.inmo.tgbotapi.types.media.TelegramMedia
import dev.inmo.tgbotapi.types.message.abstracts.* import dev.inmo.tgbotapi.types.message.abstracts.*
import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.RiskFeature

View File

@ -7,7 +7,7 @@ import dev.inmo.tgbotapi.types.abstracts.WithOptionalQuoteInfo
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.files.TelegramMediaFile import dev.inmo.tgbotapi.types.files.TelegramMediaFile
import dev.inmo.tgbotapi.types.media.TelegramMedia import dev.inmo.tgbotapi.types.media.TelegramFreeMedia
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.textsources.TextSource import dev.inmo.tgbotapi.types.message.textsources.TextSource
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@ -29,7 +29,7 @@ data class MediaGroupContent<T : MediaGroupPartContent>(
override val text: String? override val text: String?
get() = mainContent.text get() = mainContent.text
override fun asTelegramMedia(): TelegramMedia = mainContent.asTelegramMedia() override fun asTelegramMedia(): TelegramFreeMedia = mainContent.asTelegramMedia()
override fun createResend( override fun createResend(
chatId: ChatIdentifier, chatId: ChatIdentifier,

View File

@ -0,0 +1,40 @@
package dev.inmo.tgbotapi.types.message.content
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.files.*
import dev.inmo.tgbotapi.types.media.PaidMedia
import dev.inmo.tgbotapi.types.media.TelegramPaidMedia
import dev.inmo.tgbotapi.types.media.toTelegramMediaPhoto
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import kotlinx.serialization.Serializable
@Serializable
data class PaidMediaInfoContent(
override val mediaCollection: List<PaidMedia>,
override val text: String? = null,
override val textSources: TextSourcesList = emptyList(),
override val quote: TextQuote? = null,
override val showCaptionAboveMedia: Boolean = false
) : MediaCollectionContent<UsefulAsPaidMediaFile>, TextedMediaContent, WithCustomizedCaptionMediaContent {
override val media: UsefulAsPaidMediaFile
get() = mediaCollection.first()
override fun asTelegramMedia(): TelegramPaidMedia = when (val media = media) {
is VideoFile -> media.toTelegramPaidMediaVideo()
is Photo -> media.biggest.toTelegramMediaPhoto()
}
override fun createResend(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId?,
businessConnectionId: BusinessConnectionId?,
disableNotification: Boolean,
protectContent: Boolean,
effectId: EffectId?,
replyParameters: ReplyParameters?,
replyMarkup: KeyboardMarkup?
): Request<ContentMessage<PaidMediaInfoContent>> = TODO()
}

View File

@ -3,7 +3,7 @@ package dev.inmo.tgbotapi
import dev.inmo.tgbotapi.requests.abstracts.toInputFile import dev.inmo.tgbotapi.requests.abstracts.toInputFile
import dev.inmo.tgbotapi.types.TgFileUniqueId import dev.inmo.tgbotapi.types.TgFileUniqueId
import dev.inmo.tgbotapi.types.files.Photo import dev.inmo.tgbotapi.types.files.Photo
import dev.inmo.tgbotapi.types.media.MediaGroupMemberTelegramMediaSerializer import dev.inmo.tgbotapi.types.media.MediaGroupMemberTelegramFreeMediaSerializer
import dev.inmo.tgbotapi.types.files.PhotoSize import dev.inmo.tgbotapi.types.files.PhotoSize
import dev.inmo.tgbotapi.types.message.content.PhotoContent import dev.inmo.tgbotapi.types.message.content.PhotoContent
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
@ -31,13 +31,13 @@ class SimpleInputFilesTest {
val inputMedia = photoContent.toMediaGroupMemberTelegramMedia() val inputMedia = photoContent.toMediaGroupMemberTelegramMedia()
assertEquals(photoContent.media.fileId, inputMedia.file) assertEquals(photoContent.media.fileId, inputMedia.file)
val encoded = nonstrictJsonFormat.encodeToString( val encoded = nonstrictJsonFormat.encodeToString(
MediaGroupMemberTelegramMediaSerializer, MediaGroupMemberTelegramFreeMediaSerializer,
inputMedia inputMedia
) )
assertEquals( assertEquals(
inputMedia, inputMedia,
nonstrictJsonFormat.decodeFromString( nonstrictJsonFormat.decodeFromString(
MediaGroupMemberTelegramMediaSerializer, MediaGroupMemberTelegramFreeMediaSerializer,
encoded encoded
) )
) )

View File

@ -1999,141 +1999,141 @@ inline fun ChatMember.asSpecialRightsChatMember(): SpecialRightsChatMember? = th
inline fun ChatMember.requireSpecialRightsChatMember(): SpecialRightsChatMember = this as SpecialRightsChatMember inline fun ChatMember.requireSpecialRightsChatMember(): SpecialRightsChatMember = this as SpecialRightsChatMember
@PreviewFeature @PreviewFeature
inline fun <T> TelegramMedia.whenAudioMediaGroupMemberTelegramMedia(block: (AudioMediaGroupMemberTelegramMedia) -> T) = inline fun <T> TelegramFreeMedia.whenAudioMediaGroupMemberTelegramMedia(block: (AudioMediaGroupMemberTelegramMedia) -> T) =
asAudioMediaGroupMemberTelegramMedia()?.let(block) asAudioMediaGroupMemberTelegramMedia()?.let(block)
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.asAudioMediaGroupMemberTelegramMedia(): AudioMediaGroupMemberTelegramMedia? = inline fun TelegramFreeMedia.asAudioMediaGroupMemberTelegramMedia(): AudioMediaGroupMemberTelegramMedia? =
this as? AudioMediaGroupMemberTelegramMedia this as? AudioMediaGroupMemberTelegramMedia
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.requireAudioMediaGroupMemberTelegramMedia(): AudioMediaGroupMemberTelegramMedia = inline fun TelegramFreeMedia.requireAudioMediaGroupMemberTelegramMedia(): AudioMediaGroupMemberTelegramMedia =
this as AudioMediaGroupMemberTelegramMedia this as AudioMediaGroupMemberTelegramMedia
@PreviewFeature @PreviewFeature
inline fun <T> TelegramMedia.whenDocumentMediaGroupMemberTelegramMedia(block: (DocumentMediaGroupMemberTelegramMedia) -> T) = inline fun <T> TelegramFreeMedia.whenDocumentMediaGroupMemberTelegramMedia(block: (DocumentMediaGroupMemberTelegramMedia) -> T) =
asDocumentMediaGroupMemberTelegramMedia()?.let(block) asDocumentMediaGroupMemberTelegramMedia()?.let(block)
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.asDocumentMediaGroupMemberTelegramMedia(): DocumentMediaGroupMemberTelegramMedia? = inline fun TelegramFreeMedia.asDocumentMediaGroupMemberTelegramMedia(): DocumentMediaGroupMemberTelegramMedia? =
this as? DocumentMediaGroupMemberTelegramMedia this as? DocumentMediaGroupMemberTelegramMedia
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.requireDocumentMediaGroupMemberTelegramMedia(): DocumentMediaGroupMemberTelegramMedia = inline fun TelegramFreeMedia.requireDocumentMediaGroupMemberTelegramMedia(): DocumentMediaGroupMemberTelegramMedia =
this as DocumentMediaGroupMemberTelegramMedia this as DocumentMediaGroupMemberTelegramMedia
@PreviewFeature @PreviewFeature
inline fun <T> TelegramMedia.whenDuratedTelegramMedia(block: (DuratedTelegramMedia) -> T) = inline fun <T> TelegramFreeMedia.whenDuratedTelegramMedia(block: (DuratedTelegramMedia) -> T) =
asDuratedTelegramMedia()?.let(block) asDuratedTelegramMedia()?.let(block)
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.asDuratedTelegramMedia(): DuratedTelegramMedia? = this as? DuratedTelegramMedia inline fun TelegramFreeMedia.asDuratedTelegramMedia(): DuratedTelegramMedia? = this as? DuratedTelegramMedia
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.requireDuratedTelegramMedia(): DuratedTelegramMedia = this as DuratedTelegramMedia inline fun TelegramFreeMedia.requireDuratedTelegramMedia(): DuratedTelegramMedia = this as DuratedTelegramMedia
@PreviewFeature @PreviewFeature
inline fun <T> TelegramMedia.whenTelegramMediaAnimation(block: (TelegramMediaAnimation) -> T) = inline fun <T> TelegramFreeMedia.whenTelegramMediaAnimation(block: (TelegramMediaAnimation) -> T) =
asTelegramMediaAnimation()?.let(block) asTelegramMediaAnimation()?.let(block)
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.asTelegramMediaAnimation(): TelegramMediaAnimation? = this as? TelegramMediaAnimation inline fun TelegramFreeMedia.asTelegramMediaAnimation(): TelegramMediaAnimation? = this as? TelegramMediaAnimation
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.requireTelegramMediaAnimation(): TelegramMediaAnimation = this as TelegramMediaAnimation inline fun TelegramFreeMedia.requireTelegramMediaAnimation(): TelegramMediaAnimation = this as TelegramMediaAnimation
@PreviewFeature @PreviewFeature
inline fun <T> TelegramMedia.whenTelegramMediaAudio(block: (TelegramMediaAudio) -> T) = inline fun <T> TelegramFreeMedia.whenTelegramMediaAudio(block: (TelegramMediaAudio) -> T) =
asTelegramMediaAudio()?.let(block) asTelegramMediaAudio()?.let(block)
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.asTelegramMediaAudio(): TelegramMediaAudio? = this as? TelegramMediaAudio inline fun TelegramFreeMedia.asTelegramMediaAudio(): TelegramMediaAudio? = this as? TelegramMediaAudio
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.requireTelegramMediaAudio(): TelegramMediaAudio = this as TelegramMediaAudio inline fun TelegramFreeMedia.requireTelegramMediaAudio(): TelegramMediaAudio = this as TelegramMediaAudio
@PreviewFeature @PreviewFeature
inline fun <T> TelegramMedia.whenTelegramMediaDocument(block: (TelegramMediaDocument) -> T) = inline fun <T> TelegramFreeMedia.whenTelegramMediaDocument(block: (TelegramMediaDocument) -> T) =
asTelegramMediaDocument()?.let(block) asTelegramMediaDocument()?.let(block)
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.asTelegramMediaDocument(): TelegramMediaDocument? = this as? TelegramMediaDocument inline fun TelegramFreeMedia.asTelegramMediaDocument(): TelegramMediaDocument? = this as? TelegramMediaDocument
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.requireTelegramMediaDocument(): TelegramMediaDocument = this as TelegramMediaDocument inline fun TelegramFreeMedia.requireTelegramMediaDocument(): TelegramMediaDocument = this as TelegramMediaDocument
@PreviewFeature @PreviewFeature
inline fun <T> TelegramMedia.whenTelegramMediaPhoto(block: (TelegramMediaPhoto) -> T) = inline fun <T> TelegramFreeMedia.whenTelegramMediaPhoto(block: (TelegramMediaPhoto) -> T) =
asTelegramMediaPhoto()?.let(block) asTelegramMediaPhoto()?.let(block)
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.asTelegramMediaPhoto(): TelegramMediaPhoto? = this as? TelegramMediaPhoto inline fun TelegramFreeMedia.asTelegramMediaPhoto(): TelegramMediaPhoto? = this as? TelegramMediaPhoto
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.requireTelegramMediaPhoto(): TelegramMediaPhoto = this as TelegramMediaPhoto inline fun TelegramFreeMedia.requireTelegramMediaPhoto(): TelegramMediaPhoto = this as TelegramMediaPhoto
@PreviewFeature @PreviewFeature
inline fun <T> TelegramMedia.whenTelegramMediaVideo(block: (TelegramMediaVideo) -> T) = inline fun <T> TelegramFreeMedia.whenTelegramMediaVideo(block: (TelegramMediaVideo) -> T) =
asTelegramMediaVideo()?.let(block) asTelegramMediaVideo()?.let(block)
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.asTelegramMediaVideo(): TelegramMediaVideo? = this as? TelegramMediaVideo inline fun TelegramFreeMedia.asTelegramMediaVideo(): TelegramMediaVideo? = this as? TelegramMediaVideo
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.requireTelegramMediaVideo(): TelegramMediaVideo = this as TelegramMediaVideo inline fun TelegramFreeMedia.requireTelegramMediaVideo(): TelegramMediaVideo = this as TelegramMediaVideo
@PreviewFeature @PreviewFeature
inline fun <T> TelegramMedia.whenMediaGroupMemberTelegramMedia(block: (MediaGroupMemberTelegramMedia) -> T) = inline fun <T> TelegramFreeMedia.whenMediaGroupMemberTelegramMedia(block: (MediaGroupMemberTelegramMedia) -> T) =
asMediaGroupMemberTelegramMedia()?.let(block) asMediaGroupMemberTelegramMedia()?.let(block)
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.asMediaGroupMemberTelegramMedia(): MediaGroupMemberTelegramMedia? = inline fun TelegramFreeMedia.asMediaGroupMemberTelegramMedia(): MediaGroupMemberTelegramMedia? =
this as? MediaGroupMemberTelegramMedia this as? MediaGroupMemberTelegramMedia
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.requireMediaGroupMemberTelegramMedia(): MediaGroupMemberTelegramMedia = inline fun TelegramFreeMedia.requireMediaGroupMemberTelegramMedia(): MediaGroupMemberTelegramMedia =
this as MediaGroupMemberTelegramMedia this as MediaGroupMemberTelegramMedia
@PreviewFeature @PreviewFeature
inline fun <T> TelegramMedia.whenSizedTelegramMedia(block: (SizedTelegramMedia) -> T) = inline fun <T> TelegramFreeMedia.whenSizedTelegramMedia(block: (SizedTelegramMedia) -> T) =
asSizedTelegramMedia()?.let(block) asSizedTelegramMedia()?.let(block)
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.asSizedTelegramMedia(): SizedTelegramMedia? = this as? SizedTelegramMedia inline fun TelegramFreeMedia.asSizedTelegramMedia(): SizedTelegramMedia? = this as? SizedTelegramMedia
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.requireSizedTelegramMedia(): SizedTelegramMedia = this as SizedTelegramMedia inline fun TelegramFreeMedia.requireSizedTelegramMedia(): SizedTelegramMedia = this as SizedTelegramMedia
@PreviewFeature @PreviewFeature
inline fun <T> TelegramMedia.whenThumbedTelegramMedia(block: (ThumbedTelegramMedia) -> T) = inline fun <T> TelegramFreeMedia.whenThumbedTelegramMedia(block: (ThumbedTelegramMedia) -> T) =
asThumbedTelegramMedia()?.let(block) asThumbedTelegramMedia()?.let(block)
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.asThumbedTelegramMedia(): ThumbedTelegramMedia? = this as? ThumbedTelegramMedia inline fun TelegramFreeMedia.asThumbedTelegramMedia(): ThumbedTelegramMedia? = this as? ThumbedTelegramMedia
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.requireThumbedTelegramMedia(): ThumbedTelegramMedia = this as ThumbedTelegramMedia inline fun TelegramFreeMedia.requireThumbedTelegramMedia(): ThumbedTelegramMedia = this as ThumbedTelegramMedia
@PreviewFeature @PreviewFeature
inline fun <T> TelegramMedia.whenTitledTelegramMedia(block: (TitledTelegramMedia) -> T) = inline fun <T> TelegramFreeMedia.whenTitledTelegramMedia(block: (TitledTelegramMedia) -> T) =
asTitledTelegramMedia()?.let(block) asTitledTelegramMedia()?.let(block)
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.asTitledTelegramMedia(): TitledTelegramMedia? = this as? TitledTelegramMedia inline fun TelegramFreeMedia.asTitledTelegramMedia(): TitledTelegramMedia? = this as? TitledTelegramMedia
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.requireTitledTelegramMedia(): TitledTelegramMedia = this as TitledTelegramMedia inline fun TelegramFreeMedia.requireTitledTelegramMedia(): TitledTelegramMedia = this as TitledTelegramMedia
@PreviewFeature @PreviewFeature
inline fun <T> TelegramMedia.whenVisualMediaGroupMemberTelegramMedia(block: (VisualMediaGroupMemberTelegramMedia) -> T) = inline fun <T> TelegramFreeMedia.whenVisualMediaGroupMemberTelegramMedia(block: (VisualMediaGroupMemberTelegramMedia) -> T) =
asVisualMediaGroupMemberTelegramMedia()?.let(block) asVisualMediaGroupMemberTelegramMedia()?.let(block)
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.asVisualMediaGroupMemberTelegramMedia(): VisualMediaGroupMemberTelegramMedia? = inline fun TelegramFreeMedia.asVisualMediaGroupMemberTelegramMedia(): VisualMediaGroupMemberTelegramMedia? =
this as? VisualMediaGroupMemberTelegramMedia this as? VisualMediaGroupMemberTelegramMedia
@PreviewFeature @PreviewFeature
inline fun TelegramMedia.requireVisualMediaGroupMemberTelegramMedia(): VisualMediaGroupMemberTelegramMedia = inline fun TelegramFreeMedia.requireVisualMediaGroupMemberTelegramMedia(): VisualMediaGroupMemberTelegramMedia =
this as VisualMediaGroupMemberTelegramMedia this as VisualMediaGroupMemberTelegramMedia
@PreviewFeature @PreviewFeature

View File

@ -220,7 +220,7 @@ import dev.inmo.tgbotapi.types.media.DuratedTelegramMedia
import dev.inmo.tgbotapi.types.media.MediaGroupMemberTelegramMedia import dev.inmo.tgbotapi.types.media.MediaGroupMemberTelegramMedia
import dev.inmo.tgbotapi.types.media.SizedTelegramMedia import dev.inmo.tgbotapi.types.media.SizedTelegramMedia
import dev.inmo.tgbotapi.types.media.SpoilerableTelegramMedia import dev.inmo.tgbotapi.types.media.SpoilerableTelegramMedia
import dev.inmo.tgbotapi.types.media.TelegramMedia import dev.inmo.tgbotapi.types.media.TelegramFreeMedia
import dev.inmo.tgbotapi.types.media.TelegramMediaAnimation import dev.inmo.tgbotapi.types.media.TelegramMediaAnimation
import dev.inmo.tgbotapi.types.media.TelegramMediaAudio import dev.inmo.tgbotapi.types.media.TelegramMediaAudio
import dev.inmo.tgbotapi.types.media.TelegramMediaDocument import dev.inmo.tgbotapi.types.media.TelegramMediaDocument
@ -2945,155 +2945,155 @@ public inline fun Location.liveLocationOrThrow(): LiveLocation = this as
public inline fun <T> Location.ifLiveLocation(block: (LiveLocation) -> T): T? = liveLocationOrNull() public inline fun <T> Location.ifLiveLocation(block: (LiveLocation) -> T): T? = liveLocationOrNull()
?.let(block) ?.let(block)
public inline fun TelegramMedia.duratedTelegramMediaOrNull(): DuratedTelegramMedia? = this as? public inline fun TelegramFreeMedia.duratedTelegramMediaOrNull(): DuratedTelegramMedia? = this as?
dev.inmo.tgbotapi.types.media.DuratedTelegramMedia dev.inmo.tgbotapi.types.media.DuratedTelegramMedia
public inline fun TelegramMedia.duratedTelegramMediaOrThrow(): DuratedTelegramMedia = this as public inline fun TelegramFreeMedia.duratedTelegramMediaOrThrow(): DuratedTelegramMedia = this as
dev.inmo.tgbotapi.types.media.DuratedTelegramMedia dev.inmo.tgbotapi.types.media.DuratedTelegramMedia
public inline fun <T> TelegramMedia.ifDuratedTelegramMedia(block: (DuratedTelegramMedia) -> T): T? = public inline fun <T> TelegramFreeMedia.ifDuratedTelegramMedia(block: (DuratedTelegramMedia) -> T): T? =
duratedTelegramMediaOrNull() ?.let(block) duratedTelegramMediaOrNull() ?.let(block)
public inline fun TelegramMedia.mediaGroupMemberTelegramMediaOrNull(): public inline fun TelegramFreeMedia.mediaGroupMemberTelegramMediaOrNull():
MediaGroupMemberTelegramMedia? = this as? MediaGroupMemberTelegramMedia? = this as?
dev.inmo.tgbotapi.types.media.MediaGroupMemberTelegramMedia dev.inmo.tgbotapi.types.media.MediaGroupMemberTelegramMedia
public inline fun TelegramMedia.mediaGroupMemberTelegramMediaOrThrow(): public inline fun TelegramFreeMedia.mediaGroupMemberTelegramMediaOrThrow():
MediaGroupMemberTelegramMedia = this as MediaGroupMemberTelegramMedia = this as
dev.inmo.tgbotapi.types.media.MediaGroupMemberTelegramMedia dev.inmo.tgbotapi.types.media.MediaGroupMemberTelegramMedia
public inline fun <T> public inline fun <T>
TelegramMedia.ifMediaGroupMemberTelegramMedia(block: (MediaGroupMemberTelegramMedia) -> T): T? = TelegramFreeMedia.ifMediaGroupMemberTelegramMedia(block: (MediaGroupMemberTelegramMedia) -> T): T? =
mediaGroupMemberTelegramMediaOrNull() ?.let(block) mediaGroupMemberTelegramMediaOrNull() ?.let(block)
public inline fun TelegramMedia.audioMediaGroupMemberTelegramMediaOrNull(): public inline fun TelegramFreeMedia.audioMediaGroupMemberTelegramMediaOrNull():
AudioMediaGroupMemberTelegramMedia? = this as? AudioMediaGroupMemberTelegramMedia? = this as?
dev.inmo.tgbotapi.types.media.AudioMediaGroupMemberTelegramMedia dev.inmo.tgbotapi.types.media.AudioMediaGroupMemberTelegramMedia
public inline fun TelegramMedia.audioMediaGroupMemberTelegramMediaOrThrow(): public inline fun TelegramFreeMedia.audioMediaGroupMemberTelegramMediaOrThrow():
AudioMediaGroupMemberTelegramMedia = this as AudioMediaGroupMemberTelegramMedia = this as
dev.inmo.tgbotapi.types.media.AudioMediaGroupMemberTelegramMedia dev.inmo.tgbotapi.types.media.AudioMediaGroupMemberTelegramMedia
public inline fun <T> public inline fun <T>
TelegramMedia.ifAudioMediaGroupMemberTelegramMedia(block: (AudioMediaGroupMemberTelegramMedia) -> T): TelegramFreeMedia.ifAudioMediaGroupMemberTelegramMedia(block: (AudioMediaGroupMemberTelegramMedia) -> T):
T? = audioMediaGroupMemberTelegramMediaOrNull() ?.let(block) T? = audioMediaGroupMemberTelegramMediaOrNull() ?.let(block)
public inline fun TelegramMedia.documentMediaGroupMemberTelegramMediaOrNull(): public inline fun TelegramFreeMedia.documentMediaGroupMemberTelegramMediaOrNull():
DocumentMediaGroupMemberTelegramMedia? = this as? DocumentMediaGroupMemberTelegramMedia? = this as?
dev.inmo.tgbotapi.types.media.DocumentMediaGroupMemberTelegramMedia dev.inmo.tgbotapi.types.media.DocumentMediaGroupMemberTelegramMedia
public inline fun TelegramMedia.documentMediaGroupMemberTelegramMediaOrThrow(): public inline fun TelegramFreeMedia.documentMediaGroupMemberTelegramMediaOrThrow():
DocumentMediaGroupMemberTelegramMedia = this as DocumentMediaGroupMemberTelegramMedia = this as
dev.inmo.tgbotapi.types.media.DocumentMediaGroupMemberTelegramMedia dev.inmo.tgbotapi.types.media.DocumentMediaGroupMemberTelegramMedia
public inline fun <T> public inline fun <T>
TelegramMedia.ifDocumentMediaGroupMemberTelegramMedia(block: (DocumentMediaGroupMemberTelegramMedia) -> T): TelegramFreeMedia.ifDocumentMediaGroupMemberTelegramMedia(block: (DocumentMediaGroupMemberTelegramMedia) -> T):
T? = documentMediaGroupMemberTelegramMediaOrNull() ?.let(block) T? = documentMediaGroupMemberTelegramMediaOrNull() ?.let(block)
public inline fun TelegramMedia.visualMediaGroupMemberTelegramMediaOrNull(): public inline fun TelegramFreeMedia.visualMediaGroupMemberTelegramMediaOrNull():
VisualMediaGroupMemberTelegramMedia? = this as? VisualMediaGroupMemberTelegramMedia? = this as?
dev.inmo.tgbotapi.types.media.VisualMediaGroupMemberTelegramMedia dev.inmo.tgbotapi.types.media.VisualMediaGroupMemberTelegramMedia
public inline fun TelegramMedia.visualMediaGroupMemberTelegramMediaOrThrow(): public inline fun TelegramFreeMedia.visualMediaGroupMemberTelegramMediaOrThrow():
VisualMediaGroupMemberTelegramMedia = this as VisualMediaGroupMemberTelegramMedia = this as
dev.inmo.tgbotapi.types.media.VisualMediaGroupMemberTelegramMedia dev.inmo.tgbotapi.types.media.VisualMediaGroupMemberTelegramMedia
public inline fun <T> public inline fun <T>
TelegramMedia.ifVisualMediaGroupMemberTelegramMedia(block: (VisualMediaGroupMemberTelegramMedia) -> T): TelegramFreeMedia.ifVisualMediaGroupMemberTelegramMedia(block: (VisualMediaGroupMemberTelegramMedia) -> T):
T? = visualMediaGroupMemberTelegramMediaOrNull() ?.let(block) T? = visualMediaGroupMemberTelegramMediaOrNull() ?.let(block)
public inline fun TelegramMedia.sizedTelegramMediaOrNull(): SizedTelegramMedia? = this as? public inline fun TelegramFreeMedia.sizedTelegramMediaOrNull(): SizedTelegramMedia? = this as?
dev.inmo.tgbotapi.types.media.SizedTelegramMedia dev.inmo.tgbotapi.types.media.SizedTelegramMedia
public inline fun TelegramMedia.sizedTelegramMediaOrThrow(): SizedTelegramMedia = this as public inline fun TelegramFreeMedia.sizedTelegramMediaOrThrow(): SizedTelegramMedia = this as
dev.inmo.tgbotapi.types.media.SizedTelegramMedia dev.inmo.tgbotapi.types.media.SizedTelegramMedia
public inline fun <T> TelegramMedia.ifSizedTelegramMedia(block: (SizedTelegramMedia) -> T): T? = public inline fun <T> TelegramFreeMedia.ifSizedTelegramMedia(block: (SizedTelegramMedia) -> T): T? =
sizedTelegramMediaOrNull() ?.let(block) sizedTelegramMediaOrNull() ?.let(block)
public inline fun TelegramMedia.spoilerableTelegramMediaOrNull(): SpoilerableTelegramMedia? = this public inline fun TelegramFreeMedia.spoilerableTelegramMediaOrNull(): SpoilerableTelegramMedia? = this
as? dev.inmo.tgbotapi.types.media.SpoilerableTelegramMedia as? dev.inmo.tgbotapi.types.media.SpoilerableTelegramMedia
public inline fun TelegramMedia.spoilerableTelegramMediaOrThrow(): SpoilerableTelegramMedia = this public inline fun TelegramFreeMedia.spoilerableTelegramMediaOrThrow(): SpoilerableTelegramMedia = this
as dev.inmo.tgbotapi.types.media.SpoilerableTelegramMedia as dev.inmo.tgbotapi.types.media.SpoilerableTelegramMedia
public inline fun <T> public inline fun <T>
TelegramMedia.ifSpoilerableTelegramMedia(block: (SpoilerableTelegramMedia) -> T): T? = TelegramFreeMedia.ifSpoilerableTelegramMedia(block: (SpoilerableTelegramMedia) -> T): T? =
spoilerableTelegramMediaOrNull() ?.let(block) spoilerableTelegramMediaOrNull() ?.let(block)
public inline fun TelegramMedia.telegramMediaAnimationOrNull(): TelegramMediaAnimation? = this as? public inline fun TelegramFreeMedia.telegramMediaAnimationOrNull(): TelegramMediaAnimation? = this as?
dev.inmo.tgbotapi.types.media.TelegramMediaAnimation dev.inmo.tgbotapi.types.media.TelegramMediaAnimation
public inline fun TelegramMedia.telegramMediaAnimationOrThrow(): TelegramMediaAnimation = this as public inline fun TelegramFreeMedia.telegramMediaAnimationOrThrow(): TelegramMediaAnimation = this as
dev.inmo.tgbotapi.types.media.TelegramMediaAnimation dev.inmo.tgbotapi.types.media.TelegramMediaAnimation
public inline fun <T> TelegramMedia.ifTelegramMediaAnimation(block: (TelegramMediaAnimation) -> T): public inline fun <T> TelegramFreeMedia.ifTelegramMediaAnimation(block: (TelegramMediaAnimation) -> T):
T? = telegramMediaAnimationOrNull() ?.let(block) T? = telegramMediaAnimationOrNull() ?.let(block)
public inline fun TelegramMedia.telegramMediaAudioOrNull(): TelegramMediaAudio? = this as? public inline fun TelegramFreeMedia.telegramMediaAudioOrNull(): TelegramMediaAudio? = this as?
dev.inmo.tgbotapi.types.media.TelegramMediaAudio dev.inmo.tgbotapi.types.media.TelegramMediaAudio
public inline fun TelegramMedia.telegramMediaAudioOrThrow(): TelegramMediaAudio = this as public inline fun TelegramFreeMedia.telegramMediaAudioOrThrow(): TelegramMediaAudio = this as
dev.inmo.tgbotapi.types.media.TelegramMediaAudio dev.inmo.tgbotapi.types.media.TelegramMediaAudio
public inline fun <T> TelegramMedia.ifTelegramMediaAudio(block: (TelegramMediaAudio) -> T): T? = public inline fun <T> TelegramFreeMedia.ifTelegramMediaAudio(block: (TelegramMediaAudio) -> T): T? =
telegramMediaAudioOrNull() ?.let(block) telegramMediaAudioOrNull() ?.let(block)
public inline fun TelegramMedia.telegramMediaDocumentOrNull(): TelegramMediaDocument? = this as? public inline fun TelegramFreeMedia.telegramMediaDocumentOrNull(): TelegramMediaDocument? = this as?
dev.inmo.tgbotapi.types.media.TelegramMediaDocument dev.inmo.tgbotapi.types.media.TelegramMediaDocument
public inline fun TelegramMedia.telegramMediaDocumentOrThrow(): TelegramMediaDocument = this as public inline fun TelegramFreeMedia.telegramMediaDocumentOrThrow(): TelegramMediaDocument = this as
dev.inmo.tgbotapi.types.media.TelegramMediaDocument dev.inmo.tgbotapi.types.media.TelegramMediaDocument
public inline fun <T> TelegramMedia.ifTelegramMediaDocument(block: (TelegramMediaDocument) -> T): T? public inline fun <T> TelegramFreeMedia.ifTelegramMediaDocument(block: (TelegramMediaDocument) -> T): T?
= telegramMediaDocumentOrNull() ?.let(block) = telegramMediaDocumentOrNull() ?.let(block)
public inline fun TelegramMedia.telegramMediaPhotoOrNull(): TelegramMediaPhoto? = this as? public inline fun TelegramFreeMedia.telegramMediaPhotoOrNull(): TelegramMediaPhoto? = this as?
dev.inmo.tgbotapi.types.media.TelegramMediaPhoto dev.inmo.tgbotapi.types.media.TelegramMediaPhoto
public inline fun TelegramMedia.telegramMediaPhotoOrThrow(): TelegramMediaPhoto = this as public inline fun TelegramFreeMedia.telegramMediaPhotoOrThrow(): TelegramMediaPhoto = this as
dev.inmo.tgbotapi.types.media.TelegramMediaPhoto dev.inmo.tgbotapi.types.media.TelegramMediaPhoto
public inline fun <T> TelegramMedia.ifTelegramMediaPhoto(block: (TelegramMediaPhoto) -> T): T? = public inline fun <T> TelegramFreeMedia.ifTelegramMediaPhoto(block: (TelegramMediaPhoto) -> T): T? =
telegramMediaPhotoOrNull() ?.let(block) telegramMediaPhotoOrNull() ?.let(block)
public inline fun TelegramMedia.telegramMediaVideoOrNull(): TelegramMediaVideo? = this as? public inline fun TelegramFreeMedia.telegramMediaVideoOrNull(): TelegramMediaVideo? = this as?
dev.inmo.tgbotapi.types.media.TelegramMediaVideo dev.inmo.tgbotapi.types.media.TelegramMediaVideo
public inline fun TelegramMedia.telegramMediaVideoOrThrow(): TelegramMediaVideo = this as public inline fun TelegramFreeMedia.telegramMediaVideoOrThrow(): TelegramMediaVideo = this as
dev.inmo.tgbotapi.types.media.TelegramMediaVideo dev.inmo.tgbotapi.types.media.TelegramMediaVideo
public inline fun <T> TelegramMedia.ifTelegramMediaVideo(block: (TelegramMediaVideo) -> T): T? = public inline fun <T> TelegramFreeMedia.ifTelegramMediaVideo(block: (TelegramMediaVideo) -> T): T? =
telegramMediaVideoOrNull() ?.let(block) telegramMediaVideoOrNull() ?.let(block)
public inline fun TelegramMedia.thumbedTelegramMediaOrNull(): ThumbedTelegramMedia? = this as? public inline fun TelegramFreeMedia.thumbedTelegramMediaOrNull(): ThumbedTelegramMedia? = this as?
dev.inmo.tgbotapi.types.media.ThumbedTelegramMedia dev.inmo.tgbotapi.types.media.ThumbedTelegramMedia
public inline fun TelegramMedia.thumbedTelegramMediaOrThrow(): ThumbedTelegramMedia = this as public inline fun TelegramFreeMedia.thumbedTelegramMediaOrThrow(): ThumbedTelegramMedia = this as
dev.inmo.tgbotapi.types.media.ThumbedTelegramMedia dev.inmo.tgbotapi.types.media.ThumbedTelegramMedia
public inline fun <T> TelegramMedia.ifThumbedTelegramMedia(block: (ThumbedTelegramMedia) -> T): T? = public inline fun <T> TelegramFreeMedia.ifThumbedTelegramMedia(block: (ThumbedTelegramMedia) -> T): T? =
thumbedTelegramMediaOrNull() ?.let(block) thumbedTelegramMediaOrNull() ?.let(block)
public inline fun TelegramMedia.titledTelegramMediaOrNull(): TitledTelegramMedia? = this as? public inline fun TelegramFreeMedia.titledTelegramMediaOrNull(): TitledTelegramMedia? = this as?
dev.inmo.tgbotapi.types.media.TitledTelegramMedia dev.inmo.tgbotapi.types.media.TitledTelegramMedia
public inline fun TelegramMedia.titledTelegramMediaOrThrow(): TitledTelegramMedia = this as public inline fun TelegramFreeMedia.titledTelegramMediaOrThrow(): TitledTelegramMedia = this as
dev.inmo.tgbotapi.types.media.TitledTelegramMedia dev.inmo.tgbotapi.types.media.TitledTelegramMedia
public inline fun <T> TelegramMedia.ifTitledTelegramMedia(block: (TitledTelegramMedia) -> T): T? = public inline fun <T> TelegramFreeMedia.ifTitledTelegramMedia(block: (TitledTelegramMedia) -> T): T? =
titledTelegramMediaOrNull() ?.let(block) titledTelegramMediaOrNull() ?.let(block)
public inline fun TelegramMedia.withCustomizableCaptionTelegramMediaOrNull(): public inline fun TelegramFreeMedia.withCustomizableCaptionTelegramMediaOrNull():
WithCustomizableCaptionTelegramMedia? = this as? WithCustomizableCaptionTelegramMedia? = this as?
dev.inmo.tgbotapi.types.media.WithCustomizableCaptionTelegramMedia dev.inmo.tgbotapi.types.media.WithCustomizableCaptionTelegramMedia
public inline fun TelegramMedia.withCustomizableCaptionTelegramMediaOrThrow(): public inline fun TelegramFreeMedia.withCustomizableCaptionTelegramMediaOrThrow():
WithCustomizableCaptionTelegramMedia = this as WithCustomizableCaptionTelegramMedia = this as
dev.inmo.tgbotapi.types.media.WithCustomizableCaptionTelegramMedia dev.inmo.tgbotapi.types.media.WithCustomizableCaptionTelegramMedia
public inline fun <T> public inline fun <T>
TelegramMedia.ifWithCustomizableCaptionTelegramMedia(block: (WithCustomizableCaptionTelegramMedia) -> T): TelegramFreeMedia.ifWithCustomizableCaptionTelegramMedia(block: (WithCustomizableCaptionTelegramMedia) -> T):
T? = withCustomizableCaptionTelegramMediaOrNull() ?.let(block) T? = withCustomizableCaptionTelegramMediaOrNull() ?.let(block)
public inline fun ChatEvent.chatBackgroundOrNull(): ChatBackground? = this as? public inline fun ChatEvent.chatBackgroundOrNull(): ChatBackground? = this as?