1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-24 19:18:44 +00:00

improvements and breaking changes in ChatMember hierarchy

This commit is contained in:
InsanusMokrassar 2024-08-29 17:54:00 +06:00
parent 2d40af21fe
commit 10d92c2fdb
15 changed files with 266 additions and 131 deletions

View File

@ -2,12 +2,34 @@
## 18.0.0 ## 18.0.0
**THIS UPDATE CONTAINS BREAKING CHANGES**
---
**Migration (step-by-step)**
Replace in a whole project:
1. `RestrictedChatMember` -> `RestrictedMemberChatMember`
2. `BannedChatMember` -> `RestrictedChatMember`
---
**Changes:**
* `Version`: * `Version`:
* `Kotlin`: `2.0.10` -> `2.0.20` * `Kotlin`: `2.0.10` -> `2.0.20`
* `Serialization`: `1.7.1` -> `1.7.2` * `Serialization`: `1.7.1` -> `1.7.2`
* `MicroUtils`: `0.22.0` -> `0.22.1` * `MicroUtils`: `0.22.0` -> `0.22.1`
* `KSLog`: `1.3.5` -> `1.3.6` * `KSLog`: `1.3.5` -> `1.3.6`
* `Ktor`: `2.3.11` -> `2.3.12` * `Ktor`: `2.3.11` -> `2.3.12`
* `Core`:
* `RestrictedChatMember` has been renamed to `RestrictedMemberChatMember`
* `BannedChatMember` has been renamed to `RestrictedChatMember`
* `KickedChatMember` now implements `RestrictedChatMember` (due to rename)
* `Utils`:
* Add a lot of extensions like `ChatMember.isMember`
* Add a lot of extensions like `ChatMemberUpdated.joinedChat`
## 17.0.0 ## 17.0.0

View File

