1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-29 13:38:43 +00:00

add LinkPreviewOptions

This commit is contained in:
InsanusMokrassar 2024-01-02 21:55:28 +06:00
parent 90225a9380
commit 4e1ecc0e34
2 changed files with 83 additions and 0 deletions

View File

@ -545,6 +545,10 @@ const val providerTokenField = "provider_token"
const val providerDataField = "provider_data" const val providerDataField = "provider_data"
const val usersField = "users" const val usersField = "users"
const val startDateField = "start_date" const val startDateField = "start_date"
const val showAboveTextField = "show_above_text"
const val isDisabledField = "is_disabled"
const val preferSmallMediaField = "prefer_small_media"
const val preferLargeMediaField = "prefer_large_media"
const val requireNameField = "need_name" const val requireNameField = "need_name"
const val requirePhoneNumberField = "need_phone_number" const val requirePhoneNumberField = "need_phone_number"

View File

@ -0,0 +1,79 @@
package dev.inmo.tgbotapi.types
import kotlinx.serialization.Required
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
sealed interface LinkPreviewOptions {
val isDisabled: Boolean
val url: String?
val preferSmallMedia: Boolean
val preferLargeMedia: Boolean
val showAboveText: Boolean
@Serializable
data object Disabled : LinkPreviewOptions {
@Required
@SerialName(isDisabledField)
override val isDisabled: Boolean = true
override val url: String?
get() = null
override val preferSmallMedia: Boolean
get() = false
override val preferLargeMedia: Boolean
get() = false
override val showAboveText: Boolean
get() = false
}
@Serializable
data class Large(
@SerialName(urlField)
override val url: String?,
@SerialName(showAboveTextField)
override val showAboveText: Boolean
) : LinkPreviewOptions {
@Required
@SerialName(isDisabledField)
override val isDisabled: Boolean = false
@Required
@SerialName(preferLargeMediaField)
override val preferLargeMedia: Boolean = true
override val preferSmallMedia: Boolean
get() = false
}
@Serializable
data class Small(
@SerialName(urlField)
override val url: String?,
@SerialName(showAboveTextField)
override val showAboveText: Boolean
) : LinkPreviewOptions {
@Required
@SerialName(isDisabledField)
override val isDisabled: Boolean = false
@Required
@SerialName(preferSmallMediaField)
override val preferSmallMedia: Boolean = true
override val preferLargeMedia: Boolean
get() = false
}
@Serializable
data class Medium(
@SerialName(urlField)
override val url: String?,
@SerialName(showAboveTextField)
override val showAboveText: Boolean
) : LinkPreviewOptions {
@Required
@SerialName(isDisabledField)
override val isDisabled: Boolean = false
override val preferSmallMedia: Boolean
get() = false
override val preferLargeMedia: Boolean
get() = false
}
}