mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-12-29 09:29:23 +00:00
Compare commits
15 Commits
v3.0.0
...
3fc1058491
| Author | SHA1 | Date | |
|---|---|---|---|
| 3fc1058491 | |||
| c3668e978b | |||
| 5a4a6d5710 | |||
| ed1d8beb2e | |||
| 881ede7d2a | |||
| 60d3d279e7 | |||
| 4b84518dbb | |||
| 8b451791dd | |||
| 771fb5c288 | |||
| d19ee74f8b | |||
| aaf489c2ed | |||
| 1b06b63703 | |||
| bf7fc25285 | |||
| 4df242747f | |||
| e831ca143e |
@@ -1,6 +1,11 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 3.0.0
|
||||
## 3.1.0
|
||||
|
||||
* `Core`:
|
||||
* Add support of `custom emoji`s
|
||||
|
||||
## 3.0.2
|
||||
|
||||
**ALL OLD DEPRECATIONS HAVE BEEN REMOVED**
|
||||
|
||||
@@ -28,6 +33,8 @@
|
||||
* `Utils`:
|
||||
* **BREAKING CHANGES** Now all new classcasts (like `Chat.ifPrivateChat` etc.) have been rewritten to be generated with `ksp` and `kotlin poet`
|
||||
|
||||
*Note: Versions 3.0.0 and 3.0.1 have been published with errors and didn't recommend to use*
|
||||
|
||||
## 2.2.2
|
||||
|
||||
* `Utils`:
|
||||
|
||||
@@ -30,12 +30,13 @@ kotlin {
|
||||
|
||||
private List<SourceDirectorySet> findSourcesWithName(String... approximateNames) {
|
||||
return parent.subprojects
|
||||
.findAll { it != project }
|
||||
.collectMany { it.kotlin.sourceSets }
|
||||
.findAll { sourceSet -> approximateNames.any {
|
||||
nameToFilter -> sourceSet.name.contains(nameToFilter)
|
||||
}
|
||||
}.collect { it.kotlin }
|
||||
.findAll { it != project && it.hasProperty("kotlin") }
|
||||
.collectMany { it.kotlin.sourceSets }
|
||||
.findAll { sourceSet ->
|
||||
approximateNames.any { nameToFilter ->
|
||||
sourceSet.name.contains(nameToFilter)
|
||||
}
|
||||
}.collect { it.kotlin }
|
||||
}
|
||||
|
||||
Object callback = {
|
||||
|
||||
@@ -6,4 +6,4 @@ kotlin.incremental=true
|
||||
kotlin.incremental.js=true
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=3.0.0
|
||||
library_version=3.1.0
|
||||
|
||||
@@ -8,12 +8,12 @@ javax-activation = "1.1.1"
|
||||
|
||||
korlibs = "3.0.0"
|
||||
uuid = "0.5.0"
|
||||
ktor = "2.0.3"
|
||||
ktor = "2.1.0"
|
||||
|
||||
ksp = "1.7.10-1.0.6"
|
||||
kotlin-poet = "1.12.0"
|
||||
|
||||
microutils = "0.12.0"
|
||||
microutils = "0.12.1"
|
||||
|
||||
github-release-plugin = "2.4.1"
|
||||
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||
|
||||
@@ -12,8 +12,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
include ":tgbotapi.core"
|
||||
include ":tgbotapi.ksp:processor"
|
||||
include ":tgbotapi.ksp:lib"
|
||||
include ":tgbotapi.ksp"
|
||||
include ":tgbotapi.api"
|
||||
include ":tgbotapi.utils"
|
||||
include ":tgbotapi.behaviour_builder"
|
||||
|
||||
@@ -29,8 +29,6 @@ kotlin {
|
||||
api libs.microutils.languageCodes
|
||||
|
||||
api libs.ktor.client.core
|
||||
|
||||
api project(":tgbotapi.ksp:lib")
|
||||
}
|
||||
}
|
||||
commonTest {
|
||||
@@ -52,8 +50,7 @@ kotlin {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
add("kspCommonMainMetadata", project(":tgbotapi.ksp:processor"))
|
||||
add("kspJvm", project(":tgbotapi.ksp:processor"))
|
||||
add("kspJvm", project(":tgbotapi.ksp"))
|
||||
}
|
||||
|
||||
ksp {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.payments.abstracts.Currencied
|
||||
import dev.inmo.tgbotapi.types.payments.abstracts.Priced
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package dev.inmo.tgbotapi.requests.get
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.files.CustomEmojiSticker
|
||||
import dev.inmo.tgbotapi.types.files.StickerSerializer
|
||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class GetCustomEmojiStickers(
|
||||
@SerialName(customEmojiIdsField)
|
||||
val customEmojiIds: List<CustomEmojiId>
|
||||
): SimpleRequest<CustomEmojiSticker> {
|
||||
override fun method(): String = "getCustomEmojiStickers"
|
||||
override val resultDeserializer: DeserializationStrategy<CustomEmojiSticker>
|
||||
get() = StickerSerializer as DeserializationStrategy<CustomEmojiSticker>
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -40,6 +40,7 @@ data class CreateNewAnimatedStickerSet internal constructor(
|
||||
@SerialName(tgsStickerField)
|
||||
val sticker: FileId? = null,
|
||||
@SerialName(containsMasksField)
|
||||
@Deprecated("Will be removed soon due to its redundancy")
|
||||
val containsMasks: Boolean? = null,
|
||||
@SerialName(maskPositionField)
|
||||
override val maskPosition: MaskPosition? = null
|
||||
|
||||
@@ -50,6 +50,7 @@ data class CreateNewStaticStickerSet internal constructor(
|
||||
@SerialName(pngStickerField)
|
||||
val sticker: FileId? = null,
|
||||
@SerialName(containsMasksField)
|
||||
@Deprecated("Will be removed soon due to its redundancy")
|
||||
val containsMasks: Boolean? = null,
|
||||
@SerialName(maskPositionField)
|
||||
override val maskPosition: MaskPosition? = null
|
||||
|
||||
@@ -40,6 +40,7 @@ data class CreateNewVideoStickerSet internal constructor(
|
||||
@SerialName(webmStickerField)
|
||||
val sticker: FileId? = null,
|
||||
@SerialName(containsMasksField)
|
||||
@Deprecated("Will be removed soon due to its redundancy")
|
||||
val containsMasks: Boolean? = null,
|
||||
@SerialName(maskPositionField)
|
||||
override val maskPosition: MaskPosition? = null
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import dev.inmo.tgbotapi.utils.BuiltinMimeTypes
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import kotlin.jvm.JvmInline
|
||||
|
||||
typealias Identifier = Long
|
||||
typealias MessageIdentifier = Long
|
||||
@@ -28,6 +35,11 @@ typealias GooglePlaceId = String
|
||||
typealias GooglePlaceType = String
|
||||
typealias MembersLimit = Int
|
||||
typealias WebAppQueryId = String
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class CustomEmojiId(
|
||||
val string: String
|
||||
)
|
||||
|
||||
typealias Seconds = Int
|
||||
typealias MilliSeconds = Long
|
||||
@@ -37,6 +49,36 @@ typealias UnixTimeStamp = LongSeconds
|
||||
typealias Meters = Float
|
||||
typealias Degrees = Int
|
||||
|
||||
@Serializable(StickerType.Serializer::class)
|
||||
sealed interface StickerType {
|
||||
val type: String
|
||||
|
||||
@Serializable
|
||||
object Regular : StickerType { override val type: String = "regular" }
|
||||
@Serializable
|
||||
object Mask : StickerType { override val type: String = "mask" }
|
||||
@Serializable
|
||||
object CustomEmoji : StickerType { override val type: String = "custom_emoji" }
|
||||
|
||||
object Serializer : KSerializer<StickerType> {
|
||||
override val descriptor: SerialDescriptor = String.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): StickerType {
|
||||
return when (val type = decoder.decodeString()) {
|
||||
Regular.type -> Regular
|
||||
Mask.type -> Regular
|
||||
CustomEmoji.type -> Regular
|
||||
else -> error("Unknown type of emoji $type")
|
||||
}
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: StickerType) {
|
||||
encoder.encodeString(value.type)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
val degreesLimit = 1 .. 360
|
||||
val horizontalAccuracyLimit = 0F .. 1500F
|
||||
|
||||
@@ -126,6 +168,8 @@ const val supportInlineQueriesField = "supports_inline_queries"
|
||||
const val textEntitiesField = "text_entities"
|
||||
const val entitiesField = "entities"
|
||||
const val stickerSetNameField = "set_name"
|
||||
const val customEmojiIdField = "custom_emoji_id"
|
||||
const val customEmojiIdsField = "custom_emoji_ids"
|
||||
const val premiumAnimationField = "premium_animation"
|
||||
const val stickerSetNameFullField = "sticker_set_name"
|
||||
const val slowModeDelayField = "slow_mode_delay"
|
||||
@@ -290,6 +334,7 @@ const val tgsStickerField = "tgs_sticker"
|
||||
const val webmStickerField = "webm_sticker"
|
||||
const val oldChatMemberField = "old_chat_member"
|
||||
const val newChatMemberField = "new_chat_member"
|
||||
const val stickerTypeField = "sticker_type"
|
||||
|
||||
const val okField = "ok"
|
||||
const val captionField = "caption"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.serializers.InlineQueryResultSerializer
|
||||
import dev.inmo.tgbotapi.types.InlineQueryIdentifier
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContentSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.actions
|
||||
|
||||
import dev.inmo.micro_utils.common.Warning
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.games.CallbackGame
|
||||
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.buttons
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(KeyboardMarkupSerializer::class)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.chat
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.dice
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.KSerializer
|
||||
|
||||
@@ -14,6 +14,7 @@ import kotlinx.serialization.encoding.Encoder
|
||||
data class StickerSurrogate(
|
||||
val file_id: FileId,
|
||||
val file_unique_id: FileUniqueId,
|
||||
val type: StickerType,
|
||||
val width: Int,
|
||||
val height: Int,
|
||||
val is_animated: Boolean? = null,
|
||||
@@ -21,23 +22,22 @@ data class StickerSurrogate(
|
||||
val thumb: PhotoSize? = null,
|
||||
val emoji: String? = null,
|
||||
val set_name: StickerSetName? = null,
|
||||
val premium_animation: File? = null,
|
||||
val mask_position: MaskPosition? = null,
|
||||
val file_size: Long? = null,
|
||||
val premium_animation: File? = null
|
||||
val custom_emoji_id: CustomEmojiId? = null,
|
||||
val file_size: Long? = null
|
||||
)
|
||||
|
||||
// TODO:: Serializer
|
||||
@Serializable(StickerSerializer::class)
|
||||
sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile {
|
||||
val emoji: String?
|
||||
val maskPosition: MaskPosition?
|
||||
val stickerSetName: StickerSetName?
|
||||
val premiumAnimationFile: File?
|
||||
|
||||
val isAnimated
|
||||
get() = this is AnimatedSticker
|
||||
get() = false
|
||||
val isVideo
|
||||
get() = this is VideoSticker
|
||||
get() = false
|
||||
}
|
||||
|
||||
object StickerSerializer : KSerializer<Sticker> {
|
||||
@@ -46,43 +46,90 @@ object StickerSerializer : KSerializer<Sticker> {
|
||||
override fun deserialize(decoder: Decoder): Sticker {
|
||||
val surrogate = StickerSurrogate.serializer().deserialize(decoder)
|
||||
|
||||
return when {
|
||||
surrogate.is_animated == true -> AnimatedSticker(
|
||||
return when (surrogate.type) {
|
||||
StickerType.Regular -> when {
|
||||
surrogate.is_animated == true -> RegularAnimatedSticker(
|
||||
surrogate.file_id,
|
||||
surrogate.file_unique_id,
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.thumb,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.premium_animation,
|
||||
surrogate.file_size
|
||||
)
|
||||
surrogate.is_video == true -> RegularVideoSticker(
|
||||
surrogate.file_id,
|
||||
surrogate.file_unique_id,
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.thumb,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.premium_animation,
|
||||
surrogate.file_size
|
||||
)
|
||||
else -> RegularSimpleSticker(
|
||||
surrogate.file_id,
|
||||
surrogate.file_unique_id,
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.thumb,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.premium_animation,
|
||||
surrogate.file_size
|
||||
)
|
||||
}
|
||||
StickerType.Mask -> MaskSticker(
|
||||
surrogate.file_id,
|
||||
surrogate.file_unique_id,
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.mask_position ?: error("For mask stickers field mask_position should be presented"),
|
||||
surrogate.is_animated == true,
|
||||
surrogate.is_video == true,
|
||||
surrogate.thumb,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.premium_animation,
|
||||
surrogate.mask_position,
|
||||
surrogate.file_size
|
||||
)
|
||||
surrogate.is_video == true -> VideoSticker(
|
||||
surrogate.file_id,
|
||||
surrogate.file_unique_id,
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.thumb,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.premium_animation,
|
||||
surrogate.mask_position,
|
||||
surrogate.file_size
|
||||
)
|
||||
else -> SimpleSticker(
|
||||
surrogate.file_id,
|
||||
surrogate.file_unique_id,
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.thumb,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.premium_animation,
|
||||
surrogate.mask_position,
|
||||
surrogate.file_size
|
||||
)
|
||||
StickerType.CustomEmoji -> when {
|
||||
surrogate.is_animated == true -> CustomEmojiAnimatedSticker(
|
||||
surrogate.file_id,
|
||||
surrogate.file_unique_id,
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.custom_emoji_id ?: error("For mask stickers field mask_position should be presented"),
|
||||
surrogate.thumb,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.file_size
|
||||
)
|
||||
surrogate.is_video == true -> CustomEmojiVideoSticker(
|
||||
surrogate.file_id,
|
||||
surrogate.file_unique_id,
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.custom_emoji_id ?: error("For mask stickers field mask_position should be presented"),
|
||||
surrogate.thumb,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.file_size
|
||||
)
|
||||
else -> CustomEmojiSimpleSticker(
|
||||
surrogate.file_id,
|
||||
surrogate.file_unique_id,
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.custom_emoji_id ?: error("For mask stickers field mask_position should be presented"),
|
||||
surrogate.thumb,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.file_size
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,8 +139,50 @@ object StickerSerializer : KSerializer<Sticker> {
|
||||
|
||||
}
|
||||
|
||||
@Serializable(StickerSerializer::class)
|
||||
sealed interface VideoSticker : Sticker {
|
||||
override val isVideo: Boolean
|
||||
get() = true
|
||||
}
|
||||
@Serializable(StickerSerializer::class)
|
||||
sealed interface AnimatedSticker : Sticker {
|
||||
override val isAnimated: Boolean
|
||||
get() = true
|
||||
}
|
||||
|
||||
@Serializable(StickerSerializer::class)
|
||||
sealed interface RegularSticker : Sticker {
|
||||
val premiumAnimationFile: File?
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class SimpleSticker(
|
||||
data class MaskSticker(
|
||||
@SerialName(fileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(fileUniqueIdField)
|
||||
override val fileUniqueId: FileUniqueId,
|
||||
@SerialName(widthField)
|
||||
override val width: Int,
|
||||
@SerialName(heightField)
|
||||
override val height: Int,
|
||||
@SerialName(maskPositionField)
|
||||
val maskPosition: MaskPosition,
|
||||
@SerialName(isAnimatedField)
|
||||
override val isAnimated: Boolean,
|
||||
@SerialName(isVideoField)
|
||||
override val isVideo: Boolean,
|
||||
@SerialName(thumbField)
|
||||
override val thumb: PhotoSize? = null,
|
||||
@SerialName(emojiField)
|
||||
override val emoji: String? = null,
|
||||
@SerialName(stickerSetNameField)
|
||||
override val stickerSetName: StickerSetName? = null,
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null,
|
||||
) : Sticker
|
||||
|
||||
@Serializable
|
||||
data class RegularSimpleSticker(
|
||||
@SerialName(fileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(fileUniqueIdField)
|
||||
@@ -110,13 +199,13 @@ data class SimpleSticker(
|
||||
override val stickerSetName: StickerSetName? = null,
|
||||
@SerialName(premiumAnimationField)
|
||||
override val premiumAnimationFile: File?,
|
||||
@SerialName(maskPositionField)
|
||||
override val maskPosition: MaskPosition? = null,
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null,
|
||||
) : Sticker
|
||||
) : RegularSticker
|
||||
@Deprecated("Renamed", ReplaceWith("SimpleRegularSticker", "dev.inmo.tgbotapi.types.files.SimpleRegularSticker"))
|
||||
typealias SimpleSticker = RegularSimpleSticker
|
||||
@Serializable
|
||||
data class AnimatedSticker(
|
||||
data class RegularAnimatedSticker(
|
||||
@SerialName(fileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(fileUniqueIdField)
|
||||
@@ -133,13 +222,11 @@ data class AnimatedSticker(
|
||||
override val stickerSetName: StickerSetName? = null,
|
||||
@SerialName(premiumAnimationField)
|
||||
override val premiumAnimationFile: File?,
|
||||
@SerialName(maskPositionField)
|
||||
override val maskPosition: MaskPosition? = null,
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null,
|
||||
) : Sticker
|
||||
) : RegularSticker, AnimatedSticker
|
||||
@Serializable
|
||||
data class VideoSticker(
|
||||
data class RegularVideoSticker(
|
||||
@SerialName(fileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(fileUniqueIdField)
|
||||
@@ -156,8 +243,75 @@ data class VideoSticker(
|
||||
override val stickerSetName: StickerSetName? = null,
|
||||
@SerialName(premiumAnimationField)
|
||||
override val premiumAnimationFile: File?,
|
||||
@SerialName(maskPositionField)
|
||||
override val maskPosition: MaskPosition? = null,
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null,
|
||||
) : Sticker
|
||||
) : RegularSticker, VideoSticker
|
||||
|
||||
@Serializable(StickerSerializer::class)
|
||||
sealed interface CustomEmojiSticker : Sticker {
|
||||
val customEmojiId: CustomEmojiId
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class CustomEmojiSimpleSticker(
|
||||
@SerialName(fileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(fileUniqueIdField)
|
||||
override val fileUniqueId: FileUniqueId,
|
||||
@SerialName(widthField)
|
||||
override val width: Int,
|
||||
@SerialName(heightField)
|
||||
override val height: Int,
|
||||
@SerialName(customEmojiIdField)
|
||||
override val customEmojiId: CustomEmojiId,
|
||||
@SerialName(thumbField)
|
||||
override val thumb: PhotoSize? = null,
|
||||
@SerialName(emojiField)
|
||||
override val emoji: String? = null,
|
||||
@SerialName(stickerSetNameField)
|
||||
override val stickerSetName: StickerSetName? = null,
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null,
|
||||
) : CustomEmojiSticker
|
||||
@Serializable
|
||||
data class CustomEmojiAnimatedSticker(
|
||||
@SerialName(fileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(fileUniqueIdField)
|
||||
override val fileUniqueId: FileUniqueId,
|
||||
@SerialName(widthField)
|
||||
override val width: Int,
|
||||
@SerialName(heightField)
|
||||
override val height: Int,
|
||||
@SerialName(customEmojiIdField)
|
||||
override val customEmojiId: CustomEmojiId,
|
||||
@SerialName(thumbField)
|
||||
override val thumb: PhotoSize? = null,
|
||||
@SerialName(emojiField)
|
||||
override val emoji: String? = null,
|
||||
@SerialName(stickerSetNameField)
|
||||
override val stickerSetName: StickerSetName? = null,
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null,
|
||||
) : CustomEmojiSticker, AnimatedSticker
|
||||
@Serializable
|
||||
data class CustomEmojiVideoSticker(
|
||||
@SerialName(fileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(fileUniqueIdField)
|
||||
override val fileUniqueId: FileUniqueId,
|
||||
@SerialName(widthField)
|
||||
override val width: Int,
|
||||
@SerialName(heightField)
|
||||
override val height: Int,
|
||||
@SerialName(customEmojiIdField)
|
||||
override val customEmojiId: CustomEmojiId,
|
||||
@SerialName(thumbField)
|
||||
override val thumb: PhotoSize? = null,
|
||||
@SerialName(emojiField)
|
||||
override val emoji: String? = null,
|
||||
@SerialName(stickerSetNameField)
|
||||
override val stickerSetName: StickerSetName? = null,
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null,
|
||||
) : CustomEmojiSticker, VideoSticker
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.files
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.types.FileUniqueId
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.location
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.*
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.media
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
|
||||
@ClassCastsIncluded
|
||||
interface ChatEvent
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.message
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.FromUser
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.*
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.message
|
||||
|
||||
import dev.inmo.tgbotapi.types.CustomEmojiId
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
import dev.inmo.tgbotapi.types.message.textsources.*
|
||||
import kotlinx.serialization.Serializable
|
||||
@@ -11,7 +12,8 @@ internal data class RawMessageEntity(
|
||||
val length: Int,
|
||||
val url: String? = null,
|
||||
val user: User? = null,
|
||||
val language: String? = null
|
||||
val language: String? = null,
|
||||
val custom_emoji_id: CustomEmojiId? = null
|
||||
) {
|
||||
internal val range by lazy {
|
||||
offset until (offset + length)
|
||||
@@ -50,6 +52,7 @@ internal fun RawMessageEntity.asTextSource(
|
||||
"underline" -> UnderlineTextSource(sourceSubstring, subPartsWithRegulars)
|
||||
"strikethrough" -> StrikethroughTextSource(sourceSubstring, subPartsWithRegulars)
|
||||
"spoiler" -> SpoilerTextSource(sourceSubstring, subPartsWithRegulars)
|
||||
"custom_emoji" -> CustomEmojiTextSource(sourceSubstring, custom_emoji_id ?: error("For custom emoji custom_emoji_id should exists"), subPartsWithRegulars)
|
||||
else -> RegularTextSource(sourceSubstring)
|
||||
}
|
||||
}
|
||||
@@ -158,7 +161,8 @@ internal fun TextSource.toRawMessageEntities(offset: Int = 0): List<RawMessageEn
|
||||
is UnderlineTextSource -> RawMessageEntity("underline", offset, length)
|
||||
is StrikethroughTextSource -> RawMessageEntity("strikethrough", offset, length)
|
||||
is SpoilerTextSource -> RawMessageEntity("spoiler", offset, length)
|
||||
else -> null
|
||||
is CustomEmojiTextSource -> RawMessageEntity("custom_emoji", offset, length)
|
||||
is RegularTextSource -> null
|
||||
}
|
||||
) + if (this is MultilevelTextSource) {
|
||||
subsources.toRawMessageEntities(offset)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.message.abstracts
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.RawMessage
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.message.content
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package dev.inmo.tgbotapi.types.message.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.types.CustomEmojiId
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* @see customEmoji
|
||||
*/
|
||||
@Serializable
|
||||
data class CustomEmojiTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
|
||||
override val source: String,
|
||||
val customEmojiId: CustomEmojiId,
|
||||
override val subsources: TextSourcesList
|
||||
) : MultilevelTextSource {
|
||||
override val markdown: String by lazy { source.customEmojiMarkdown() }
|
||||
override val markdownV2: String by lazy { source.customEmojiMarkdownV2() }
|
||||
override val html: String by lazy { source.customEmojiHTML() }
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_API_USAGE")
|
||||
inline fun customEmoji(emojiId: CustomEmojiId, parts: TextSourcesList) = CustomEmojiTextSource(parts.makeString(), emojiId, parts)
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun customEmoji(emojiId: CustomEmojiId, vararg parts: TextSource) = customEmoji(emojiId, parts.toList())
|
||||
/**
|
||||
* Without sharp (#)
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun customEmoji(emojiId: CustomEmojiId, text: String) = customEmoji(emojiId, regular(text))
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.message.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.captionLength
|
||||
import dev.inmo.tgbotapi.types.textLength
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@@ -21,6 +21,7 @@ private val baseSerializers: Map<String, KSerializer<out TextSource>> = mapOf(
|
||||
"hashtag" to HashTagTextSource.serializer(),
|
||||
"cashtag" to CashTagTextSource.serializer(),
|
||||
"spoiler" to SpoilerTextSource.serializer(),
|
||||
"custom_emoji" to CustomEmojiTextSource.serializer(),
|
||||
)
|
||||
|
||||
object TextSourceSerializer : TypedSerializer<TextSource>(TextSource::class, baseSerializers) {
|
||||
|
||||
@@ -5,7 +5,7 @@ package dev.inmo.tgbotapi.types.passport
|
||||
import dev.inmo.micro_utils.crypto.MD5
|
||||
import dev.inmo.micro_utils.crypto.md5
|
||||
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted.type
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.passport.decrypted.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.passport.credentials.EndDataCredentials
|
||||
|
||||
@ClassCastsIncluded
|
||||
|
||||
@@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.passport.encrypted.abstracts
|
||||
|
||||
import dev.inmo.micro_utils.crypto.SourceBytes
|
||||
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted.EncryptedElementSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
@@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.types.polls
|
||||
import com.soywiz.klock.DateTime
|
||||
import com.soywiz.klock.TimeSpan
|
||||
import dev.inmo.tgbotapi.abstracts.TextedInput
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.message.*
|
||||
import dev.inmo.tgbotapi.types.message.RawMessageEntity
|
||||
|
||||
@@ -1,25 +1,87 @@
|
||||
package dev.inmo.tgbotapi.types.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.files.PhotoSize
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import dev.inmo.tgbotapi.types.files.*
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
data class StickerSet(
|
||||
sealed interface StickerSet {
|
||||
@SerialName(nameField)
|
||||
val name: String,
|
||||
val name: String
|
||||
@SerialName(titleField)
|
||||
val title: String,
|
||||
val title: String
|
||||
@SerialName(stickerTypeField)
|
||||
val stickerType: StickerType
|
||||
@SerialName(stickersField)
|
||||
val stickers: List<Sticker>,
|
||||
val stickers: List<Sticker>
|
||||
@SerialName(isAnimatedField)
|
||||
val isAnimated: Boolean = false,
|
||||
val isAnimated: Boolean
|
||||
@SerialName(isVideoField)
|
||||
val isVideo: Boolean = false,
|
||||
val isVideo: Boolean
|
||||
@SerialName(containsMasksField)
|
||||
val containsMasks: Boolean = false,
|
||||
@Deprecated("Will be removed soon due to its redundancy")
|
||||
val containsMasks: Boolean
|
||||
get() = this is MaskStickerSet
|
||||
@SerialName(thumbField)
|
||||
val thumb: PhotoSize? = null
|
||||
)
|
||||
val thumb: PhotoSize?
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class RegularStickerSet(
|
||||
@SerialName(nameField)
|
||||
override val name: String,
|
||||
@SerialName(titleField)
|
||||
override val title: String,
|
||||
@SerialName(stickersField)
|
||||
override val stickers: List<RegularSticker>,
|
||||
@SerialName(isAnimatedField)
|
||||
override val isAnimated: Boolean = false,
|
||||
@SerialName(isVideoField)
|
||||
override val isVideo: Boolean = false,
|
||||
@SerialName(thumbField)
|
||||
override val thumb: PhotoSize? = null
|
||||
) : StickerSet {
|
||||
@SerialName(stickerTypeField)
|
||||
@EncodeDefault
|
||||
override val stickerType: StickerType = StickerType.Regular
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class MaskStickerSet(
|
||||
@SerialName(nameField)
|
||||
override val name: String,
|
||||
@SerialName(titleField)
|
||||
override val title: String,
|
||||
@SerialName(stickersField)
|
||||
override val stickers: List<MaskSticker>,
|
||||
@SerialName(isAnimatedField)
|
||||
override val isAnimated: Boolean = false,
|
||||
@SerialName(isVideoField)
|
||||
override val isVideo: Boolean = false,
|
||||
@SerialName(thumbField)
|
||||
override val thumb: PhotoSize? = null
|
||||
) : StickerSet {
|
||||
@SerialName(stickerTypeField)
|
||||
@EncodeDefault
|
||||
override val stickerType: StickerType = StickerType.Mask
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class CustomEmojiStickerSet(
|
||||
@SerialName(nameField)
|
||||
override val name: String,
|
||||
@SerialName(titleField)
|
||||
override val title: String,
|
||||
@SerialName(stickersField)
|
||||
override val stickers: List<CustomEmojiSticker>,
|
||||
@SerialName(isAnimatedField)
|
||||
override val isAnimated: Boolean = false,
|
||||
@SerialName(isVideoField)
|
||||
override val isVideo: Boolean = false,
|
||||
@SerialName(thumbField)
|
||||
override val thumb: PhotoSize? = null
|
||||
) : StickerSet {
|
||||
@SerialName(stickerTypeField)
|
||||
@EncodeDefault
|
||||
override val stickerType: StickerType = StickerType.CustomEmoji
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.update.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||
import dev.inmo.tgbotapi.types.update.RawUpdate
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package dev.inmo.tgbotapi.utils.internal
|
||||
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
internal annotation class ClassCastsIncluded
|
||||
@@ -119,6 +119,10 @@ internal fun String.commandMarkdown(): String = command(String::toMarkdown)
|
||||
internal fun String.commandMarkdownV2(): String = command(String::escapeMarkdownV2Common)
|
||||
internal fun String.commandHTML(): String = command(String::toHtml)
|
||||
|
||||
internal fun String.customEmojiMarkdown(): String = toMarkdown()
|
||||
internal fun String.customEmojiMarkdownV2(): String = escapeMarkdownV2Common()
|
||||
internal fun String.customEmojiHTML(): String = toHtml()
|
||||
|
||||
internal fun String.regularMarkdown(): String = toMarkdown()
|
||||
internal fun String.regularMarkdownV2(): String = escapeMarkdownV2Common()
|
||||
internal fun String.regularHtml(): String = toHtml()
|
||||
|
||||
@@ -9,5 +9,4 @@ repositories {
|
||||
dependencies {
|
||||
implementation libs.kotlin.poet
|
||||
implementation libs.ksp
|
||||
implementation project(":tgbotapi.ksp:lib")
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
}
|
||||
|
||||
project.description = "Class Casts generator KSP library to include into your library"
|
||||
|
||||
apply from: "$mppProjectWithSerializationPresetPath"
|
||||
@@ -1,5 +0,0 @@
|
||||
package dev.inmo.tgbotapi.ksp.lib
|
||||
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
annotation class ClassCastsIncluded
|
||||
@@ -7,7 +7,6 @@ import com.google.devtools.ksp.symbol.KSClassDeclaration
|
||||
import com.squareup.kotlinpoet.AnnotationSpec
|
||||
import com.squareup.kotlinpoet.FileSpec
|
||||
import com.squareup.kotlinpoet.ksp.writeTo
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import java.io.File
|
||||
|
||||
class TelegramBotAPISymbolProcessor(
|
||||
@@ -17,7 +16,7 @@ class TelegramBotAPISymbolProcessor(
|
||||
private val outputFolder: String? = null
|
||||
) : SymbolProcessor {
|
||||
override fun process(resolver: Resolver): List<KSAnnotated> {
|
||||
val classes = resolver.getSymbolsWithAnnotation(ClassCastsIncluded::class.qualifiedName!!).filterIsInstance<KSClassDeclaration>()
|
||||
val classes = resolver.getSymbolsWithAnnotation("dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded").filterIsInstance<KSClassDeclaration>()
|
||||
val classesSubtypes = mutableMapOf<KSClassDeclaration, MutableSet<KSClassDeclaration>>()
|
||||
|
||||
resolver.getAllFiles().forEach {
|
||||
@@ -295,6 +295,7 @@ import dev.inmo.tgbotapi.types.message.textsources.BoldTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.CashTagTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.CodeTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.CustomEmojiTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.EMailTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.HashTagTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.ItalicTextSource
|
||||
@@ -3427,6 +3428,15 @@ public inline fun TextSource.codeTextSourceOrThrow(): CodeTextSource = this as
|
||||
public inline fun <T> TextSource.ifCodeTextSource(block: (CodeTextSource) -> T): T? =
|
||||
codeTextSourceOrNull() ?.let(block)
|
||||
|
||||
public inline fun TextSource.customEmojiTextSourceOrNull(): CustomEmojiTextSource? = this as?
|
||||
dev.inmo.tgbotapi.types.message.textsources.CustomEmojiTextSource
|
||||
|
||||
public inline fun TextSource.customEmojiTextSourceOrThrow(): CustomEmojiTextSource = this as
|
||||
dev.inmo.tgbotapi.types.message.textsources.CustomEmojiTextSource
|
||||
|
||||
public inline fun <T> TextSource.ifCustomEmojiTextSource(block: (CustomEmojiTextSource) -> T): T? =
|
||||
customEmojiTextSourceOrNull() ?.let(block)
|
||||
|
||||
public inline fun TextSource.eMailTextSourceOrNull(): EMailTextSource? = this as?
|
||||
dev.inmo.tgbotapi.types.message.textsources.EMailTextSource
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package dev.inmo.tgbotapi.extensions.utils.formatting
|
||||
|
||||
import dev.inmo.micro_utils.common.joinTo
|
||||
import dev.inmo.tgbotapi.types.CustomEmojiId
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
import dev.inmo.tgbotapi.types.message.textsources.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
@@ -510,3 +511,39 @@ inline fun EntitiesBuilder.underline(text: String) = add(dev.inmo.tgbotapi.types
|
||||
* Version of [EntitiesBuilder.underline] with new line at the end
|
||||
*/
|
||||
inline fun EntitiesBuilder.underlineln(text: String) = underline(text) + newLine
|
||||
|
||||
|
||||
/**
|
||||
* Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji]
|
||||
*/
|
||||
inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, parts))
|
||||
/**
|
||||
* Version of [EntitiesBuilder.customEmoji] with new line at the end
|
||||
*/
|
||||
inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, parts: TextSourcesList) = customEmoji(customEmojiId, parts) + newLine
|
||||
/**
|
||||
* Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji].
|
||||
* Will reuse separator config from [buildEntities]
|
||||
*/
|
||||
inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, buildEntities(separator, init)))
|
||||
/**
|
||||
* Version of [EntitiesBuilder.customEmoji] with new line at the end.
|
||||
* Will reuse separator config from [buildEntities]
|
||||
*/
|
||||
inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, noinline init: EntitiesBuilderBody) = customEmoji(customEmojiId, init) + newLine
|
||||
/**
|
||||
* Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji]
|
||||
*/
|
||||
inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, *parts))
|
||||
/**
|
||||
* Version of [EntitiesBuilder.customEmoji] with new line at the end
|
||||
*/
|
||||
inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, vararg parts: TextSource) = customEmoji(customEmojiId, *parts) + newLine
|
||||
/**
|
||||
* Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji]
|
||||
*/
|
||||
inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, text: String) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, text))
|
||||
/**
|
||||
* Version of [EntitiesBuilder.customEmoji] with new line at the end
|
||||
*/
|
||||
inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, text: String) = customEmoji(customEmojiId, text) + newLine
|
||||
|
||||
Reference in New Issue
Block a user