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

progress on addinf of paid media

This commit is contained in:
InsanusMokrassar 2024-07-08 02:51:09 +06:00
parent 1eef5bb239
commit 00aefefc31
22 changed files with 89 additions and 56 deletions

View File

@ -855,7 +855,7 @@ suspend inline fun TelegramBot.replyWithPhoto(
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: AccessibleMessage, to: AccessibleMessage,
photo: Photo, photo: PhotoFile,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
showCaptionAboveMedia: Boolean = false, showCaptionAboveMedia: Boolean = false,
@ -947,7 +947,7 @@ suspend inline fun TelegramBot.replyWithPhoto(
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: AccessibleMessage, to: AccessibleMessage,
photo: Photo, photo: PhotoFile,
entities: TextSourcesList, entities: TextSourcesList,
showCaptionAboveMedia: Boolean = false, showCaptionAboveMedia: Boolean = false,
spoilered: Boolean = false, spoilered: Boolean = false,

View File

@ -806,7 +806,7 @@ suspend inline fun TelegramBot.replyWithPhoto(
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: IdChatIdentifier, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
photo: Photo, photo: PhotoFile,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
showCaptionAboveMedia: Boolean = false, showCaptionAboveMedia: Boolean = false,
@ -860,7 +860,7 @@ suspend inline fun TelegramBot.replyWithPhoto(
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: IdChatIdentifier, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
photo: Photo, photo: PhotoFile,
entities: TextSourcesList, entities: TextSourcesList,
showCaptionAboveMedia: Boolean = false, showCaptionAboveMedia: Boolean = false,
spoilered: Boolean = false, spoilered: Boolean = false,

View File

@ -726,7 +726,7 @@ suspend fun TelegramBot.send(
*/ */
suspend fun TelegramBot.send( suspend fun TelegramBot.send(
chatId: ChatIdentifier, chatId: ChatIdentifier,
photo: Photo, photo: PhotoFile,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
showCaptionAboveMedia: Boolean = false, showCaptionAboveMedia: Boolean = false,
@ -747,7 +747,7 @@ suspend fun TelegramBot.send(
*/ */
suspend fun TelegramBot.send( suspend fun TelegramBot.send(
chat: Chat, chat: Chat,
photo: Photo, photo: PhotoFile,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
showCaptionAboveMedia: Boolean = false, showCaptionAboveMedia: Boolean = false,
@ -810,7 +810,7 @@ suspend fun TelegramBot.send(
*/ */
suspend inline fun TelegramBot.send( suspend inline fun TelegramBot.send(
chatId: ChatIdentifier, chatId: ChatIdentifier,
photo: Photo, photo: PhotoFile,
entities: TextSourcesList, entities: TextSourcesList,
showCaptionAboveMedia: Boolean = false, showCaptionAboveMedia: Boolean = false,
spoilered: Boolean = false, spoilered: Boolean = false,
@ -830,7 +830,7 @@ suspend inline fun TelegramBot.send(
*/ */
suspend inline fun TelegramBot.send( suspend inline fun TelegramBot.send(
chat: Chat, chat: Chat,
photo: Photo, photo: PhotoFile,
entities: TextSourcesList, entities: TextSourcesList,
showCaptionAboveMedia: Boolean = false, showCaptionAboveMedia: Boolean = false,
spoilered: Boolean = false, spoilered: Boolean = false,

View File

@ -87,7 +87,7 @@ suspend fun TelegramBot.sendPhoto(
*/ */
suspend fun TelegramBot.sendPhoto( suspend fun TelegramBot.sendPhoto(
chatId: ChatIdentifier, chatId: ChatIdentifier,
photo: Photo, photo: PhotoFile,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
showCaptionAboveMedia: Boolean = false, showCaptionAboveMedia: Boolean = false,
@ -121,7 +121,7 @@ suspend fun TelegramBot.sendPhoto(
*/ */
suspend fun TelegramBot.sendPhoto( suspend fun TelegramBot.sendPhoto(
chat: Chat, chat: Chat,
photo: Photo, photo: PhotoFile,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
showCaptionAboveMedia: Boolean = false, showCaptionAboveMedia: Boolean = false,
@ -290,7 +290,7 @@ suspend inline fun TelegramBot.sendPhoto(
*/ */
suspend inline fun TelegramBot.sendPhoto( suspend inline fun TelegramBot.sendPhoto(
chatId: ChatIdentifier, chatId: ChatIdentifier,
photo: Photo, photo: PhotoFile,
entities: TextSourcesList, entities: TextSourcesList,
showCaptionAboveMedia: Boolean = false, showCaptionAboveMedia: Boolean = false,
spoilered: Boolean = false, spoilered: Boolean = false,
@ -322,7 +322,7 @@ suspend inline fun TelegramBot.sendPhoto(
*/ */
suspend inline fun TelegramBot.sendPhoto( suspend inline fun TelegramBot.sendPhoto(
chat: Chat, chat: Chat,
photo: Photo, photo: PhotoFile,
entities: TextSourcesList, entities: TextSourcesList,
showCaptionAboveMedia: Boolean = false, showCaptionAboveMedia: Boolean = false,
spoilered: Boolean = false, spoilered: Boolean = false,

View File

@ -606,6 +606,8 @@ const val additionalChatCountField = "additional_chat_count"
const val unclaimedPrizeCountField = "unclaimed_prize_count" const val unclaimedPrizeCountField = "unclaimed_prize_count"
const val wasRefundedField = "was_refunded" const val wasRefundedField = "was_refunded"
const val isManualField = "is_manual" const val isManualField = "is_manual"
const val starCountField = "star_count"
const val paidMediaField = "paid_media"
const val businessConnectionIdField = "business_connection_id" const val businessConnectionIdField = "business_connection_id"
const val businessIntroField = "business_intro" const val businessIntroField = "business_intro"

View File

@ -92,7 +92,7 @@ sealed interface ReplyInfo {
private val animation: AnimationFile? = null, private val animation: AnimationFile? = null,
private val game: RawGame? = null, private val game: RawGame? = null,
@Serializable(PhotoSerializer::class) @Serializable(PhotoSerializer::class)
private val photo: Photo? = null, private val photo: PhotoFile? = null,
private val sticker: Sticker? = null, private val sticker: Sticker? = null,
private val video: VideoFile? = null, private val video: VideoFile? = null,
private val voice: VoiceFile? = null, private val voice: VoiceFile? = null,

View File

@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.types package dev.inmo.tgbotapi.types
import dev.inmo.tgbotapi.types.files.Photo import dev.inmo.tgbotapi.types.files.PhotoFile
import dev.inmo.tgbotapi.types.files.PhotoSerializer import dev.inmo.tgbotapi.types.files.PhotoSerializer
import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.serialization.* import kotlinx.serialization.*
@ -11,10 +11,10 @@ data class UserProfilePhotos (
@SerialName("total_count") @SerialName("total_count")
val count: Int, val count: Int,
@Serializable(UserProfilePhotosPhotosSerializer::class) @Serializable(UserProfilePhotosPhotosSerializer::class)
val photos: List<Photo> val photos: List<PhotoFile>
) )
@RiskFeature @RiskFeature
object UserProfilePhotosPhotosSerializer : KSerializer<List<Photo>> by ListSerializer( object UserProfilePhotosPhotosSerializer : KSerializer<List<PhotoFile>> by ListSerializer(
PhotoSerializer PhotoSerializer
) )

View File

@ -0,0 +1,15 @@
package dev.inmo.tgbotapi.types.files
import dev.inmo.tgbotapi.types.message.payments.PaidMedia
import dev.inmo.tgbotapi.types.paidMediaField
import dev.inmo.tgbotapi.types.starCountField
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class PaidMediaInfo(
@SerialName(starCountField)
val stars: Int,
@SerialName(paidMediaField)
val media: List<PaidMedia>
)

View File

@ -8,7 +8,7 @@ import kotlin.jvm.JvmInline
@Serializable @Serializable
@JvmInline @JvmInline
value class Photo( value class PhotoFile(
val photos: List<PhotoSize> val photos: List<PhotoSize>
) : List<PhotoSize> by photos, MediaContentVariant, UsefulAsPaidMediaFile { ) : List<PhotoSize> by photos, MediaContentVariant, UsefulAsPaidMediaFile {
val biggest: PhotoSize val biggest: PhotoSize
@ -27,12 +27,14 @@ value class Photo(
} }
} }
fun Photo.biggest(): PhotoSize? = maxByOrNull { typealias Photo = PhotoFile
fun PhotoFile.biggest(): PhotoSize? = maxByOrNull {
it.resolution it.resolution
} }
@RiskFeature @RiskFeature
object PhotoSerializer : KSerializer<Photo> by Photo.serializer() object PhotoSerializer : KSerializer<PhotoFile> by PhotoFile.serializer()
@Serializable @Serializable
data class PhotoSize( data class PhotoSize(

View File

@ -5,14 +5,14 @@ import dev.inmo.tgbotapi.abstracts.Titled
import dev.inmo.tgbotapi.types.ReplyInfo import dev.inmo.tgbotapi.types.ReplyInfo
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.files.AnimationFile import dev.inmo.tgbotapi.types.files.AnimationFile
import dev.inmo.tgbotapi.types.files.Photo import dev.inmo.tgbotapi.types.files.PhotoFile
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@Serializable @Serializable
data class Game( data class Game(
override val title: String, override val title: String,
val description: String, val description: String,
val photo: Photo, val photo: PhotoFile,
override val text: String? = null, override val text: String? = null,
override val textSources: TextSourcesList = emptyList(), override val textSources: TextSourcesList = emptyList(),
val animation: AnimationFile? = null val animation: AnimationFile? = null

View File

@ -14,7 +14,7 @@ internal data class RawGame(
private val description: String, private val description: String,
@Serializable(PhotoSerializer::class) @Serializable(PhotoSerializer::class)
@SerialName(photoField) @SerialName(photoField)
private val photo: Photo, private val photo: PhotoFile,
@SerialName(textField) @SerialName(textField)
private val text: String? = null, private val text: String? = null,
@SerialName(textEntitiesField) @SerialName(textEntitiesField)

View File

@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile
import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend import dev.inmo.tgbotapi.requests.abstracts.fileIdToSend
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.VideoFile import dev.inmo.tgbotapi.types.files.VideoFile
import dev.inmo.tgbotapi.types.message.payments.PaidMedia
import kotlinx.serialization.* import kotlinx.serialization.*
internal const val videoTelegramPaidMediaType = "video" internal const val videoTelegramPaidMediaType = "video"

View File

@ -1,8 +1,8 @@
package dev.inmo.tgbotapi.types.message.ChatEvents package dev.inmo.tgbotapi.types.message.ChatEvents
import dev.inmo.tgbotapi.types.files.Photo import dev.inmo.tgbotapi.types.files.PhotoFile
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent
data class NewChatPhoto( data class NewChatPhoto(
val photo: Photo val photo: PhotoFile
): PublicChatEvent ): PublicChatEvent

View File

@ -71,10 +71,11 @@ internal data class RawMessage(
private val story: Story? = null, private val story: Story? = null,
private val audio: AudioFile? = null, private val audio: AudioFile? = null,
private val document: DocumentFile? = null, private val document: DocumentFile? = null,
private val paid_media: PaidMediaInfoContent? = null,
private val animation: AnimationFile? = null, private val animation: AnimationFile? = null,
private val game: RawGame? = null, private val game: RawGame? = null,
@Serializable(PhotoSerializer::class) @Serializable(PhotoSerializer::class)
private val photo: Photo? = null, private val photo: PhotoFile? = null,
private val sticker: Sticker? = null, private val sticker: Sticker? = null,
private val video: VideoFile? = null, private val video: VideoFile? = null,
private val voice: VoiceFile? = null, private val voice: VoiceFile? = null,
@ -87,7 +88,7 @@ internal data class RawMessage(
private val left_chat_member: User? = null, private val left_chat_member: User? = null,
private val new_chat_title: String? = null, private val new_chat_title: String? = null,
@Serializable(PhotoSerializer::class) @Serializable(PhotoSerializer::class)
private val new_chat_photo: Photo? = null, private val new_chat_photo: PhotoFile? = null,
private val delete_chat_photo: Boolean = false, private val delete_chat_photo: Boolean = false,
private val group_chat_created: Boolean = false, private val group_chat_created: Boolean = false,
private val supergroup_chat_created: Boolean = false, private val supergroup_chat_created: Boolean = false,
@ -198,6 +199,12 @@ internal data class RawMessage(
adaptedCaptionEntities, adaptedCaptionEntities,
quote quote
) )
paid_media != null -> PaidMediaInfoContent(
document,
caption,
adaptedCaptionEntities,
quote
)
voice != null -> VoiceContent( voice != null -> VoiceContent(
voice, voice,
caption, caption,

View File

@ -6,25 +6,27 @@ import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.files.* import dev.inmo.tgbotapi.types.files.*
import dev.inmo.tgbotapi.types.media.PaidMedia import dev.inmo.tgbotapi.types.files.toTelegramPaidMediaVideo
import dev.inmo.tgbotapi.types.media.TelegramPaidMedia import dev.inmo.tgbotapi.types.media.*
import dev.inmo.tgbotapi.types.media.toTelegramMediaPhoto
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.payments.PaidMedia
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@Serializable @Serializable
data class PaidMediaInfoContent( data class PaidMediaInfoContent(
override val mediaCollection: List<PaidMedia>, val paidMediaInfo: PaidMediaInfo,
override val text: String? = null, override val text: String? = null,
override val textSources: TextSourcesList = emptyList(), override val textSources: TextSourcesList = emptyList(),
override val quote: TextQuote? = null, override val quote: TextQuote? = null,
override val showCaptionAboveMedia: Boolean = false override val showCaptionAboveMedia: Boolean = false
) : MediaCollectionContent<UsefulAsPaidMediaFile>, TextedMediaContent, WithCustomizedCaptionMediaContent { ) : TextedMediaContent, WithCustomizedCaptionMediaContent {
override val media: UsefulAsPaidMediaFile override val media: TelegramMediaFile
get() = mediaCollection.first() get() = paidMediaInfo.media.fir
override fun asTelegramMedia(): TelegramPaidMedia = when (val media = media) { override fun asTelegramMedia(): TelegramMediaFile = when (val media = media) {
is VideoFile -> media.toTelegramPaidMediaVideo() is PaidMedia.Photo -> media.photo.biggest.toTelegramPaidMediaPhoto()
is Photo -> media.biggest.toTelegramMediaPhoto() is PaidMedia.Preview,
is PaidMedia.Unknown -> error("Unable to create telegram media out of $media")
is PaidMedia.Video -> media.video.toTelegramPaidMediaVideo()
} }
override fun createResend( override fun createResend(

View File

@ -15,7 +15,7 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class PhotoContent( data class PhotoContent(
override val mediaCollection: Photo, override val mediaCollection: PhotoFile,
override val text: String? = null, override val text: String? = null,
override val textSources: TextSourcesList = emptyList(), override val textSources: TextSourcesList = emptyList(),
override val spoilered: Boolean = false, override val spoilered: Boolean = false,

View File

@ -1,6 +1,8 @@
package dev.inmo.tgbotapi.types.media package dev.inmo.tgbotapi.types.message.payments
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.PhotoFile
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
import dev.inmo.tgbotapi.types.files.VideoFile 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
@ -13,7 +15,9 @@ 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 : TelegramMedia { sealed interface PaidMedia {
val type: String
@Serializable @Serializable
data class Preview( data class Preview(
@SerialName(widthField) @SerialName(widthField)
@ -35,7 +39,7 @@ sealed interface PaidMedia : TelegramMedia {
@Serializable @Serializable
data class Photo( data class Photo(
@SerialName(photoField) @SerialName(photoField)
val photo: Photo val photo: PhotoFile
) : PaidMedia { ) : PaidMedia {
@EncodeDefault @EncodeDefault
@SerialName(typeField) @SerialName(typeField)
@ -79,9 +83,9 @@ sealed interface PaidMedia : TelegramMedia {
@SerialName(durationField) @SerialName(durationField)
val duration: Int? = null, val duration: Int? = null,
@SerialName(photoField) @SerialName(photoField)
val photo: Photo? = null, val photo: PhotoFile? = null,
@SerialName(videoField) @SerialName(videoField)
val video: Video? = null val video: VideoFile? = null
) )
override val descriptor: SerialDescriptor override val descriptor: SerialDescriptor

View File

@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.types.request package dev.inmo.tgbotapi.types.request
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.Photo import dev.inmo.tgbotapi.types.files.PhotoFile
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@ -16,5 +16,5 @@ data class ChatShared(
@SerialName(usernameField) @SerialName(usernameField)
val username: Username? = null, val username: Username? = null,
@SerialName(photoField) @SerialName(photoField)
val photo: Photo? = null val photo: PhotoFile? = null
) : ChatSharedRequest ) : ChatSharedRequest

View File

@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.types.request package dev.inmo.tgbotapi.types.request
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.Photo import dev.inmo.tgbotapi.types.files.PhotoFile
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@ -16,5 +16,5 @@ data class SharedUser(
@SerialName(usernameField) @SerialName(usernameField)
val username: Username? = null, val username: Username? = null,
@SerialName(photoField) @SerialName(photoField)
val photo: Photo? = null, val photo: PhotoFile? = null,
) )

View File

@ -2,7 +2,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.PhotoFile
import dev.inmo.tgbotapi.types.media.MediaGroupMemberTelegramFreeMediaSerializer 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
@ -22,7 +22,7 @@ class SimpleInputFilesTest {
@Test @Test
fun test_that_creating_of_photo_and_converting_to_input_media_working_correctly() { fun test_that_creating_of_photo_and_converting_to_input_media_working_correctly() {
val photoContent = PhotoContent( val photoContent = PhotoContent(
Photo( PhotoFile(
listOf( listOf(
PhotoSize("example_file_id".toInputFile(), TgFileUniqueId("example_unique_file_id"), 100, 100, 100) PhotoSize("example_file_id".toInputFile(), TgFileUniqueId("example_unique_file_id"), 100, 100, 100)
) )

View File

@ -193,7 +193,7 @@ import dev.inmo.tgbotapi.types.files.MediaContentVariant
import dev.inmo.tgbotapi.types.files.MimedMediaFile import dev.inmo.tgbotapi.types.files.MimedMediaFile
import dev.inmo.tgbotapi.types.files.PassportFile import dev.inmo.tgbotapi.types.files.PassportFile
import dev.inmo.tgbotapi.types.files.PathedFile import dev.inmo.tgbotapi.types.files.PathedFile
import dev.inmo.tgbotapi.types.files.Photo import dev.inmo.tgbotapi.types.files.PhotoFile
import dev.inmo.tgbotapi.types.files.PhotoSize import dev.inmo.tgbotapi.types.files.PhotoSize
import dev.inmo.tgbotapi.types.files.PlayableMediaFile import dev.inmo.tgbotapi.types.files.PlayableMediaFile
import dev.inmo.tgbotapi.types.files.RegularAnimatedSticker import dev.inmo.tgbotapi.types.files.RegularAnimatedSticker
@ -2707,13 +2707,13 @@ public inline fun TelegramMediaFile.pathedFileOrThrow(): PathedFile = this as
public inline fun <T> TelegramMediaFile.ifPathedFile(block: (PathedFile) -> T): T? = public inline fun <T> TelegramMediaFile.ifPathedFile(block: (PathedFile) -> T): T? =
pathedFileOrNull() ?.let(block) pathedFileOrNull() ?.let(block)
public inline fun TelegramMediaFile.photoOrNull(): Photo? = this as? public inline fun TelegramMediaFile.photoOrNull(): PhotoFile? = this as?
dev.inmo.tgbotapi.types.files.Photo dev.inmo.tgbotapi.types.files.PhotoFile
public inline fun TelegramMediaFile.photoOrThrow(): Photo = this as public inline fun TelegramMediaFile.photoOrThrow(): PhotoFile = this as
dev.inmo.tgbotapi.types.files.Photo dev.inmo.tgbotapi.types.files.PhotoFile
public inline fun <T> TelegramMediaFile.ifPhoto(block: (Photo) -> T): T? = photoOrNull() public inline fun <T> TelegramMediaFile.ifPhoto(block: (PhotoFile) -> T): T? = photoOrNull()
?.let(block) ?.let(block)
public inline fun TelegramMediaFile.photoSizeOrNull(): PhotoSize? = this as? public inline fun TelegramMediaFile.photoSizeOrNull(): PhotoSize? = this as?

View File

@ -103,7 +103,7 @@ inline val Message.animation: AnimationFile?
inline val Message.game: Game? inline val Message.game: Game?
get() = asContentMessage() ?.content ?.asGameContent() ?.game get() = asContentMessage() ?.content ?.asGameContent() ?.game
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.photo: Photo? inline val Message.photo: PhotoFile?
get() = asContentMessage() ?.content ?.asPhotoContent() ?.mediaCollection get() = asContentMessage() ?.content ?.asPhotoContent() ?.mediaCollection
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.sticker: Sticker? inline val Message.sticker: Sticker?
@ -145,7 +145,7 @@ inline val Message.left_chat_member: User?
inline val Message.new_chat_title: String? inline val Message.new_chat_title: String?
get() = asChatEventMessage() ?.chatEvent ?.asNewChatTitle() ?.title get() = asChatEventMessage() ?.chatEvent ?.asNewChatTitle() ?.title
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.new_chat_photo: Photo? inline val Message.new_chat_photo: PhotoFile?
get() = asChatEventMessage() ?.chatEvent ?.asNewChatPhoto() ?.photo get() = asChatEventMessage() ?.chatEvent ?.asNewChatPhoto() ?.photo
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.delete_chat_photo: Boolean inline val Message.delete_chat_photo: Boolean