@ -1369,18 +1369,21 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/utils/Subconte
} }
public final class dev/inmo/tgbotapi/extensions/behaviour_builder/utils/extensions/ChatMemberKt { public final class dev/inmo/tgbotapi/extensions/behaviour_builder/utils/extensions/ChatMemberKt {
public static final fun getHasSpecialRights (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z
public static final fun isAdministrator (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z public static final fun isAdministrator (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z
public static final fun isAdministratorStrict (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z public static final fun isBanned (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z
public static final fun isCommonAdministrator (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z
public static final fun isCommonMember (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z
public static final fun isKicked (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z public static final fun isKicked (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z
public static final fun isKickedOrRestricted (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z public static final fun isKickedOrRestricted (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z
public static final fun isLeft (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z public static final fun isLeft (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z
public static final fun isLeftOrKicked (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z public static final fun isLeftOrKicked (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z
public static final fun isMember (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z public static final fun isMember (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z
public static final fun isMemberStrict (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z
public static final fun isOwner (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z public static final fun isOwner (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z
public static final fun isRestricted (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z public static final fun isRestricted (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z
public static final fun isSubscriber (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z public static final fun isRestrictedAndNotKicked (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z
public static final fun isRestrictedMember (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z
public static final fun isSpecialRightsMember (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z
public static final fun isSubscriberMember (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Z
} }
public final class dev/inmo/tgbotapi/extensions/behaviour_builder/utils/extensions/ChatMemberUpdatedKt { public final class dev/inmo/tgbotapi/extensions/behaviour_builder/utils/extensions/ChatMemberUpdatedKt {
@ -1395,8 +1398,9 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/utils/extensio
public static final fun getJoinedChat (Ldev/inmo/tgbotapi/types/chat/member/ChatMemberUpdated;)Z public static final fun getJoinedChat (Ldev/inmo/tgbotapi/types/chat/member/ChatMemberUpdated;)Z
public static final fun getLeftChat (Ldev/inmo/tgbotapi/types/chat/member/ChatMemberUpdated;)Z public static final fun getLeftChat (Ldev/inmo/tgbotapi/types/chat/member/ChatMemberUpdated;)Z
public static final fun getSubscribed (Ldev/inmo/tgbotapi/types/chat/member/ChatMemberUpdated;)Z public static final fun getSubscribed (Ldev/inmo/tgbotapi/types/chat/member/ChatMemberUpdated;)Z
public static final fun getSubscriptionChanged (Ldev/inmo/tgbotapi/types/chat/member/ChatMemberUpdated;)Z public static final fun getSubscriptionUpdated (Ldev/inmo/tgbotapi/types/chat/member/ChatMemberUpdated;)Z
public static final fun getUnsubscribed (Ldev/inmo/tgbotapi/types/chat/member/ChatMemberUpdated;)Z public static final fun getUnsubscribed (Ldev/inmo/tgbotapi/types/chat/member/ChatMemberUpdated;)Z
public static final fun getUnsubscribedAndLeft (Ldev/inmo/tgbotapi/types/chat/member/ChatMemberUpdated;)Z
} }
public final class dev/inmo/tgbotapi/extensions/behaviour_builder/utils/extensions/EnablePrivacyPolicyCommandKt { public final class dev/inmo/tgbotapi/extensions/behaviour_builder/utils/extensions/EnablePrivacyPolicyCommandKt {

View File

@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.filters package dev.inmo.tgbotapi.extensions.behaviour_builder.filters
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.extensions.* import dev.inmo.tgbotapi.extensions.utils.extensions.*
import dev.inmo.tgbotapi.types.chat.member.* import dev.inmo.tgbotapi.types.chat.member.*
/** /**
@ -26,10 +26,10 @@ val chatMemberSubscribedFilter = SimpleFilter<ChatMemberUpdated> {
} }
/** /**
* Allows only member [subscriptionChanged] updates * Allows only member [subscriptionUpdated] updates
*/ */
val chatMemberSubscriptionChangedFilter = SimpleFilter<ChatMemberUpdated> { val chatMemberSubscriptionChangedFilter = SimpleFilter<ChatMemberUpdated> {
it.subscriptionChanged it.subscriptionUpdated
} }
/** /**

View File

@ -1,24 +0,0 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.extensions
import dev.inmo.tgbotapi.types.chat.member.*
val ChatMember.isLeft: Boolean get() = this is LeftChatMember
val ChatMember.isKicked: Boolean get() = this is KickedChatMember
val ChatMember.isLeftOrKicked: Boolean get() = isLeft || isKicked
val ChatMember.isRestricted: Boolean get() = this is RestrictedChatMember
val ChatMember.isMember: Boolean get() = this is MemberChatMember
val ChatMember.isOwner: Boolean get() = this is OwnerChatMember
val ChatMember.isSubscriber: Boolean get() = this is SubscriptionMemberChatMember
val ChatMember.isAdministrator: Boolean get() = this is AdministratorChatMember
/**
* Checks if member is strictly [MemberChatMember], not any derivatives
*/
val ChatMember.isMemberStrict: Boolean get() = this is MemberChatMemberImpl
/**
* Checks if member is strictly [AdministratorChatMember], not any derivatives
*/
val ChatMember.isAdministratorStrict: Boolean get() = this is AdministratorChatMemberImpl
val ChatMember.hasSpecialRights: Boolean get() = this is SpecialRightsChatMember
val ChatMember.isKickedOrRestricted: Boolean get() = this is BannedChatMember

View File

@ -15681,14 +15681,6 @@ public final class dev/inmo/tgbotapi/types/chat/member/AdministratorChatMemberSe
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
} }
public abstract interface class dev/inmo/tgbotapi/types/chat/member/BannedChatMember : dev/inmo/tgbotapi/abstracts/types/UntilDate, dev/inmo/tgbotapi/types/chat/member/ChatMember {
public static final field Companion Ldev/inmo/tgbotapi/types/chat/member/BannedChatMember$Companion;
}
public final class dev/inmo/tgbotapi/types/chat/member/BannedChatMember$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public abstract interface class dev/inmo/tgbotapi/types/chat/member/ChatAdministratorRights : dev/inmo/tgbotapi/types/chat/member/SpecialChatAdministratorRights { public abstract interface class dev/inmo/tgbotapi/types/chat/member/ChatAdministratorRights : dev/inmo/tgbotapi/types/chat/member/SpecialChatAdministratorRights {
public static final field Companion Ldev/inmo/tgbotapi/types/chat/member/ChatAdministratorRights$Companion; public static final field Companion Ldev/inmo/tgbotapi/types/chat/member/ChatAdministratorRights$Companion;
public abstract fun getCanDeleteStories ()Z public abstract fun getCanDeleteStories ()Z
@ -15856,7 +15848,7 @@ public final class dev/inmo/tgbotapi/types/chat/member/ChatMemberUpdated$Compani
public final fun serializer ()Lkotlinx/serialization/KSerializer; public final fun serializer ()Lkotlinx/serialization/KSerializer;
} }
public final class dev/inmo/tgbotapi/types/chat/member/KickedChatMember : dev/inmo/tgbotapi/types/chat/member/BannedChatMember { public final class dev/inmo/tgbotapi/types/chat/member/KickedChatMember : dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember {
public static final field Companion Ldev/inmo/tgbotapi/types/chat/member/KickedChatMember$Companion; public static final field Companion Ldev/inmo/tgbotapi/types/chat/member/KickedChatMember$Companion;
public fun <init> (Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;)V public fun <init> (Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;)V
public synthetic fun <init> (Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun <init> (Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
@ -16008,8 +16000,18 @@ public final class dev/inmo/tgbotapi/types/chat/member/OwnerChatMember$Companion
public final fun serializer ()Lkotlinx/serialization/KSerializer; public final fun serializer ()Lkotlinx/serialization/KSerializer;
} }
public final class dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember : dev/inmo/tgbotapi/types/chat/ChatPermissions, dev/inmo/tgbotapi/types/chat/member/BannedChatMember, dev/inmo/tgbotapi/types/chat/member/SpecialRightsChatMember { public abstract interface class dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember : dev/inmo/tgbotapi/abstracts/types/UntilDate, dev/inmo/tgbotapi/types/chat/member/ChatMember {
public static final field Companion Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMember$Companion; public static final field Companion Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMember$Companion;
}
public final class dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember$Companion {
public final fun invoke (Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;ZZZZZZZZZZZZZZZ)Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMemberImpl;
public static synthetic fun invoke$default (Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMember$Companion;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;ZZZZZZZZZZZZZZZILjava/lang/Object;)Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMemberImpl;
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class dev/inmo/tgbotapi/types/chat/member/RestrictedChatMemberImpl : dev/inmo/tgbotapi/types/chat/ChatPermissions, dev/inmo/tgbotapi/types/chat/member/MemberChatMember, dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember, dev/inmo/tgbotapi/types/chat/member/SpecialRightsChatMember {
public static final field Companion Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMemberImpl$Companion;
public fun <init> (Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;ZZZZZZZZZZZZZZZ)V public fun <init> (Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;ZZZZZZZZZZZZZZZ)V
public synthetic fun <init> (Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;ZZZZZZZZZZZZZZZILkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun <init> (Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;ZZZZZZZZZZZZZZZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ldev/inmo/tgbotapi/types/chat/User; public final fun component1 ()Ldev/inmo/tgbotapi/types/chat/User;
@ -16029,8 +16031,8 @@ public final class dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember : de
public final fun component7 ()Z public final fun component7 ()Z
public final fun component8 ()Z public final fun component8 ()Z
public final fun component9 ()Z public final fun component9 ()Z
public final fun copy (Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;ZZZZZZZZZZZZZZZ)Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMember; public final fun copy (Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;ZZZZZZZZZZZZZZZ)Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMemberImpl;
public static synthetic fun copy$default (Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMember;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;ZZZZZZZZZZZZZZZILjava/lang/Object;)Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMember; public static synthetic fun copy$default (Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMemberImpl;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/TelegramDate;ZZZZZZZZZZZZZZZILjava/lang/Object;)Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMemberImpl;
public fun copyCommon (Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;)Ldev/inmo/tgbotapi/types/chat/ChatPermissions; public fun copyCommon (Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;)Ldev/inmo/tgbotapi/types/chat/ChatPermissions;
public fun copyGranular (Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;)Ldev/inmo/tgbotapi/types/chat/ChatPermissions; public fun copyGranular (Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;)Ldev/inmo/tgbotapi/types/chat/ChatPermissions;
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
@ -16062,18 +16064,18 @@ public final class dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember : de
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
} }
public synthetic class dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public synthetic class dev/inmo/tgbotapi/types/chat/member/RestrictedChatMemberImpl$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMember$$serializer; public static final field INSTANCE Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMemberImpl$$serializer;
public final fun childSerializers ()[Lkotlinx/serialization/KSerializer; public final fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMember; public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMemberImpl;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMember;)V public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMemberImpl;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
} }
public final class dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember$Companion { public final class dev/inmo/tgbotapi/types/chat/member/RestrictedChatMemberImpl$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer; public final fun serializer ()Lkotlinx/serialization/KSerializer;
} }

View File

@ -1,7 +0,0 @@
package dev.inmo.tgbotapi.types.chat.member
import dev.inmo.tgbotapi.abstracts.types.UntilDate
import kotlinx.serialization.Serializable
@Serializable(ChatMemberSerializer::class)
sealed interface BannedChatMember : ChatMember, UntilDate

View File

@ -12,7 +12,6 @@ import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonPrimitive import kotlinx.serialization.json.jsonPrimitive
@ -28,7 +27,7 @@ sealed interface ChatMember : WithUser {
Administrator("administrator", AdministratorChatMemberImpl.serializer()), Administrator("administrator", AdministratorChatMemberImpl.serializer()),
Member("member", MemberChatMemberImpl.serializer(), { status, json -> status == "member" && json[untilDateField] ?.jsonPrimitive == null }), Member("member", MemberChatMemberImpl.serializer(), { status, json -> status == "member" && json[untilDateField] ?.jsonPrimitive == null }),
SubscriptionMember("member", SubscriptionMemberChatMemberImpl.serializer(), { status, json -> status == "member" && json[untilDateField] ?.jsonPrimitive != null }), SubscriptionMember("member", SubscriptionMemberChatMemberImpl.serializer(), { status, json -> status == "member" && json[untilDateField] ?.jsonPrimitive != null }),
Restricted("restricted", RestrictedChatMember.serializer()), Restricted("restricted", RestrictedMemberChatMember.serializer()),
Left("left", LeftChatMemberImpl.serializer()), Left("left", LeftChatMemberImpl.serializer()),
Kicked("kicked", KickedChatMember.serializer()) Kicked("kicked", KickedChatMember.serializer())
} }
@ -74,7 +73,7 @@ object ChatMemberSerializer : KSerializer<ChatMember> {
is AdministratorChatMemberImpl -> AdministratorChatMemberImpl.serializer().serialize(encoder, value) is AdministratorChatMemberImpl -> AdministratorChatMemberImpl.serializer().serialize(encoder, value)
is SubscriptionMemberChatMemberImpl -> SubscriptionMemberChatMemberImpl.serializer().serialize(encoder, value) is SubscriptionMemberChatMemberImpl -> SubscriptionMemberChatMemberImpl.serializer().serialize(encoder, value)
is MemberChatMemberImpl -> MemberChatMemberImpl.serializer().serialize(encoder, value) is MemberChatMemberImpl -> MemberChatMemberImpl.serializer().serialize(encoder, value)
is RestrictedChatMember -> RestrictedChatMember.serializer().serialize(encoder, value) is RestrictedMemberChatMember -> RestrictedMemberChatMember.serializer().serialize(encoder, value)
is LeftChatMemberImpl -> LeftChatMemberImpl.serializer().serialize(encoder, value) is LeftChatMemberImpl -> LeftChatMemberImpl.serializer().serialize(encoder, value)
is KickedChatMember -> KickedChatMember.serializer().serialize(encoder, value) is KickedChatMember -> KickedChatMember.serializer().serialize(encoder, value)
} }

View File

@ -10,7 +10,7 @@ data class KickedChatMember(
override val user: User, override val user: User,
@SerialName(untilDateField) @SerialName(untilDateField)
override val untilDate: TelegramDate? = null override val untilDate: TelegramDate? = null
) : BannedChatMember { ) : RestrictedChatMember {
@SerialName(statusField) @SerialName(statusField)
@Required @Required
@EncodeDefault @EncodeDefault

View File

@ -1,49 +1,60 @@
package dev.inmo.tgbotapi.types.chat.member package dev.inmo.tgbotapi.types.chat.member
import dev.inmo.tgbotapi.abstracts.types.UntilDate
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.ChatPermissions
import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.types.chat.User
import kotlinx.serialization.* import kotlinx.serialization.Serializable
@Serializable @Serializable(ChatMemberSerializer::class)
data class RestrictedChatMember( sealed interface RestrictedChatMember : ChatMember, UntilDate {
@SerialName(userField) companion object {
override val user: User, // backward compatibility fun
@SerialName(untilDateField) @Deprecated(
override val untilDate: TelegramDate? = null, "Renamed",
@SerialName(isMemberField) ReplaceWith(
val isMember: Boolean = false, "RestrictedChatMemberImpl(user, untilDate, isMember, canSendMessages, canSendAudios, canSendDocuments, canSendPhotos, canSendVideos, canSendVideoNotes, canSendVoiceNotes, canSendPolls, canSendOtherMessages, canAddWebPagePreviews, canChangeInfo, canInviteUsers, canPinMessages, canManageTopics)",
@SerialName(canSendMessagesField) "dev.inmo.tgbotapi.types.chat.members.RestrictedChatMemberImpl",
override val canSendMessages: Boolean = false, )
@SerialName(canSendAudiosField) )
override val canSendAudios: Boolean = false, operator fun invoke(
@SerialName(canSendDocumentsField) user: User,
override val canSendDocuments: Boolean = false, untilDate: TelegramDate? = null,
@SerialName(canSendPhotosField) isMember: Boolean = false,
override val canSendPhotos: Boolean = false, canSendMessages: Boolean = false,
@SerialName(canSendVideosField) canSendAudios: Boolean = false,
override val canSendVideos: Boolean = false, canSendDocuments: Boolean = false,
@SerialName(canSendVideoNotesField) canSendPhotos: Boolean = false,
override val canSendVideoNotes: Boolean = false, canSendVideos: Boolean = false,
@SerialName(canSendVoiceNotesField) canSendVideoNotes: Boolean = false,
override val canSendVoiceNotes: Boolean = false, canSendVoiceNotes: Boolean = false,
@SerialName(canSendPollsField) canSendPolls: Boolean = false,
override val canSendPolls: Boolean = false, canSendOtherMessages: Boolean = false,
@SerialName(canSendOtherMessagesField) canAddWebPagePreviews: Boolean = false,
override val canSendOtherMessages: Boolean = false, canChangeInfo: Boolean = false,
@SerialName(canAddWebPagePreviewsField) canInviteUsers: Boolean = false,
override val canAddWebPagePreviews: Boolean = false, canPinMessages: Boolean = false,
@SerialName(canChangeInfoField) canManageTopics: Boolean = false
override val canChangeInfo: Boolean = false, ) = RestrictedMemberChatMember(
@SerialName(canInviteUsersField) user = user,
override val canInviteUsers: Boolean = false, untilDate = untilDate,
@SerialName(canPinMessagesField) isMember = isMember,
override val canPinMessages: Boolean = false, canSendMessages = canSendMessages,
@SerialName(canManageTopicsField) canSendAudios = canSendAudios,
override val canManageTopics: Boolean = false canSendDocuments = canSendDocuments,
) : BannedChatMember, SpecialRightsChatMember, ChatPermissions { canSendPhotos = canSendPhotos,
@SerialName(statusField) canSendVideos = canSendVideos,
@Required canSendVideoNotes = canSendVideoNotes,
@EncodeDefault canSendVoiceNotes = canSendVoiceNotes,
override val status: ChatMember.Status = ChatMember.Status.Restricted canSendPolls = canSendPolls,
canSendOtherMessages = canSendOtherMessages,
canAddWebPagePreviews = canAddWebPagePreviews,
canChangeInfo = canChangeInfo,
canInviteUsers = canInviteUsers,
canPinMessages = canPinMessages,
canManageTopics = canManageTopics
)
} }
}
@Deprecated("Renamed", ReplaceWith("RestrictedChatMember", "dev.inmo.tgbotapi.types.chat.member.RestrictedChatMember"))
typealias BannedChatMember = RestrictedChatMember

View File

@ -0,0 +1,53 @@
package dev.inmo.tgbotapi.types.chat.member
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.ChatPermissions
import dev.inmo.tgbotapi.types.chat.User
import kotlinx.serialization.*
/**
* Represents `ChatMemberRestricted` from telegram bots api and means that member is still member of chat but has been
* restricted in his rights
*/
@Serializable
data class RestrictedMemberChatMember(
@SerialName(userField)
override val user: User,
@SerialName(untilDateField)
override val untilDate: TelegramDate? = null,
@SerialName(isMemberField)
val isMember: Boolean = false,
@SerialName(canSendMessagesField)
override val canSendMessages: Boolean = false,
@SerialName(canSendAudiosField)
override val canSendAudios: Boolean = false,
@SerialName(canSendDocumentsField)
override val canSendDocuments: Boolean = false,
@SerialName(canSendPhotosField)
override val canSendPhotos: Boolean = false,
@SerialName(canSendVideosField)
override val canSendVideos: Boolean = false,
@SerialName(canSendVideoNotesField)
override val canSendVideoNotes: Boolean = false,
@SerialName(canSendVoiceNotesField)
override val canSendVoiceNotes: Boolean = false,
@SerialName(canSendPollsField)
override val canSendPolls: Boolean = false,
@SerialName(canSendOtherMessagesField)
override val canSendOtherMessages: Boolean = false,
@SerialName(canAddWebPagePreviewsField)
override val canAddWebPagePreviews: Boolean = false,
@SerialName(canChangeInfoField)
override val canChangeInfo: Boolean = false,
@SerialName(canInviteUsersField)
override val canInviteUsers: Boolean = false,
@SerialName(canPinMessagesField)
override val canPinMessages: Boolean = false,
@SerialName(canManageTopicsField)
override val canManageTopics: Boolean = false
) : RestrictedChatMember, SpecialRightsChatMember, MemberChatMember, ChatPermissions {
@SerialName(statusField)
@Required
@EncodeDefault
override val status: ChatMember.Status = ChatMember.Status.Restricted
}

View File

@ -20,7 +20,7 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsKt {
public static final fun asAudioMediaGroupMemberTelegramMedia (Ldev/inmo/tgbotapi/types/media/TelegramFreeMedia;)Ldev/inmo/tgbotapi/types/media/AudioMediaGroupMemberTelegramMedia; public static final fun asAudioMediaGroupMemberTelegramMedia (Ldev/inmo/tgbotapi/types/media/TelegramFreeMedia;)Ldev/inmo/tgbotapi/types/media/AudioMediaGroupMemberTelegramMedia;
public static final fun asBankStatement (Ldev/inmo/tgbotapi/types/passport/encrypted/abstracts/EncryptedPassportElement;)Ldev/inmo/tgbotapi/types/passport/encrypted/BankStatement; public static final fun asBankStatement (Ldev/inmo/tgbotapi/types/passport/encrypted/abstracts/EncryptedPassportElement;)Ldev/inmo/tgbotapi/types/passport/encrypted/BankStatement;
public static final fun asBankStatementSecureValue (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/BankStatementSecureValue; public static final fun asBankStatementSecureValue (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/BankStatementSecureValue;
public static final fun asBannedChatMember (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Ldev/inmo/tgbotapi/types/chat/member/BannedChatMember; public static final fun asBannedChatMember (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMember;
public static final fun asBaseChosenInlineResult (Ldev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/ChosenInlineResult;)Ldev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/BaseChosenInlineResult; public static final fun asBaseChosenInlineResult (Ldev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/ChosenInlineResult;)Ldev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/BaseChosenInlineResult;
public static final fun asBaseEditMessageUpdate (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/abstracts/BaseEditMessageUpdate; public static final fun asBaseEditMessageUpdate (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/abstracts/BaseEditMessageUpdate;
public static final fun asBaseInlineQuery (Ldev/inmo/tgbotapi/types/InlineQueries/query/InlineQuery;)Ldev/inmo/tgbotapi/types/InlineQueries/query/BaseInlineQuery; public static final fun asBaseInlineQuery (Ldev/inmo/tgbotapi/types/InlineQueries/query/InlineQuery;)Ldev/inmo/tgbotapi/types/InlineQueries/query/BaseInlineQuery;
@ -256,7 +256,7 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsKt {
public static final fun asRentalAgreementSecureValue (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/RentalAgreementSecureValue; public static final fun asRentalAgreementSecureValue (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/RentalAgreementSecureValue;
public static final fun asReplyKeyboardMarkup (Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup;)Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup; public static final fun asReplyKeyboardMarkup (Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup;)Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup;
public static final fun asReplyKeyboardRemove (Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup;)Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardRemove; public static final fun asReplyKeyboardRemove (Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup;)Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardRemove;
public static final fun asRestrictedChatMember (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMember; public static final fun asRestrictedChatMember (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMemberImpl;
public static final fun asSecondaryChatInviteLink (Ldev/inmo/tgbotapi/types/ChatInviteLink;)Ldev/inmo/tgbotapi/types/SecondaryChatInviteLink; public static final fun asSecondaryChatInviteLink (Ldev/inmo/tgbotapi/types/ChatInviteLink;)Ldev/inmo/tgbotapi/types/SecondaryChatInviteLink;
public static final fun asSecureValueIdentity (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValueIdentity; public static final fun asSecureValueIdentity (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValueIdentity;
public static final fun asSecureValueWithData (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValueWithData; public static final fun asSecureValueWithData (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValueWithData;
@ -363,7 +363,7 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsKt {
public static final fun requireAudioMediaGroupMemberTelegramMedia (Ldev/inmo/tgbotapi/types/media/TelegramFreeMedia;)Ldev/inmo/tgbotapi/types/media/AudioMediaGroupMemberTelegramMedia; public static final fun requireAudioMediaGroupMemberTelegramMedia (Ldev/inmo/tgbotapi/types/media/TelegramFreeMedia;)Ldev/inmo/tgbotapi/types/media/AudioMediaGroupMemberTelegramMedia;
public static final fun requireBankStatement (Ldev/inmo/tgbotapi/types/passport/encrypted/abstracts/EncryptedPassportElement;)Ldev/inmo/tgbotapi/types/passport/encrypted/BankStatement; public static final fun requireBankStatement (Ldev/inmo/tgbotapi/types/passport/encrypted/abstracts/EncryptedPassportElement;)Ldev/inmo/tgbotapi/types/passport/encrypted/BankStatement;
public static final fun requireBankStatementSecureValue (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/BankStatementSecureValue; public static final fun requireBankStatementSecureValue (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/BankStatementSecureValue;
public static final fun requireBannedChatMember (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Ldev/inmo/tgbotapi/types/chat/member/BannedChatMember; public static final fun requireBannedChatMember (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMember;
public static final fun requireBaseChosenInlineResult (Ldev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/ChosenInlineResult;)Ldev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/BaseChosenInlineResult; public static final fun requireBaseChosenInlineResult (Ldev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/ChosenInlineResult;)Ldev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/BaseChosenInlineResult;
public static final fun requireBaseEditMessageUpdate (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/abstracts/BaseEditMessageUpdate; public static final fun requireBaseEditMessageUpdate (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/abstracts/BaseEditMessageUpdate;
public static final fun requireBaseInlineQuery (Ldev/inmo/tgbotapi/types/InlineQueries/query/InlineQuery;)Ldev/inmo/tgbotapi/types/InlineQueries/query/BaseInlineQuery; public static final fun requireBaseInlineQuery (Ldev/inmo/tgbotapi/types/InlineQueries/query/InlineQuery;)Ldev/inmo/tgbotapi/types/InlineQueries/query/BaseInlineQuery;
@ -599,7 +599,7 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsKt {
public static final fun requireRentalAgreementSecureValue (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/RentalAgreementSecureValue; public static final fun requireRentalAgreementSecureValue (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/RentalAgreementSecureValue;
public static final fun requireReplyKeyboardMarkup (Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup;)Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup; public static final fun requireReplyKeyboardMarkup (Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup;)Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardMarkup;
public static final fun requireReplyKeyboardRemove (Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup;)Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardRemove; public static final fun requireReplyKeyboardRemove (Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup;)Ldev/inmo/tgbotapi/types/buttons/ReplyKeyboardRemove;
public static final fun requireRestrictedChatMember (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMember; public static final fun requireRestrictedChatMember (Ldev/inmo/tgbotapi/types/chat/member/ChatMember;)Ldev/inmo/tgbotapi/types/chat/member/RestrictedChatMemberImpl;
public static final fun requireSecondaryChatInviteLink (Ldev/inmo/tgbotapi/types/ChatInviteLink;)Ldev/inmo/tgbotapi/types/SecondaryChatInviteLink; public static final fun requireSecondaryChatInviteLink (Ldev/inmo/tgbotapi/types/ChatInviteLink;)Ldev/inmo/tgbotapi/types/SecondaryChatInviteLink;
public static final fun requireSecureValueIdentity (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValueIdentity; public static final fun requireSecureValueIdentity (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValueIdentity;
public static final fun requireSecureValueWithData (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValueWithData; public static final fun requireSecureValueWithData (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValueWithData;
@ -1095,8 +1095,6 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt {
public static final fun bankStatementOrThrow (Ldev/inmo/tgbotapi/types/passport/encrypted/abstracts/EncryptedPassportElement;)Ldev/inmo/tgbotapi/types/passport/encrypted/BankStatement; public static final fun bankStatementOrThrow (Ldev/inmo/tgbotapi/types/passport/encrypted/abstracts/EncryptedPassportElement;)Ldev/inmo/tgbotapi/types/passport/encrypted/BankStatement;
public static final fun bankStatementSecureValueOrNull (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/BankStatementSecureValue; public static final fun bankStatementSecureValueOrNull (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/BankStatementSecureValue;
public static final fun bankStatementSecureValueOrThrow (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/BankStatementSecureValue; public static final fun bankStatementSecureValueOrThrow (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;)Ldev/inmo/tgbotapi/types/passport/decrypted/BankStatementSecureValue;
public static final fun bannedChatMemberOrNull (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;)Ldev/inmo/tgbotapi/types/chat/member/BannedChatMember;
public static final fun bannedChatMemberOrThrow (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;)Ldev/inmo/tgbotapi/types/chat/member/BannedChatMember;
public static final fun baseChosenInlineResultOrNull (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;)Ldev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/BaseChosenInlineResult; public static final fun baseChosenInlineResultOrNull (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;)Ldev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/BaseChosenInlineResult;
public static final fun baseChosenInlineResultOrThrow (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;)Ldev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/BaseChosenInlineResult; public static final fun baseChosenInlineResultOrThrow (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;)Ldev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/BaseChosenInlineResult;
public static final fun baseEditMessageUpdateOrNull (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/abstracts/BaseEditMessageUpdate; public static final fun baseEditMessageUpdateOrNull (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/abstracts/BaseEditMessageUpdate;
@ -1490,7 +1488,6 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt {
public static final fun ifAudioMediaGroupPartContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifAudioMediaGroupPartContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifBankStatement (Ldev/inmo/tgbotapi/types/passport/encrypted/abstracts/EncryptedPassportElement;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifBankStatement (Ldev/inmo/tgbotapi/types/passport/encrypted/abstracts/EncryptedPassportElement;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifBankStatementSecureValue (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifBankStatementSecureValue (Ldev/inmo/tgbotapi/types/passport/decrypted/abstracts/SecureValue;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifBannedChatMember (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifBaseChosenInlineResult (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifBaseChosenInlineResult (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifBaseEditMessageUpdate (Ldev/inmo/tgbotapi/types/update/abstracts/Update;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifBaseEditMessageUpdate (Ldev/inmo/tgbotapi/types/update/abstracts/Update;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifBaseInlineQuery (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ifBaseInlineQuery (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;

View File

@ -1961,14 +1961,14 @@ inline fun ChatMember.asMemberChatMember(): MemberChatMember? = this as? MemberC
inline fun ChatMember.requireMemberChatMember(): MemberChatMember = this as MemberChatMember inline fun ChatMember.requireMemberChatMember(): MemberChatMember = this as MemberChatMember
@PreviewFeature @PreviewFeature
inline fun <T> ChatMember.whenRestrictedChatMember(block: (RestrictedChatMember) -> T) = inline fun <T> ChatMember.whenRestrictedChatMember(block: (RestrictedMemberChatMember) -> T) =
asRestrictedChatMember()?.let(block) asRestrictedChatMember()?.let(block)
@PreviewFeature @PreviewFeature
inline fun ChatMember.asRestrictedChatMember(): RestrictedChatMember? = this as? RestrictedChatMember inline fun ChatMember.asRestrictedChatMember(): RestrictedMemberChatMember? = this as? RestrictedMemberChatMember
@PreviewFeature @PreviewFeature
inline fun ChatMember.requireRestrictedChatMember(): RestrictedChatMember = this as RestrictedChatMember inline fun ChatMember.requireRestrictedChatMember(): RestrictedMemberChatMember = this as RestrictedMemberChatMember
@PreviewFeature @PreviewFeature
inline fun <T> ChatMember.whenAdministratorChatMember(block: (AdministratorChatMember) -> T) = inline fun <T> ChatMember.whenAdministratorChatMember(block: (AdministratorChatMember) -> T) =
@ -1981,13 +1981,13 @@ inline fun ChatMember.asAdministratorChatMember(): AdministratorChatMember? = th
inline fun ChatMember.requireAdministratorChatMember(): AdministratorChatMember = this as AdministratorChatMember inline fun ChatMember.requireAdministratorChatMember(): AdministratorChatMember = this as AdministratorChatMember
@PreviewFeature @PreviewFeature
inline fun <T> ChatMember.whenBannedChatMember(block: (BannedChatMember) -> T) = asBannedChatMember()?.let(block) inline fun <T> ChatMember.whenBannedChatMember(block: (RestrictedChatMember) -> T) = asBannedChatMember()?.let(block)
@PreviewFeature @PreviewFeature
inline fun ChatMember.asBannedChatMember(): BannedChatMember? = this as? BannedChatMember inline fun ChatMember.asBannedChatMember(): RestrictedChatMember? = this as? RestrictedChatMember
@PreviewFeature @PreviewFeature
inline fun ChatMember.requireBannedChatMember(): BannedChatMember = this as BannedChatMember inline fun ChatMember.requireBannedChatMember(): RestrictedChatMember = this as RestrictedChatMember
@PreviewFeature @PreviewFeature
inline fun <T> ChatMember.whenSpecialRightsChatMember(block: (SpecialRightsChatMember) -> T) = inline fun <T> ChatMember.whenSpecialRightsChatMember(block: (SpecialRightsChatMember) -> T) =

View File

@ -161,7 +161,6 @@ import dev.inmo.tgbotapi.types.chat.UnknownExtendedChat
import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.chat.UsernameChat import dev.inmo.tgbotapi.types.chat.UsernameChat
import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember
import dev.inmo.tgbotapi.types.chat.member.BannedChatMember
import dev.inmo.tgbotapi.types.chat.member.ChatMember import dev.inmo.tgbotapi.types.chat.member.ChatMember
import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated
import dev.inmo.tgbotapi.types.chat.member.KickedChatMember import dev.inmo.tgbotapi.types.chat.member.KickedChatMember
@ -691,15 +690,6 @@ public inline fun <T>
OptionallyWithUser.ifAdministratorChatMember(block: (AdministratorChatMember) -> T): T? = OptionallyWithUser.ifAdministratorChatMember(block: (AdministratorChatMember) -> T): T? =
administratorChatMemberOrNull() ?.let(block) administratorChatMemberOrNull() ?.let(block)
public inline fun OptionallyWithUser.bannedChatMemberOrNull(): BannedChatMember? = this as?
dev.inmo.tgbotapi.types.chat.member.BannedChatMember
public inline fun OptionallyWithUser.bannedChatMemberOrThrow(): BannedChatMember = this as
dev.inmo.tgbotapi.types.chat.member.BannedChatMember
public inline fun <T> OptionallyWithUser.ifBannedChatMember(block: (BannedChatMember) -> T): T? =
bannedChatMemberOrNull() ?.let(block)
public inline fun OptionallyWithUser.chatMemberOrNull(): ChatMember? = this as? public inline fun OptionallyWithUser.chatMemberOrNull(): ChatMember? = this as?
dev.inmo.tgbotapi.types.chat.member.ChatMember dev.inmo.tgbotapi.types.chat.member.ChatMember

View File

@ -0,0 +1,81 @@
package dev.inmo.tgbotapi.extensions.utils.extensions
import dev.inmo.tgbotapi.types.chat.member.*
/**
* Check if receiver object is [LeftChatMember]
*/
val ChatMember.isLeft: Boolean get() = this is LeftChatMember
/**
* Check if receiver object is [MemberChatMember]
*/
val ChatMember.isMember: Boolean get() = this is MemberChatMember
/**
* Check if receiver object is [RestrictedMemberChatMember]
*/
val ChatMember.isRestrictedMember: Boolean get() = this is RestrictedMemberChatMember
/**
* Check if receiver object is [MemberChatMemberImpl]
*/
val ChatMember.isCommonMember: Boolean get() = this is MemberChatMemberImpl
/**
* Check if receiver object is [SubscriptionMemberChatMember]
*/
val ChatMember.isSubscriberMember: Boolean get() = this is SubscriptionMemberChatMember
/**
* Check if receiver object is [RestrictedChatMember]
*/
val ChatMember.isRestricted: Boolean get() = this is RestrictedChatMember
/**
* Check if receiver object is [KickedChatMember]
*/
val ChatMember.isKicked: Boolean get() = this is KickedChatMember
/**
* Check if receiver object [isLeft] or [isKicked]
*/
val ChatMember.isLeftOrKicked: Boolean get() = isLeft || isKicked
/**
* Check if receiver object [isRestricted] and not [isKicked]
*/
val ChatMember.isRestrictedAndNotKicked: Boolean get() = isRestricted && !isKicked
/**
* Check if receiver object is [SpecialRightsChatMember]
*/
val ChatMember.isSpecialRightsMember: Boolean get() = this is SpecialRightsChatMember
/**
* Check if receiver object is [AdministratorChatMember]
*/
val ChatMember.isAdministrator: Boolean get() = this is AdministratorChatMember
/**
* Check if receiver object is [OwnerChatMember]
*/
val ChatMember.isOwner: Boolean get() = this is OwnerChatMember
/**
* Check if receiver object is [AdministratorChatMemberImpl]
*/
val ChatMember.isCommonAdministrator: Boolean get() = this is AdministratorChatMemberImpl
/**
* Check that member is [KickedChatMember]
*/
val ChatMember.isBanned: Boolean get() = this is KickedChatMember
/**
* Check that member is [RestrictedChatMember]
*/
val ChatMember.isKickedOrRestricted: Boolean get() = this is RestrictedChatMember

View File

@ -1,4 +1,4 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.extensions package dev.inmo.tgbotapi.extensions.utils.extensions
import dev.inmo.tgbotapi.types.chat.member.* import dev.inmo.tgbotapi.types.chat.member.*
@ -15,17 +15,24 @@ val ChatMemberUpdated.leftChat get() = !oldChatMemberState.isLeftOrKicked && new
/** /**
* Member became a chat subscriber * Member became a chat subscriber
*/ */
val ChatMemberUpdated.subscribed: Boolean get() = !oldChatMemberState.isSubscriber && newChatMemberState.isSubscriber val ChatMemberUpdated.subscribed: Boolean get() = !oldChatMemberState.isSubscriberMember && newChatMemberState.isSubscriberMember
/** /**
* Member became a chat subscriber or renewed their subscription * Member became a chat subscriber or renewed their subscription
*/ */
val ChatMemberUpdated.subscriptionChanged: Boolean get() = newChatMemberState.isSubscriber val ChatMemberUpdated.subscriptionUpdated: Boolean get() = newChatMemberState.isSubscriberMember
/** /**
* Member subscription was expired * Member subscription was expired. User still can be a member
*
* @see unsubscribedAndLeft
*/ */
val ChatMemberUpdated.unsubscribed: Boolean get() = oldChatMemberState.isSubscriber && !newChatMemberState.isSubscriber val ChatMemberUpdated.unsubscribed: Boolean get() = oldChatMemberState.isSubscriberMember && !newChatMemberState.isSubscriberMember
/**
* Member subscription was expired and user left the chat
*/
val ChatMemberUpdated.unsubscribedAndLeft: Boolean get() = oldChatMemberState.isSubscriberMember && !newChatMemberState.isMember
/** /**
* Member was promoted to chat administrator (or owner) * Member was promoted to chat administrator (or owner)