1
0
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:
InsanusMokrassar 2024-09-07 00:02:09 +06:00
parent 6809b9d2ef
commit d347c94c8b

View File

@ -53,13 +53,8 @@ sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPrevi
get() = null
}
sealed interface Winners : GiveawayPublicResults {
override val prizeStarCount: Int?
get() = null
override val premiumMonths: Int?
get() = null
@Serializable
data class Premium (
data class Winners(
@SerialName(chatsField)
override val chat: PreviewChat,
@SerialName(giveawayMessageIdField)
@ -70,81 +65,20 @@ sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPrevi
override val count: Int,
@SerialName(winnersField)
override val winners: List<PreviewUser>,
@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,
@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>,
override val premiumMonths: Int? = null,
@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
data class Unknown (
@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(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,
override val prizeStarCount: Int? = null,
) : GiveawayPublicResults {
@SerialName(wasRefundedField)
@Required
@ -195,33 +129,7 @@ sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPrevi
messageId = surrogate.messageId,
selectionDate = surrogate.selectionDate
)
surrogate.premiumMonths != null -> Winners.Premium(
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(
else -> Winners(
chat = surrogate.chat,
messageId = surrogate.messageId,
selectionDate = surrogate.selectionDate,
@ -257,46 +165,5 @@ sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPrevi
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
)
}
}