mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-16 13:49:26 +00:00
PollId now is value class
This commit is contained in:
@@ -15,7 +15,6 @@ typealias AuthorSignature = ForwardSignature
|
||||
typealias PaymentQueryIdentifier = String
|
||||
typealias InvoicePayload = String
|
||||
typealias StartParameter = String
|
||||
typealias PollIdentifier = String
|
||||
typealias StickerSetName = String
|
||||
typealias DiceResult = Int
|
||||
typealias FoursquareId = String
|
||||
|
@@ -0,0 +1,16 @@
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.jvm.JvmInline
|
||||
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class PollId(
|
||||
val string: String
|
||||
) {
|
||||
override fun toString(): String {
|
||||
return string
|
||||
}
|
||||
}
|
||||
@Deprecated("Renamed", ReplaceWith("PollId", "dev.inmo.tgbotapi.types.PollId"))
|
||||
typealias PollIdentifier = String
|
@@ -50,7 +50,7 @@ val LongSeconds.asExactScheduledCloseInfo
|
||||
@Serializable(PollSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface Poll : ReplyInfo.External.ContentVariant {
|
||||
val id: PollIdentifier
|
||||
val id: PollId
|
||||
val question: String
|
||||
val options: List<PollOption>
|
||||
val votesCount: Int
|
||||
@@ -67,7 +67,7 @@ sealed interface MultipleAnswersPoll : Poll {
|
||||
@Serializable
|
||||
private class RawPoll(
|
||||
@SerialName(idField)
|
||||
val id: PollIdentifier,
|
||||
val id: PollId,
|
||||
@SerialName(questionField)
|
||||
val question: String,
|
||||
@SerialName(optionsField)
|
||||
@@ -101,7 +101,7 @@ private class RawPoll(
|
||||
@Serializable
|
||||
data class UnknownPollType internal constructor(
|
||||
@SerialName(idField)
|
||||
override val id: PollIdentifier,
|
||||
override val id: PollId,
|
||||
@SerialName(questionField)
|
||||
override val question: String,
|
||||
@SerialName(optionsField)
|
||||
@@ -124,7 +124,7 @@ data class UnknownPollType internal constructor(
|
||||
|
||||
@Serializable(PollSerializer::class)
|
||||
data class RegularPoll(
|
||||
override val id: PollIdentifier,
|
||||
override val id: PollId,
|
||||
override val question: String,
|
||||
override val options: List<PollOption>,
|
||||
override val votesCount: Int,
|
||||
@@ -136,7 +136,7 @@ data class RegularPoll(
|
||||
|
||||
@Serializable(PollSerializer::class)
|
||||
data class QuizPoll(
|
||||
override val id: PollIdentifier,
|
||||
override val id: PollId,
|
||||
override val question: String,
|
||||
override val options: List<PollOption>,
|
||||
override val votesCount: Int,
|
||||
|
@@ -12,7 +12,7 @@ import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@Serializable(PollAnswer.Companion::class)
|
||||
sealed interface PollAnswer: FromUser {
|
||||
val pollId: PollIdentifier
|
||||
val pollId: PollId
|
||||
override val user: User
|
||||
val chosen: List<Int>
|
||||
@Transient
|
||||
@@ -22,7 +22,7 @@ sealed interface PollAnswer: FromUser {
|
||||
@Serializable
|
||||
data class Public(
|
||||
@SerialName(pollIdField)
|
||||
override val pollId: PollIdentifier,
|
||||
override val pollId: PollId,
|
||||
@SerialName(userField)
|
||||
override val user: User,
|
||||
@SerialName(optionIdsField)
|
||||
@@ -32,7 +32,7 @@ sealed interface PollAnswer: FromUser {
|
||||
@Serializable
|
||||
data class Anonymous(
|
||||
@SerialName(pollIdField)
|
||||
override val pollId: PollIdentifier,
|
||||
override val pollId: PollId,
|
||||
@SerialName(voterChatField)
|
||||
val voterChat: ChannelChat,
|
||||
@SerialName(optionIdsField)
|
||||
@@ -55,7 +55,7 @@ sealed interface PollAnswer: FromUser {
|
||||
@Serializable
|
||||
private data class PollAnswerSurrogate(
|
||||
@SerialName(pollIdField)
|
||||
val pollId: PollIdentifier,
|
||||
val pollId: PollId,
|
||||
@SerialName(optionIdsField)
|
||||
val chosen: List<Int>,
|
||||
@SerialName(userField)
|
||||
@@ -64,7 +64,7 @@ sealed interface PollAnswer: FromUser {
|
||||
val voterChat: ChannelChat? = null
|
||||
)
|
||||
operator fun invoke(
|
||||
pollId: PollIdentifier,
|
||||
pollId: PollId,
|
||||
user: User,
|
||||
chosen: List<Int>,
|
||||
) = Public(pollId, user, chosen)
|
||||
|
Reference in New Issue
Block a user