mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-16 13:49:26 +00:00
add generation of class casts
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package dev.inmo.tgbotapi.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.payments.abstracts.Currencied
|
||||
import dev.inmo.tgbotapi.types.payments.abstracts.Priced
|
||||
|
||||
@ClassCastsIncluded
|
||||
interface CommonSendInvoiceData : Titled, Currencied, Priced {
|
||||
val description: String
|
||||
val payload: String
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
|
||||
/**
|
||||
@@ -7,6 +8,7 @@ import dev.inmo.tgbotapi.types.chat.User
|
||||
*
|
||||
* @see FromUser
|
||||
*/
|
||||
@ClassCastsIncluded
|
||||
interface WithUser {
|
||||
val user: User
|
||||
}
|
||||
|
@@ -1,13 +1,15 @@
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.serializers.InlineQueryResultSerializer
|
||||
import dev.inmo.tgbotapi.types.InlineQueryIdentifier
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(InlineQueryResultSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
interface InlineQueryResult {
|
||||
val type: String
|
||||
val id: InlineQueryIdentifier
|
||||
val replyMarkup: InlineKeyboardMarkup?
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,9 @@
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContentSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(InputMessageContentSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface InputMessageContent
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.actions
|
||||
|
||||
import dev.inmo.micro_utils.common.Warning
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
@@ -13,6 +14,7 @@ import kotlinx.serialization.encoding.Encoder
|
||||
* Use BotAction objects realisations to notify user about bot actions
|
||||
*/
|
||||
@Serializable(BotActionSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface BotAction {
|
||||
val actionName: String
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.games.CallbackGame
|
||||
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
||||
@@ -11,6 +12,7 @@ import kotlinx.serialization.json.*
|
||||
* https://core.telegram.org/bots/api#inlinekeyboardbutton for more info
|
||||
*/
|
||||
@Serializable(InlineKeyboardButtonSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface InlineKeyboardButton {
|
||||
val text: String
|
||||
}
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package dev.inmo.tgbotapi.types.buttons
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(KeyboardMarkupSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface KeyboardMarkup
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.chat
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@@ -43,6 +44,7 @@ sealed interface AbleToAddInAttachmentMenuChat : Chat {
|
||||
}
|
||||
|
||||
@Serializable(PreviewChatSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface Chat {
|
||||
val id: ChatId
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.dice
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import kotlinx.serialization.KSerializer
|
||||
@@ -9,6 +10,7 @@ import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@Serializable(DiceAnimationTypeSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface DiceAnimationType {
|
||||
val emoji: String
|
||||
val valueLimits: IntRange
|
||||
|
@@ -1,11 +1,13 @@
|
||||
package dev.inmo.tgbotapi.types.files
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.types.FileUniqueId
|
||||
|
||||
/**
|
||||
* Declare common part of media files in Telegram. Note: it is not representation of JVM `File` type
|
||||
*/
|
||||
@ClassCastsIncluded
|
||||
sealed interface TelegramMediaFile {
|
||||
val fileId: FileId
|
||||
val fileUniqueId: FileUniqueId
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.location
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.*
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||
import kotlinx.serialization.*
|
||||
@@ -18,6 +19,7 @@ import kotlinx.serialization.json.JsonObject
|
||||
* @see dev.inmo.tgbotapi.extensions.utils.asLiveLocation
|
||||
*/
|
||||
@Serializable(LocationSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface Location : Locationed, HorizontallyAccured
|
||||
|
||||
@Serializable
|
||||
|
@@ -1,9 +1,11 @@
|
||||
package dev.inmo.tgbotapi.types.media
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(TelegramMediaSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface TelegramMedia {
|
||||
val type: String
|
||||
val file: InputFile
|
||||
|
@@ -4,6 +4,9 @@ import dev.inmo.tgbotapi.abstracts.WithUser
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent
|
||||
|
||||
data class LeftChatMember(
|
||||
data class LeftChatMemberEvent(
|
||||
override val user: User
|
||||
) : PublicChatEvent, WithUser
|
||||
|
||||
@Deprecated("Renamed", ReplaceWith("dev.inmo.tgbotapi.types.message.ChatEvents", "LeftChatMemberEvent"))
|
||||
typealias LeftChatMember = LeftChatMemberEvent
|
||||
|
@@ -1,3 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
|
||||
@ClassCastsIncluded
|
||||
interface ChatEvent
|
||||
|
@@ -1,10 +1,12 @@
|
||||
package dev.inmo.tgbotapi.types.message
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.FromUser
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.*
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
|
||||
@ClassCastsIncluded
|
||||
sealed interface ForwardInfo {
|
||||
abstract val dateOfOriginal: TelegramDate
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.message.abstracts
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.RawMessage
|
||||
@@ -9,6 +10,7 @@ import kotlinx.serialization.descriptors.*
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@ClassCastsIncluded
|
||||
interface Message {
|
||||
val messageId: MessageIdentifier
|
||||
val chat: Chat
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.message.content
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
@@ -108,6 +109,7 @@ sealed interface MediaContent: MessageContent {
|
||||
fun asTelegramMedia(): TelegramMedia
|
||||
}
|
||||
|
||||
@ClassCastsIncluded
|
||||
sealed interface ResendableContent {
|
||||
fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.message.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.captionLength
|
||||
import dev.inmo.tgbotapi.types.textLength
|
||||
import kotlinx.serialization.Serializable
|
||||
@@ -10,6 +11,7 @@ typealias TextSourcesList = List<TextSource>
|
||||
typealias MutableTextSourcesList = MutableList<TextSource>
|
||||
|
||||
@Serializable(TextSourceSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface TextSource {
|
||||
val markdown: String
|
||||
val markdownV2: String
|
||||
|
@@ -5,6 +5,7 @@ package dev.inmo.tgbotapi.types.passport
|
||||
import dev.inmo.micro_utils.crypto.MD5
|
||||
import dev.inmo.micro_utils.crypto.md5
|
||||
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted.type
|
||||
@@ -18,6 +19,7 @@ import kotlinx.serialization.json.*
|
||||
val ByteArray.passportFileHash: MD5
|
||||
get() = md5()
|
||||
|
||||
@ClassCastsIncluded
|
||||
@Serializable(PassportElementErrorSerializer::class)
|
||||
sealed class PassportElementError {
|
||||
abstract val source: String
|
||||
|
@@ -1,7 +1,9 @@
|
||||
package dev.inmo.tgbotapi.types.passport.decrypted.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.passport.credentials.EndDataCredentials
|
||||
|
||||
@ClassCastsIncluded
|
||||
interface SecureValue {
|
||||
val credentials: List<EndDataCredentials>
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.types.passport.encrypted.abstracts
|
||||
|
||||
import dev.inmo.micro_utils.crypto.SourceBytes
|
||||
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted.EncryptedElementSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
@@ -9,6 +10,7 @@ import kotlinx.serialization.json.JsonObject
|
||||
typealias PassportElementHash = SourceBytes
|
||||
|
||||
@Serializable(EncryptedElementSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
interface EncryptedPassportElement {
|
||||
val hash: PassportElementHash
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.types.polls
|
||||
import com.soywiz.klock.DateTime
|
||||
import com.soywiz.klock.TimeSpan
|
||||
import dev.inmo.tgbotapi.abstracts.TextedInput
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.message.*
|
||||
import dev.inmo.tgbotapi.types.message.RawMessageEntity
|
||||
@@ -16,6 +17,7 @@ import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import kotlinx.serialization.json.*
|
||||
|
||||
@ClassCastsIncluded
|
||||
sealed interface ScheduledCloseInfo {
|
||||
val closeDateTime: DateTime
|
||||
}
|
||||
@@ -45,6 +47,7 @@ val LongSeconds.asExactScheduledCloseInfo
|
||||
)
|
||||
|
||||
@Serializable(PollSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface Poll {
|
||||
val id: PollIdentifier
|
||||
val question: String
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.update.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.ksp.lib.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||
import dev.inmo.tgbotapi.types.update.RawUpdate
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
@@ -10,6 +11,7 @@ import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
|
||||
@ClassCastsIncluded
|
||||
interface Update {
|
||||
val updateId: UpdateIdentifier
|
||||
val data: Any
|
||||
|
@@ -0,0 +1,3 @@
|
||||
package dev.inmo.tgbotapi.utils.internal
|
||||
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
Reference in New Issue
Block a user