mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 00:03:48 +00:00
commit
051210caf5
@ -1,5 +1,12 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 9.2.1
|
||||
|
||||
* `Version`:
|
||||
* `Ktor`: `2.3.3` -> `2.3.4`
|
||||
* `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)**
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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<ChatMember>) {
|
||||
@Serializable(StatusSerializer::class)
|
||||
enum class Status(
|
||||
val status: String,
|
||||
val deserializationStrategy: DeserializationStrategy<ChatMember>
|
||||
) {
|
||||
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<Status> {
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user