From 6103b70a4744c6f5be82f00da6e6a536570e4f40 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 29 Sep 2023 22:15:38 +0600 Subject: [PATCH 1/4] start 9.2.1 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af0b3d4e5d..8752731445 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 9.2.1 + ## 9.2.0 **Add support of [Telegram Bots API 6.9](https://core.telegram.org/bots/api-changelog#september-22-2023)** diff --git a/gradle.properties b/gradle.properties index d7e79bba4f..83b46a74a2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ kotlin.incremental=true kotlin.incremental.js=true library_group=dev.inmo -library_version=9.2.0 +library_version=9.2.1 From dee13c03ae176aa66020d9dfb72be28cd01f8e02 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 29 Sep 2023 22:16:10 +0600 Subject: [PATCH 2/4] fix serialization/deserialization of chat member statuses --- CHANGELOG.md | 3 +++ .../tgbotapi/types/chat/member/AdministratorChatMemberImpl.kt | 3 +-- .../dev/inmo/tgbotapi/types/chat/member/KickedChatMember.kt | 3 +-- .../dev/inmo/tgbotapi/types/chat/member/LeftChatMemberImpl.kt | 3 +-- .../inmo/tgbotapi/types/chat/member/MemberChatMemberImpl.kt | 3 +-- .../dev/inmo/tgbotapi/types/chat/member/OwnerChatMember.kt | 3 +-- .../inmo/tgbotapi/types/chat/member/RestrictedChatMember.kt | 3 +-- 7 files changed, 9 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8752731445..6d695d5b89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 9.2.1 +* `Core`: + * All `ChatMember` inheritors have fixes `status` field + ## 9.2.0 **Add support of [Telegram Bots API 6.9](https://core.telegram.org/bots/api-changelog#september-22-2023)** diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/AdministratorChatMemberImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/AdministratorChatMemberImpl.kt index 523ac72d19..928fdf8ae6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/AdministratorChatMemberImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/AdministratorChatMemberImpl.kt @@ -45,6 +45,5 @@ data class AdministratorChatMemberImpl( ) : AdministratorChatMember { @SerialName(statusField) @Required - override val status: ChatMember.Status - get() = ChatMember.Status.Administrator + override val status: ChatMember.Status = ChatMember.Status.Administrator } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/KickedChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/KickedChatMember.kt index b54d906ed3..3da3b37c53 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/KickedChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/KickedChatMember.kt @@ -13,6 +13,5 @@ data class KickedChatMember( ) : BannedChatMember { @SerialName(statusField) @Required - override val status: ChatMember.Status - get() = ChatMember.Status.Kicked + override val status: ChatMember.Status = ChatMember.Status.Kicked } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/LeftChatMemberImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/LeftChatMemberImpl.kt index 1676372c04..aae25344e3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/LeftChatMemberImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/LeftChatMemberImpl.kt @@ -11,6 +11,5 @@ data class LeftChatMemberImpl( ) : LeftChatMember { @SerialName(statusField) @Required - override val status: ChatMember.Status - get() = ChatMember.Status.Left + override val status: ChatMember.Status = ChatMember.Status.Left } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/MemberChatMemberImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/MemberChatMemberImpl.kt index b2cc64be59..9edd84d50c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/MemberChatMemberImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/MemberChatMemberImpl.kt @@ -11,6 +11,5 @@ data class MemberChatMemberImpl( ) : MemberChatMember { @SerialName(statusField) @Required - override val status: ChatMember.Status - get() = ChatMember.Status.Member + override val status: ChatMember.Status = ChatMember.Status.Member } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/OwnerChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/OwnerChatMember.kt index 1a825d2db3..9be0119f5f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/OwnerChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/OwnerChatMember.kt @@ -45,6 +45,5 @@ data class OwnerChatMember( @SerialName(statusField) @Required - override val status: ChatMember.Status - get() = ChatMember.Status.Creator + override val status: ChatMember.Status = ChatMember.Status.Creator } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember.kt index 2529b77eff..1d1b3b9e6c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember.kt @@ -44,6 +44,5 @@ data class RestrictedChatMember( ) : BannedChatMember, SpecialRightsChatMember, ChatPermissions { @SerialName(statusField) @Required - override val status: ChatMember.Status - get() = ChatMember.Status.Restricted + override val status: ChatMember.Status = ChatMember.Status.Restricted } From 38c9732da56cd1a8aa4be10516ae1ce475acb060 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 29 Sep 2023 22:17:42 +0600 Subject: [PATCH 3/4] update ktor version --- CHANGELOG.md | 2 ++ gradle/libs.versions.toml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d695d5b89..1aceca33db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 9.2.1 +* `Version`: + * `Ktor`: `2.3.3` -> `2.3.4` * `Core`: * All `ChatMember` inheritors have fixes `status` field diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 202011f887..0fba10635e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,7 +8,7 @@ javax-activation = "1.1.1" korlibs = "4.0.3" uuid = "0.7.1" -ktor = "2.3.3" +ktor = "2.3.4" ksp = "1.8.22-1.0.11" kotlin-poet = "1.14.2" From 284fe58848f3628f15499257c168381f0f866be7 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 29 Sep 2023 22:38:22 +0600 Subject: [PATCH 4/4] upfix of chatmember statuses serialization --- .../tgbotapi/types/chat/member/ChatMember.kt | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/ChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/ChatMember.kt index d8ea2691e6..b2598b7d67 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/ChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/ChatMember.kt @@ -7,6 +7,7 @@ import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import kotlinx.serialization.DeserializationStrategy 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 @@ -15,8 +16,11 @@ import kotlinx.serialization.json.jsonPrimitive @Serializable(ChatMemberSerializer::class) sealed interface ChatMember : WithUser { - @Serializable - enum class Status(val status: String, val deserializationStrategy: DeserializationStrategy) { + @Serializable(StatusSerializer::class) + enum class Status( + val status: String, + val deserializationStrategy: DeserializationStrategy + ) { Creator("creator", OwnerChatMember.serializer()), Administrator("administrator", AdministratorChatMemberImpl.serializer()), Member("member", MemberChatMemberImpl.serializer()), @@ -24,6 +28,23 @@ sealed interface ChatMember : WithUser { Left("left", LeftChatMemberImpl.serializer()), Kicked("kicked", KickedChatMember.serializer()) } + + object StatusSerializer : KSerializer { + override val descriptor: SerialDescriptor + get() = String.serializer().descriptor + + override fun deserialize(decoder: Decoder): Status { + val status = decoder.decodeString() + return Status.values().first { + it.status == status + } + } + + override fun serialize(encoder: Encoder, value: Status) { + encoder.encodeString(value.status) + } + } + val status: Status }