mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-24 11:08:43 +00:00
revoke rework of GiveawayPublicResults
This commit is contained in:
parent
6809b9d2ef
commit
d347c94c8b
@ -10,7 +10,7 @@ import kotlinx.serialization.encoding.Decoder
|
|||||||
import kotlinx.serialization.encoding.Encoder
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
|
||||||
@Serializable(GiveawayPublicResults.Companion::class)
|
@Serializable(GiveawayPublicResults.Companion::class)
|
||||||
sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPreviewChatAndMessageId,
|
sealed interface GiveawayPublicResults : GiveawayInfo, GiveawayResults, WithPreviewChatAndMessageId,
|
||||||
ReplyInfo.External.ContentVariant, GiveawayInfo.OptionallyStars, GiveawayInfo.OptionallyPremium {
|
ReplyInfo.External.ContentVariant, GiveawayInfo.OptionallyStars, GiveawayInfo.OptionallyPremium {
|
||||||
val count: Int
|
val count: Int
|
||||||
val winners: List<PreviewUser>
|
val winners: List<PreviewUser>
|
||||||
@ -53,74 +53,8 @@ sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPrevi
|
|||||||
get() = null
|
get() = null
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed interface Winners : GiveawayPublicResults {
|
|
||||||
override val prizeStarCount: Int?
|
|
||||||
get() = null
|
|
||||||
override val premiumMonths: Int?
|
|
||||||
get() = null
|
|
||||||
@Serializable
|
|
||||||
data class Premium (
|
|
||||||
@SerialName(chatsField)
|
|
||||||
override val chat: PreviewChat,
|
|
||||||
@SerialName(giveawayMessageIdField)
|
|
||||||
override val messageId: MessageId,
|
|
||||||
@SerialName(winnersSelectionDateField)
|
|
||||||
override val selectionDate: TelegramDate,
|
|
||||||
@SerialName(winnersCountField)
|
|
||||||
override val count: Int,
|
|
||||||
@SerialName(winnersField)
|
|
||||||
override val winners: List<PreviewUser>,
|
|
||||||
@SerialName(premiumSubscriptionMonthCountField)
|
|
||||||
override val premiumMonths: Int,
|
|
||||||
@SerialName(additionalChatCountField)
|
|
||||||
override val additionalChats: Int = 0,
|
|
||||||
@SerialName(unclaimedPrizeCountField)
|
|
||||||
override val unclaimedCount: Int = 0,
|
|
||||||
@SerialName(onlyNewMembersField)
|
|
||||||
override val onlyNewMembers: Boolean = false,
|
|
||||||
@SerialName(hasPublicWinnersField)
|
|
||||||
override val publicWinners: Boolean = false,
|
|
||||||
@SerialName(prizeDescriptionField)
|
|
||||||
override val additionalPrizeDescription: String? = null,
|
|
||||||
) : Winners, GiveawayInfo.Premium {
|
|
||||||
@SerialName(wasRefundedField)
|
|
||||||
@Required
|
|
||||||
@EncodeDefault
|
|
||||||
override val refunded: Boolean = false
|
|
||||||
}
|
|
||||||
@Serializable
|
|
||||||
data class Stars (
|
|
||||||
@SerialName(chatsField)
|
|
||||||
override val chat: PreviewChat,
|
|
||||||
@SerialName(giveawayMessageIdField)
|
|
||||||
override val messageId: MessageId,
|
|
||||||
@SerialName(winnersSelectionDateField)
|
|
||||||
override val selectionDate: TelegramDate,
|
|
||||||
@SerialName(winnersCountField)
|
|
||||||
override val count: Int,
|
|
||||||
@SerialName(winnersField)
|
|
||||||
override val winners: List<PreviewUser>,
|
|
||||||
@SerialName(prizeStarCountField)
|
|
||||||
override val prizeStarCount: Int,
|
|
||||||
@SerialName(additionalChatCountField)
|
|
||||||
override val additionalChats: Int = 0,
|
|
||||||
@SerialName(unclaimedPrizeCountField)
|
|
||||||
override val unclaimedCount: Int = 0,
|
|
||||||
@SerialName(onlyNewMembersField)
|
|
||||||
override val onlyNewMembers: Boolean = false,
|
|
||||||
@SerialName(hasPublicWinnersField)
|
|
||||||
override val publicWinners: Boolean = false,
|
|
||||||
@SerialName(prizeDescriptionField)
|
|
||||||
override val additionalPrizeDescription: String? = null,
|
|
||||||
) : Winners, GiveawayInfo.Stars {
|
|
||||||
@SerialName(wasRefundedField)
|
|
||||||
@Required
|
|
||||||
@EncodeDefault
|
|
||||||
override val refunded: Boolean = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Unknown (
|
data class Winners(
|
||||||
@SerialName(chatsField)
|
@SerialName(chatsField)
|
||||||
override val chat: PreviewChat,
|
override val chat: PreviewChat,
|
||||||
@SerialName(giveawayMessageIdField)
|
@SerialName(giveawayMessageIdField)
|
||||||
@ -131,10 +65,6 @@ sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPrevi
|
|||||||
override val count: Int,
|
override val count: Int,
|
||||||
@SerialName(winnersField)
|
@SerialName(winnersField)
|
||||||
override val winners: List<PreviewUser>,
|
override val winners: List<PreviewUser>,
|
||||||
@SerialName(prizeStarCountField)
|
|
||||||
override val prizeStarCount: Int?,
|
|
||||||
@SerialName(premiumSubscriptionMonthCountField)
|
|
||||||
override val premiumMonths: Int?,
|
|
||||||
@SerialName(additionalChatCountField)
|
@SerialName(additionalChatCountField)
|
||||||
override val additionalChats: Int = 0,
|
override val additionalChats: Int = 0,
|
||||||
@SerialName(unclaimedPrizeCountField)
|
@SerialName(unclaimedPrizeCountField)
|
||||||
@ -145,6 +75,10 @@ sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPrevi
|
|||||||
override val publicWinners: Boolean = false,
|
override val publicWinners: Boolean = false,
|
||||||
@SerialName(prizeDescriptionField)
|
@SerialName(prizeDescriptionField)
|
||||||
override val additionalPrizeDescription: String? = null,
|
override val additionalPrizeDescription: String? = null,
|
||||||
|
@SerialName(premiumSubscriptionMonthCountField)
|
||||||
|
override val premiumMonths: Int? = null,
|
||||||
|
@SerialName(prizeStarCountField)
|
||||||
|
override val prizeStarCount: Int? = null,
|
||||||
) : GiveawayPublicResults {
|
) : GiveawayPublicResults {
|
||||||
@SerialName(wasRefundedField)
|
@SerialName(wasRefundedField)
|
||||||
@Required
|
@Required
|
||||||
@ -195,33 +129,7 @@ sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPrevi
|
|||||||
messageId = surrogate.messageId,
|
messageId = surrogate.messageId,
|
||||||
selectionDate = surrogate.selectionDate
|
selectionDate = surrogate.selectionDate
|
||||||
)
|
)
|
||||||
surrogate.premiumMonths != null -> Winners.Premium(
|
else -> Winners(
|
||||||
chat = surrogate.chat,
|
|
||||||
messageId = surrogate.messageId,
|
|
||||||
selectionDate = surrogate.selectionDate,
|
|
||||||
count = surrogate.count,
|
|
||||||
winners = surrogate.winners,
|
|
||||||
additionalChats = surrogate.additionalChats,
|
|
||||||
unclaimedCount = surrogate.unclaimedCount,
|
|
||||||
onlyNewMembers = surrogate.onlyNewMembers,
|
|
||||||
publicWinners = surrogate.publicWinners,
|
|
||||||
additionalPrizeDescription = surrogate.additionalPrizeDescription,
|
|
||||||
premiumMonths = surrogate.premiumMonths,
|
|
||||||
)
|
|
||||||
surrogate.starsCount != null -> Winners.Stars(
|
|
||||||
chat = surrogate.chat,
|
|
||||||
messageId = surrogate.messageId,
|
|
||||||
selectionDate = surrogate.selectionDate,
|
|
||||||
count = surrogate.count,
|
|
||||||
winners = surrogate.winners,
|
|
||||||
additionalChats = surrogate.additionalChats,
|
|
||||||
unclaimedCount = surrogate.unclaimedCount,
|
|
||||||
onlyNewMembers = surrogate.onlyNewMembers,
|
|
||||||
publicWinners = surrogate.publicWinners,
|
|
||||||
additionalPrizeDescription = surrogate.additionalPrizeDescription,
|
|
||||||
prizeStarCount = surrogate.starsCount,
|
|
||||||
)
|
|
||||||
else -> Unknown(
|
|
||||||
chat = surrogate.chat,
|
chat = surrogate.chat,
|
||||||
messageId = surrogate.messageId,
|
messageId = surrogate.messageId,
|
||||||
selectionDate = surrogate.selectionDate,
|
selectionDate = surrogate.selectionDate,
|
||||||
@ -257,46 +165,5 @@ sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPrevi
|
|||||||
|
|
||||||
Surrogate.serializer().serialize(encoder, surrogate)
|
Surrogate.serializer().serialize(encoder, surrogate)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Winners(
|
|
||||||
chat: PreviewChat,
|
|
||||||
messageId: MessageId,
|
|
||||||
selectionDate: TelegramDate,
|
|
||||||
count: Int,
|
|
||||||
winners: List<PreviewUser>,
|
|
||||||
additionalChats: Int = 0,
|
|
||||||
unclaimedCount: Int = 0,
|
|
||||||
onlyNewMembers: Boolean = false,
|
|
||||||
publicWinners: Boolean = false,
|
|
||||||
additionalPrizeDescription: String? = null,
|
|
||||||
premiumMonths: Int? = null
|
|
||||||
) = premiumMonths ?.let {
|
|
||||||
Winners.Premium(
|
|
||||||
chat = chat,
|
|
||||||
messageId = messageId,
|
|
||||||
selectionDate = selectionDate,
|
|
||||||
count = count,
|
|
||||||
winners = winners,
|
|
||||||
premiumMonths = premiumMonths,
|
|
||||||
additionalChats = additionalChats,
|
|
||||||
unclaimedCount = unclaimedCount,
|
|
||||||
onlyNewMembers = onlyNewMembers,
|
|
||||||
publicWinners = publicWinners,
|
|
||||||
additionalPrizeDescription = additionalPrizeDescription
|
|
||||||
)
|
|
||||||
} ?: Unknown(
|
|
||||||
chat = chat,
|
|
||||||
messageId = messageId,
|
|
||||||
selectionDate = selectionDate,
|
|
||||||
count = count,
|
|
||||||
winners = winners,
|
|
||||||
prizeStarCount = null,
|
|
||||||
premiumMonths = premiumMonths,
|
|
||||||
additionalChats = additionalChats,
|
|
||||||
unclaimedCount = unclaimedCount,
|
|
||||||
onlyNewMembers = onlyNewMembers,
|
|
||||||
publicWinners = publicWinners,
|
|
||||||
additionalPrizeDescription = additionalPrizeDescription
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user