diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt index d21790ed95..91925eee57 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -31,6 +31,7 @@ import dev.inmo.tgbotapi.types.chat.abstracts.extended.* import dev.inmo.tgbotapi.types.dice.* import dev.inmo.tgbotapi.types.files.* import dev.inmo.tgbotapi.types.files.abstracts.* +import dev.inmo.tgbotapi.types.files.sticker.* import dev.inmo.tgbotapi.types.files.sticker.Sticker import dev.inmo.tgbotapi.types.location.* import dev.inmo.tgbotapi.types.message.* @@ -2310,6 +2311,33 @@ inline fun TelegramMediaFile.asSticker(): Sticker? = this as? Sticker @PreviewFeature inline fun TelegramMediaFile.requireSticker(): Sticker = this as Sticker +@PreviewFeature +inline fun TelegramMediaFile.whenSimpleSticker(block: (SimpleSticker) -> T) = asSimpleSticker() ?.let(block) + +@PreviewFeature +inline fun TelegramMediaFile.asSimpleSticker(): SimpleSticker? = this as? SimpleSticker + +@PreviewFeature +inline fun TelegramMediaFile.requireSimpleSticker(): SimpleSticker = this as SimpleSticker + +@PreviewFeature +inline fun TelegramMediaFile.whenAnimatedSticker(block: (AnimatedSticker) -> T) = asAnimatedSticker() ?.let(block) + +@PreviewFeature +inline fun TelegramMediaFile.asAnimatedSticker(): AnimatedSticker? = this as? AnimatedSticker + +@PreviewFeature +inline fun TelegramMediaFile.requireAnimatedSticker(): AnimatedSticker = this as AnimatedSticker + +@PreviewFeature +inline fun TelegramMediaFile.whenVideoSticker(block: (VideoSticker) -> T) = asVideoSticker() ?.let(block) + +@PreviewFeature +inline fun TelegramMediaFile.asVideoSticker(): VideoSticker? = this as? VideoSticker + +@PreviewFeature +inline fun TelegramMediaFile.requireVideoSticker(): VideoSticker = this as VideoSticker + @PreviewFeature inline fun TelegramMediaFile.whenVideoFile(block: (VideoFile) -> T) = asVideoFile() ?.let(block) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Sticker.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Sticker.kt new file mode 100644 index 0000000000..9de78af393 --- /dev/null +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/raw/Sticker.kt @@ -0,0 +1,21 @@ +package dev.inmo.tgbotapi.extensions.utils.extensions.raw + +import dev.inmo.tgbotapi.requests.abstracts.FileId +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.files.sticker.* +import dev.inmo.tgbotapi.types.stickers.MaskPosition + +inline val Sticker.file_id: FileId + get() = fileId +inline val Sticker.file_unique_id: FileUniqueId + get() = fileUniqueId +inline val Sticker.is_animated: Boolean + get() = this is AnimatedSticker +inline val Sticker.is_video: Boolean + get() = this is VideoSticker +inline val Sticker.set_name: StickerSetName? + get() = stickerSetName +inline val Sticker.mask_position: MaskPosition? + get() = maskPosition +inline val Sticker.file_size: Long? + get() = fileSize