1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-22 16:47:13 +00:00

CreatorChatMember -> OwnerChatMember

This commit is contained in:
InsanusMokrassar 2022-07-11 01:56:31 +06:00
parent fde2c79f4c
commit 678f79da04
4 changed files with 10 additions and 6 deletions

View File

@ -12,6 +12,7 @@
* New companion functions:
* `ReplyForce#Selective`
* `ReplyForce#NonSelective`
* Rename `CreatorChatMember` -> `OwnerChatMember`
* `API`:
* For `copyMessage` order of parameters has been changed
* `Utils`:

View File

@ -22,7 +22,7 @@ object ChatMemberSerializer : KSerializer<ChatMember> {
override fun deserialize(decoder: Decoder): ChatMember {
val json = JsonObject.serializer().deserialize(decoder)
return when (json[statusField] ?.jsonPrimitive ?.content ?: error("Status field of chat member must be specified, but incoming json contains next: $json")) {
"creator" -> nonstrictJsonFormat.decodeFromJsonElement(CreatorChatMember.serializer(), json)
"creator" -> nonstrictJsonFormat.decodeFromJsonElement(OwnerChatMember.serializer(), json)
"administrator" -> nonstrictJsonFormat.decodeFromJsonElement(AdministratorChatMemberImpl.serializer(), json)
"member" -> nonstrictJsonFormat.decodeFromJsonElement(MemberChatMemberImpl.serializer(), json)
"restricted" -> nonstrictJsonFormat.decodeFromJsonElement(RestrictedChatMember.serializer(), json)
@ -34,7 +34,7 @@ object ChatMemberSerializer : KSerializer<ChatMember> {
override fun serialize(encoder: Encoder, value: ChatMember) {
when (value) {
is CreatorChatMember -> CreatorChatMember.serializer()
is OwnerChatMember -> OwnerChatMember.serializer()
is AdministratorChatMemberImpl -> AdministratorChatMemberImpl.serializer()
is MemberChatMember -> MemberChatMemberImpl.serializer()
is RestrictedChatMember -> RestrictedChatMember.serializer()

View File

@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.types.chat.User
import kotlinx.serialization.*
@Serializable
data class CreatorChatMember(
data class OwnerChatMember(
override val user: User,
@SerialName(isAnonymousField)
override val isAnonymous: Boolean = false,
@ -38,3 +38,6 @@ data class CreatorChatMember(
@Required
private val type: String = "creator"
}
@Deprecated("Renamed", ReplaceWith("OwnerChatMember", "dev.inmo.tgbotapi.types.chat.member.OwnerChatMember"))
typealias CreatorChatMember = OwnerChatMember

View File

@ -1828,13 +1828,13 @@ inline fun InlineQueryResult.requireInlineQueryResultVoiceCommon(): InlineQueryR
this as InlineQueryResultVoiceCommon
@PreviewFeature
inline fun <T> ChatMember.whenCreatorChatMember(block: (CreatorChatMember) -> T) = asCreatorChatMember() ?.let(block)
inline fun <T> ChatMember.whenCreatorChatMember(block: (OwnerChatMember) -> T) = asCreatorChatMember() ?.let(block)
@PreviewFeature
inline fun ChatMember.asCreatorChatMember(): CreatorChatMember? = this as? CreatorChatMember
inline fun ChatMember.asCreatorChatMember(): OwnerChatMember? = this as? OwnerChatMember
@PreviewFeature
inline fun ChatMember.requireCreatorChatMember(): CreatorChatMember = this as CreatorChatMember
inline fun ChatMember.requireCreatorChatMember(): OwnerChatMember = this as OwnerChatMember
@PreviewFeature
inline fun <T> ChatMember.whenKickedChatMember(block: (KickedChatMember) -> T) = asKickedChatMember() ?.let(block)