mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-16 13:49:26 +00:00
improve class casts including filtering
This commit is contained in:
@@ -8,7 +8,7 @@ import dev.inmo.tgbotapi.types.chat.User
|
||||
*
|
||||
* @see FromUser
|
||||
*/
|
||||
@ClassCastsIncluded
|
||||
@ClassCastsIncluded(excludeRegex = ".*Impl")
|
||||
interface WithUser {
|
||||
val user: User
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(InlineQueryResultSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
@ClassCastsIncluded(excludeRegex = ".*Impl")
|
||||
interface InlineQueryResult {
|
||||
val type: String
|
||||
val id: InlineQueryIdentifier
|
||||
|
@@ -49,7 +49,7 @@ sealed interface AbleToAddInAttachmentMenuChat : Chat {
|
||||
}
|
||||
|
||||
@Serializable(PreviewChatSerializer::class)
|
||||
@ClassCastsIncluded(excludeRegex = ".*Impl.kt")
|
||||
@ClassCastsIncluded(excludeRegex = ".*Impl")
|
||||
sealed interface Chat {
|
||||
val id: IdChatIdentifier
|
||||
}
|
||||
|
@@ -4,12 +4,14 @@ import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsExcluded
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
@Serializable
|
||||
@RiskFeature("This class is a subject of changes. It is better to use ExtendedChannelChat due")
|
||||
@ClassCastsExcluded
|
||||
data class ExtendedChannelChatImpl(
|
||||
@SerialName(idField)
|
||||
override val id: ChatId,
|
||||
@@ -36,6 +38,7 @@ data class ExtendedChannelChatImpl(
|
||||
|
||||
@Serializable
|
||||
@RiskFeature("This class is a subject of changes. It is better to use ExtendedGroupChat due")
|
||||
@ClassCastsExcluded
|
||||
data class ExtendedGroupChatImpl(
|
||||
@SerialName(idField)
|
||||
override val id: ChatId,
|
||||
@@ -58,6 +61,7 @@ data class ExtendedGroupChatImpl(
|
||||
|
||||
@Serializable
|
||||
@RiskFeature("This class is a subject of changes. It is better to use ExtendedPrivateChat due")
|
||||
@ClassCastsExcluded
|
||||
data class ExtendedPrivateChatImpl(
|
||||
@SerialName(idField)
|
||||
override val id: UserId,
|
||||
@@ -85,6 +89,7 @@ typealias ExtendedUser = ExtendedPrivateChatImpl
|
||||
|
||||
@Serializable
|
||||
@RiskFeature("This class is a subject of changes. It is better to use ExtendedSupergroupChat due")
|
||||
@ClassCastsExcluded
|
||||
data class ExtendedSupergroupChatImpl(
|
||||
@SerialName(idField)
|
||||
override val id: ChatId,
|
||||
@@ -127,6 +132,7 @@ data class ExtendedSupergroupChatImpl(
|
||||
|
||||
@Serializable
|
||||
@RiskFeature("This class is a subject of changes. It is better to use ExtendedForumChat due")
|
||||
@ClassCastsExcluded
|
||||
data class ExtendedForumChatImpl(
|
||||
@SerialName(idField)
|
||||
override val id: IdChatIdentifier,
|
||||
|
@@ -5,11 +5,13 @@ import dev.inmo.micro_utils.language_codes.IetfLanguageCodeSerializer
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsExcluded
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@RiskFeature("This class is a subject of changes. It is better to use GroupChat due")
|
||||
@ClassCastsExcluded
|
||||
data class GroupChatImpl(
|
||||
@SerialName(idField)
|
||||
override val id: ChatId,
|
||||
@@ -19,6 +21,7 @@ data class GroupChatImpl(
|
||||
|
||||
@Serializable
|
||||
@RiskFeature("This class is a subject of changes. It is better to use PrivateChat due")
|
||||
@ClassCastsExcluded
|
||||
data class PrivateChatImpl(
|
||||
@SerialName(idField)
|
||||
override val id: UserId,
|
||||
@@ -32,6 +35,7 @@ data class PrivateChatImpl(
|
||||
|
||||
@Serializable
|
||||
@RiskFeature("This class is a subject of changes. It is better to use SupergroupChat due")
|
||||
@ClassCastsExcluded
|
||||
data class SupergroupChatImpl(
|
||||
@SerialName(idField)
|
||||
override val id: ChatId,
|
||||
@@ -43,6 +47,7 @@ data class SupergroupChatImpl(
|
||||
|
||||
@Serializable
|
||||
@RiskFeature("This class is a subject of changes. It is better to use ForumChat due")
|
||||
@ClassCastsExcluded
|
||||
data class ForumChatImpl(
|
||||
@SerialName(idField)
|
||||
override val id: IdChatIdentifier,
|
||||
@@ -54,6 +59,7 @@ data class ForumChatImpl(
|
||||
|
||||
@Serializable
|
||||
@RiskFeature("This class is a subject of changes. It is better to use ChannelChat due")
|
||||
@ClassCastsExcluded
|
||||
data class ChannelChatImpl(
|
||||
@SerialName(idField)
|
||||
override val id: ChatId,
|
||||
|
@@ -2,9 +2,11 @@ package dev.inmo.tgbotapi.types.chat.member
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsExcluded
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
@ClassCastsExcluded
|
||||
data class AdministratorChatMemberImpl(
|
||||
@SerialName(userField)
|
||||
override val user: User,
|
||||
|
@@ -1,10 +1,12 @@
|
||||
package dev.inmo.tgbotapi.types.chat.member
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsExcluded
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@ClassCastsExcluded
|
||||
data class ChatAdministratorRightsImpl(
|
||||
@SerialName(canChangeInfoField)
|
||||
override val canChangeInfo: Boolean = false,
|
||||
|
@@ -2,9 +2,11 @@ package dev.inmo.tgbotapi.types.chat.member
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsExcluded
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
@ClassCastsExcluded
|
||||
data class LeftChatMemberImpl(@SerialName(userField) override val user: User) : LeftChatMember {
|
||||
@SerialName(statusField)
|
||||
@Required
|
||||
|
@@ -2,9 +2,11 @@ package dev.inmo.tgbotapi.types.chat.member
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsExcluded
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Serializable
|
||||
@ClassCastsExcluded
|
||||
data class MemberChatMemberImpl(@SerialName(userField) override val user: User) : MemberChatMember {
|
||||
@SerialName(statusField)
|
||||
@Required
|
||||
|
@@ -11,7 +11,7 @@ import kotlinx.serialization.descriptors.*
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@ClassCastsIncluded
|
||||
@ClassCastsIncluded(excludeRegex = ".*Impl")
|
||||
interface Message : WithChat {
|
||||
val messageId: MessageId
|
||||
val date: DateTime
|
||||
|
@@ -1,5 +1,13 @@
|
||||
package dev.inmo.tgbotapi.utils.internal
|
||||
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
internal annotation class ClassCastsIncluded(val typesRegex: String = ".*", val excludeRegex: String = "")
|
||||
@RiskFeature("It is internal API in tgbotapi.core and should not be used outside")
|
||||
annotation class ClassCastsIncluded(val typesRegex: String = "", val excludeRegex: String = "")
|
||||
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@RiskFeature("It is internal API in tgbotapi.core and should not be used outside")
|
||||
annotation class ClassCastsExcluded()
|
||||
|
Reference in New Issue
Block a user