mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-27 01:35:47 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ced11ab336 | |||
| 6686aef4fa | |||
| 9ede545e56 | |||
| a74066cf62 | |||
| 0a7e99bbb3 | |||
| 913f584469 | |||
| 20278804bf | |||
| 631f1b9427 | |||
| 5e0106beb5 | |||
| d37e01f93e | |||
|
|
d4492ec7ac | ||
| 60d24259f4 |
15
CHANGELOG.md
15
CHANGELOG.md
@@ -1,5 +1,20 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 7.1.2
|
||||
|
||||
* `Versions`:
|
||||
* `MicroUtils`: `0.18.0` -> `0.18.1`
|
||||
* `Core`:
|
||||
* Now it is possible to serialize `Sticker`s
|
||||
|
||||
## 7.1.1
|
||||
|
||||
* `Versions`:
|
||||
* `Kotlin`: `1.8.20` -> `1.8.21`
|
||||
* `MicroUtils`: `0.17.8` -> `0.18.0`
|
||||
* `Utils`:
|
||||
* Fixes in `makeLinkToMessage`
|
||||
|
||||
## 7.1.0
|
||||
|
||||
**This update contains changes according to the [Telegram Bot API 6.7](https://core.telegram.org/bots/api-changelog#april-21-2023)**
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
| Useful repos | [](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) |
|
||||
| Misc | [](https://github.com/KotlinBy/awesome-kotlin) [](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) |
|
||||
| Platforms |   |
|
||||
| Experimental Platforms |   |
|
||||
| Experimental Platforms | [](https://kotlinlang.org/docs/native-target-support.html#tier-1) [](https://kotlinlang.org/docs/native-target-support.html#tier-1) |
|
||||
|
||||
<!--- [](https://t.me/ktgbotapi) --->
|
||||
|
||||
|
||||
@@ -6,4 +6,4 @@ kotlin.incremental=true
|
||||
kotlin.incremental.js=true
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=7.1.0
|
||||
library_version=7.1.2
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[versions]
|
||||
|
||||
kotlin = "1.8.20"
|
||||
kotlin = "1.8.21"
|
||||
kotlin-serialization = "1.5.0"
|
||||
kotlin-coroutines = "1.6.4"
|
||||
|
||||
@@ -10,10 +10,10 @@ korlibs = "3.4.0"
|
||||
uuid = "0.7.0"
|
||||
ktor = "2.3.0"
|
||||
|
||||
ksp = "1.8.20-1.0.11"
|
||||
kotlin-poet = "1.13.0"
|
||||
ksp = "1.8.21-1.0.11"
|
||||
kotlin-poet = "1.13.2"
|
||||
|
||||
microutils = "0.17.8"
|
||||
microutils = "0.18.1"
|
||||
|
||||
github-release-plugin = "2.4.1"
|
||||
dokka = "1.8.10"
|
||||
|
||||
@@ -14,7 +14,6 @@ object ExceptionsOnlyLimiter : RequestLimiter {
|
||||
result = runCatchingSafely {
|
||||
block()
|
||||
}.onFailure {
|
||||
it.printStackTrace()
|
||||
if (it is TooMuchRequestsException) {
|
||||
delay(it.retryAfter.leftToRetry)
|
||||
} else {
|
||||
|
||||
@@ -22,7 +22,7 @@ data class StickerSurrogate(
|
||||
val height: Int,
|
||||
val is_animated: Boolean? = null,
|
||||
val is_video: Boolean? = null,
|
||||
val thumb: PhotoSize? = null,
|
||||
val thumbnail: PhotoSize? = null,
|
||||
val emoji: String? = null,
|
||||
val set_name: StickerSetName? = null,
|
||||
val premium_animation: File? = null,
|
||||
@@ -43,6 +43,7 @@ sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile {
|
||||
get() = false
|
||||
val isVideo
|
||||
get() = false
|
||||
val type: StickerType
|
||||
|
||||
fun asInputSticker(emojis: List<String> = emoji ?.let { listOf(it) } ?: error("Unable to create input sticker without emojis")): InputSticker
|
||||
}
|
||||
@@ -62,7 +63,7 @@ object StickerSerializer : KSerializer<Sticker> {
|
||||
surrogate.file_unique_id,
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.thumb,
|
||||
surrogate.thumbnail,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.premium_animation,
|
||||
@@ -73,7 +74,7 @@ object StickerSerializer : KSerializer<Sticker> {
|
||||
surrogate.file_unique_id,
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.thumb,
|
||||
surrogate.thumbnail,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.premium_animation,
|
||||
@@ -84,7 +85,7 @@ object StickerSerializer : KSerializer<Sticker> {
|
||||
surrogate.file_unique_id,
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.thumb,
|
||||
surrogate.thumbnail,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.premium_animation,
|
||||
@@ -98,7 +99,7 @@ object StickerSerializer : KSerializer<Sticker> {
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.mask_position,
|
||||
surrogate.thumb,
|
||||
surrogate.thumbnail,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.file_size
|
||||
@@ -109,7 +110,7 @@ object StickerSerializer : KSerializer<Sticker> {
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.mask_position,
|
||||
surrogate.thumb,
|
||||
surrogate.thumbnail,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.file_size
|
||||
@@ -120,7 +121,7 @@ object StickerSerializer : KSerializer<Sticker> {
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.mask_position,
|
||||
surrogate.thumb,
|
||||
surrogate.thumbnail,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.file_size
|
||||
@@ -133,7 +134,7 @@ object StickerSerializer : KSerializer<Sticker> {
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.custom_emoji_id ?: error("For custom emoji stickers field custom_emoji_id should be presented"),
|
||||
surrogate.thumb,
|
||||
surrogate.thumbnail,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.file_size,
|
||||
@@ -145,7 +146,7 @@ object StickerSerializer : KSerializer<Sticker> {
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.custom_emoji_id ?: error("For custom emoji stickers field custom_emoji_id should be presented"),
|
||||
surrogate.thumb,
|
||||
surrogate.thumbnail,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.file_size,
|
||||
@@ -157,7 +158,7 @@ object StickerSerializer : KSerializer<Sticker> {
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.custom_emoji_id ?: error("For custom emoji stickers field custom_emoji_id should be presented"),
|
||||
surrogate.thumb,
|
||||
surrogate.thumbnail,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.file_size,
|
||||
@@ -169,7 +170,7 @@ object StickerSerializer : KSerializer<Sticker> {
|
||||
surrogate.file_unique_id,
|
||||
surrogate.width,
|
||||
surrogate.height,
|
||||
surrogate.thumb,
|
||||
surrogate.thumbnail,
|
||||
surrogate.emoji,
|
||||
surrogate.set_name,
|
||||
surrogate.file_size,
|
||||
@@ -178,13 +179,35 @@ object StickerSerializer : KSerializer<Sticker> {
|
||||
surrogate.is_video == true -> StickerFormat.Video
|
||||
else -> StickerFormat.Static
|
||||
},
|
||||
surrogate.type,
|
||||
json
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: Sticker) {
|
||||
TODO("Not yet implemented")
|
||||
with(value) {
|
||||
StickerSurrogate.serializer().serialize(
|
||||
encoder,
|
||||
StickerSurrogate(
|
||||
fileId,
|
||||
fileUniqueId,
|
||||
type,
|
||||
width,
|
||||
height,
|
||||
isAnimated,
|
||||
isVideo,
|
||||
thumbnail,
|
||||
emoji,
|
||||
stickerSetName,
|
||||
(this as? RegularSticker) ?.premiumAnimationFile,
|
||||
(this as? MaskSticker) ?.maskPosition,
|
||||
(this as? CustomEmojiSticker) ?.customEmojiId,
|
||||
fileSize,
|
||||
(this as? CustomEmojiSticker) ?.needsRepainting ?: false
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -210,6 +233,9 @@ sealed interface AnimatedSticker : Sticker {
|
||||
sealed interface RegularSticker : Sticker {
|
||||
val premiumAnimationFile: File?
|
||||
|
||||
override val type: StickerType.Regular
|
||||
get() = StickerType.Regular
|
||||
|
||||
override fun asInputSticker(emojis: List<String>) = InputSticker.WithKeywords.Regular(
|
||||
fileId,
|
||||
emojis,
|
||||
@@ -241,6 +267,11 @@ data class RegularSimpleSticker(
|
||||
@SerialName(stickerFormatField)
|
||||
@EncodeDefault
|
||||
override val stickerFormat: StickerFormat = StickerFormat.Static
|
||||
@SerialName(stickerTypeField)
|
||||
@Serializable(StickerType.Serializer::class)
|
||||
@EncodeDefault
|
||||
override val type: StickerType.Regular
|
||||
get() = StickerType.Regular
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@@ -263,7 +294,13 @@ data class RegularAnimatedSticker(
|
||||
override val premiumAnimationFile: File? = null,
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null,
|
||||
) : RegularSticker, AnimatedSticker
|
||||
) : RegularSticker, AnimatedSticker {
|
||||
@SerialName(stickerTypeField)
|
||||
@Serializable(StickerType.Serializer::class)
|
||||
@EncodeDefault
|
||||
override val type: StickerType.Regular
|
||||
get() = StickerType.Regular
|
||||
}
|
||||
@Serializable
|
||||
data class RegularVideoSticker(
|
||||
@SerialName(fileIdField)
|
||||
@@ -284,13 +321,22 @@ data class RegularVideoSticker(
|
||||
override val premiumAnimationFile: File? = null,
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null,
|
||||
) : RegularSticker, VideoSticker
|
||||
) : RegularSticker, VideoSticker {
|
||||
@SerialName(stickerTypeField)
|
||||
@Serializable(StickerType.Serializer::class)
|
||||
@EncodeDefault
|
||||
override val type: StickerType.Regular
|
||||
get() = StickerType.Regular
|
||||
}
|
||||
|
||||
|
||||
@Serializable
|
||||
sealed interface MaskSticker : Sticker {
|
||||
val maskPosition: MaskPosition?
|
||||
|
||||
override val type: StickerType.Mask
|
||||
get() = StickerType.Mask
|
||||
|
||||
override fun asInputSticker(emojis: List<String>) = InputSticker.Mask(
|
||||
fileId,
|
||||
emojis,
|
||||
@@ -321,6 +367,12 @@ data class MaskSimpleSticker(
|
||||
@SerialName(stickerFormatField)
|
||||
@EncodeDefault
|
||||
override val stickerFormat: StickerFormat = StickerFormat.Static
|
||||
|
||||
@SerialName(stickerTypeField)
|
||||
@Serializable(StickerType.Serializer::class)
|
||||
@EncodeDefault
|
||||
override val type: StickerType.Mask
|
||||
get() = StickerType.Mask
|
||||
}
|
||||
@Serializable
|
||||
data class MaskAnimatedSticker(
|
||||
@@ -342,7 +394,13 @@ data class MaskAnimatedSticker(
|
||||
override val stickerSetName: StickerSetName? = null,
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null,
|
||||
) : MaskSticker, AnimatedSticker
|
||||
) : MaskSticker, AnimatedSticker {
|
||||
@SerialName(stickerTypeField)
|
||||
@Serializable(StickerType.Serializer::class)
|
||||
@EncodeDefault
|
||||
override val type: StickerType.Mask
|
||||
get() = StickerType.Mask
|
||||
}
|
||||
@Serializable
|
||||
data class MaskVideoSticker(
|
||||
@SerialName(fileIdField)
|
||||
@@ -363,13 +421,22 @@ data class MaskVideoSticker(
|
||||
override val stickerSetName: StickerSetName? = null,
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null,
|
||||
) : MaskSticker, VideoSticker
|
||||
) : MaskSticker, VideoSticker {
|
||||
@SerialName(stickerTypeField)
|
||||
@Serializable(StickerType.Serializer::class)
|
||||
@EncodeDefault
|
||||
override val type: StickerType.Mask
|
||||
get() = StickerType.Mask
|
||||
}
|
||||
|
||||
@Serializable
|
||||
sealed interface CustomEmojiSticker : Sticker {
|
||||
val customEmojiId: CustomEmojiId
|
||||
val needsRepainting: Boolean
|
||||
|
||||
override val type: StickerType.CustomEmoji
|
||||
get() = StickerType.CustomEmoji
|
||||
|
||||
override fun asInputSticker(emojis: List<String>) = InputSticker.WithKeywords.CustomEmoji(
|
||||
fileId,
|
||||
emojis,
|
||||
@@ -403,6 +470,12 @@ data class CustomEmojiSimpleSticker(
|
||||
@SerialName(stickerFormatField)
|
||||
@EncodeDefault
|
||||
override val stickerFormat: StickerFormat = StickerFormat.Static
|
||||
|
||||
@SerialName(stickerTypeField)
|
||||
@Serializable(StickerType.Serializer::class)
|
||||
@EncodeDefault
|
||||
override val type: StickerType.CustomEmoji
|
||||
get() = StickerType.CustomEmoji
|
||||
}
|
||||
@Serializable
|
||||
data class CustomEmojiAnimatedSticker(
|
||||
@@ -426,7 +499,13 @@ data class CustomEmojiAnimatedSticker(
|
||||
override val fileSize: Long? = null,
|
||||
@SerialName(needsRepaintingField)
|
||||
override val needsRepainting: Boolean = false,
|
||||
) : CustomEmojiSticker, AnimatedSticker
|
||||
) : CustomEmojiSticker, AnimatedSticker {
|
||||
@SerialName(stickerTypeField)
|
||||
@Serializable(StickerType.Serializer::class)
|
||||
@EncodeDefault
|
||||
override val type: StickerType.CustomEmoji
|
||||
get() = StickerType.CustomEmoji
|
||||
}
|
||||
@Serializable
|
||||
data class CustomEmojiVideoSticker(
|
||||
@SerialName(fileIdField)
|
||||
@@ -449,7 +528,13 @@ data class CustomEmojiVideoSticker(
|
||||
override val fileSize: Long? = null,
|
||||
@SerialName(needsRepaintingField)
|
||||
override val needsRepainting: Boolean = false,
|
||||
) : CustomEmojiSticker, VideoSticker
|
||||
) : CustomEmojiSticker, VideoSticker {
|
||||
@SerialName(stickerTypeField)
|
||||
@Serializable(StickerType.Serializer::class)
|
||||
@EncodeDefault
|
||||
override val type: StickerType.CustomEmoji
|
||||
get() = StickerType.CustomEmoji
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class UnknownSticker(
|
||||
@@ -471,6 +556,9 @@ data class UnknownSticker(
|
||||
override val fileSize: Long? = null,
|
||||
@SerialName(stickerFormatField)
|
||||
override val stickerFormat: StickerFormat = StickerFormat.Static,
|
||||
@SerialName(stickerTypeField)
|
||||
@Serializable(StickerType.Serializer::class)
|
||||
override val type: StickerType = StickerType.Regular,
|
||||
val raw: JsonElement
|
||||
) : Sticker {
|
||||
override fun asInputSticker(emojis: List<String>) = InputSticker.WithKeywords.Regular(
|
||||
|
||||
@@ -47,7 +47,7 @@ fun makeLinkToMessage(
|
||||
username: Username,
|
||||
messageId: MessageId,
|
||||
threadId: MessageThreadId? = null
|
||||
): String = makeLinkToMessage(username.username, messageId, threadId)
|
||||
): String = makeLinkToMessage(username.usernameWithoutAt, messageId, threadId)
|
||||
fun makeLinkToMessage(
|
||||
chatId: Identifier,
|
||||
messageId: MessageId,
|
||||
|
||||
Reference in New Issue
Block a user