From f760e600895300013cbb04a3cc6e01e52921a8af Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 7 Jan 2024 17:40:41 +0600 Subject: [PATCH] fixes in typing of giveaways --- .../expectations/WaitContent.kt | 10 ++++ .../expectations/WaitContentMessage.kt | 10 ++++ .../expectations/WaitEditedContent.kt | 11 ++++ .../expectations/WaitEditedContentMessage.kt | 11 ++++ .../triggers_handling/ContentTriggers.kt | 49 +++++++++++++++++ .../types/giveaway/GiveawayPrivateResults.kt | 4 +- .../types/giveaway/GiveawayResults.kt | 2 +- .../{Giveaway.kt => ScheduledGiveaway.kt} | 9 ++-- .../inmo/tgbotapi/types/message/RawMessage.kt | 13 +++-- .../content/GiveawayPublicResultsContent.kt | 25 +++++++++ .../content/ScheduledGiveawayContent.kt | 29 ++++++++++ .../types/message/content/Typealiases.kt | 2 + .../extensions/utils/ClassCastsNew.kt | 54 +++++++++---------- 13 files changed, 187 insertions(+), 42 deletions(-) rename tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/{Giveaway.kt => ScheduledGiveaway.kt} (79%) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayPublicResultsContent.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt index 6bafc17182..2fe2743266 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt @@ -138,3 +138,13 @@ suspend fun BehaviourContext.waitMediaContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContent(initRequest, errorFactory).mapContent() + +suspend fun BehaviourContext.waitScheduledGiveawayContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, errorFactory).mapContent() + +suspend fun BehaviourContext.waitGiveawayPublicResultsContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, errorFactory).mapContent() diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt index d0e151480a..7ff93f2931 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContentMessage.kt @@ -152,3 +152,13 @@ suspend fun BehaviourContext.waitMediaContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory).mapWithContent() + +suspend fun BehaviourContext.waitScheduledGiveawayContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, errorFactory).mapWithContent() + +suspend fun BehaviourContext.waitGiveawayPublicResultsContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, errorFactory).mapWithContent() diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt index c78ab0452a..d3761f4097 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt @@ -130,3 +130,14 @@ suspend fun BehaviourContext.waitEditedInvoice( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitEditedContent(initRequest, false, errorFactory) + +suspend fun BehaviourContext.waitEditedScheduledGiveawayContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContent(initRequest, false, errorFactory) + +suspend fun BehaviourContext.waitEditedGiveawayPublicResultsContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContent(initRequest, false, errorFactory) + diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt index 99d14d8d0b..4790f8ac71 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContentMessage.kt @@ -136,3 +136,14 @@ suspend fun BehaviourContext.waitEditedInvoiceMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitEditedContentMessage(initRequest, errorFactory) + +suspend fun BehaviourContext.waitEditedScheduledGiveawayContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, errorFactory) + +suspend fun BehaviourContext.waitEditedGiveawayPublicResultsContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEditedContentMessage(initRequest, errorFactory) + diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt index a2b1a002b4..0b3e5ec1eb 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt @@ -703,3 +703,52 @@ suspend fun BC.onMediaContent( markerFactory, scenarioReceiver ) + +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onScheduledGiveawayContent( + initialFilter: CommonMessageFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = MessageFilterByChat, + markerFactory: MarkerFactory = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = onContentMessageWithType( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) + + +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onScheduledGiveawayContent( + initialFilter: CommonMessageFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = MessageFilterByChat, + markerFactory: MarkerFactory = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = onContentMessageWithType( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPrivateResults.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPrivateResults.kt index 8fbbf42bc2..81cbc2ce03 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPrivateResults.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayPrivateResults.kt @@ -1,6 +1,8 @@ package dev.inmo.tgbotapi.types.giveaway import dev.inmo.tgbotapi.types.chat.PreviewChat +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import kotlinx.serialization.Serializable import kotlinx.serialization.Transient @@ -11,4 +13,4 @@ data class GiveawayPrivateResults( override val unclaimedCount: Int, @Transient // TODO::Add message serializer val message: AccessibleMessage? = null -) : GiveawayResults +) : GiveawayResults, ChatEvent, PublicChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt index fc193537e6..90628b1ee3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/GiveawayResults.kt @@ -6,6 +6,6 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent import kotlinx.serialization.Serializable @Serializable -sealed interface GiveawayResults : WithPreviewChat, ChatEvent, PublicChatEvent { +sealed interface GiveawayResults : WithPreviewChat { val unclaimedCount: Int } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/Giveaway.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/ScheduledGiveaway.kt similarity index 79% rename from tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/Giveaway.kt rename to tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/ScheduledGiveaway.kt index cbae4c2740..d0642619f0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/Giveaway.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/giveaway/ScheduledGiveaway.kt @@ -1,16 +1,19 @@ package dev.inmo.tgbotapi.types.giveaway import dev.inmo.micro_utils.language_codes.IetfLang +import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.PreviewChat -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent +import dev.inmo.tgbotapi.types.giveaway.GiveawayInfo import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class Giveaway( +data class ScheduledGiveaway( @SerialName(chatsField) val chats: List, @SerialName(winnersSelectionDateField) @@ -27,4 +30,4 @@ data class Giveaway( val countries: List? = null, @SerialName(premiumSubscriptionMonthCountField) override val premiumMonths: Int? = null -) : GiveawayInfo, ChatEvent, PublicChatEvent \ No newline at end of file +) : GiveawayInfo \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt index f876f18ed6..e8758b9045 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt @@ -9,10 +9,8 @@ import dev.inmo.tgbotapi.types.dice.Dice import dev.inmo.tgbotapi.types.files.* import dev.inmo.tgbotapi.types.files.Sticker import dev.inmo.tgbotapi.types.games.RawGame -import dev.inmo.tgbotapi.types.giveaway.Giveaway -import dev.inmo.tgbotapi.types.giveaway.GiveawayCreated -import dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults -import dev.inmo.tgbotapi.types.giveaway.GiveawayResults +import dev.inmo.tgbotapi.types.giveaway.* +import dev.inmo.tgbotapi.types.message.content.ScheduledGiveawayContent import dev.inmo.tgbotapi.types.location.Location import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* @@ -134,7 +132,7 @@ internal data class RawMessage( // Giveaways private val giveaway_created: GiveawayCreated? = null, - private val giveaway: Giveaway? = null, + private val giveaway: ScheduledGiveaway? = null, private val giveaway_winners: GiveawayResults? = null, private val giveaway_completed: GiveawayPrivateResults? = null, ) { @@ -193,6 +191,8 @@ internal data class RawMessage( venue != null -> VenueContent(venue) poll != null -> PollContent(poll) invoice != null -> InvoiceContent(invoice) + giveaway != null -> ScheduledGiveawayContent(giveaway) + giveaway_winners is GiveawayPublicResults -> GiveawayPublicResultsContent(giveaway_winners) else -> null } } @@ -237,8 +237,7 @@ internal data class RawMessage( users_shared != null -> users_shared chat_shared != null -> chat_shared giveaway_created != null -> giveaway_created - giveaway != null -> giveaway - giveaway_winners != null -> giveaway_winners + giveaway_winners is GiveawayPrivateResults -> giveaway_winners giveaway_completed != null -> giveaway_completed else -> null } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayPublicResultsContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayPublicResultsContent.kt new file mode 100644 index 0000000000..3d4a5e4ded --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/GiveawayPublicResultsContent.kt @@ -0,0 +1,25 @@ +package dev.inmo.tgbotapi.types.message.content + +import dev.inmo.tgbotapi.requests.abstracts.Request +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup +import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +import kotlinx.serialization.Serializable + +@Serializable +data class GiveawayPublicResultsContent( + val giveaway: GiveawayPublicResults +) : MessageContent { + override fun createResend( + chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, + disableNotification: Boolean, + protectContent: Boolean, + replyToMessageId: MessageId?, + allowSendingWithoutReply: Boolean?, + replyMarkup: KeyboardMarkup? + ): Request { + TODO("Not yet implemented") + } +} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt new file mode 100644 index 0000000000..47386da9ef --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/ScheduledGiveawayContent.kt @@ -0,0 +1,29 @@ +package dev.inmo.tgbotapi.types.message.content + +import dev.inmo.micro_utils.language_codes.IetfLang +import dev.inmo.tgbotapi.requests.abstracts.Request +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup +import dev.inmo.tgbotapi.types.chat.PreviewChat +import dev.inmo.tgbotapi.types.giveaway.GiveawayInfo +import dev.inmo.tgbotapi.types.giveaway.ScheduledGiveaway +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ScheduledGiveawayContent( + val giveaway: ScheduledGiveaway +) : MessageContent { + override fun createResend( + chatId: ChatIdentifier, + messageThreadId: MessageThreadId?, + disableNotification: Boolean, + protectContent: Boolean, + replyToMessageId: MessageId?, + allowSendingWithoutReply: Boolean?, + replyMarkup: KeyboardMarkup? + ): Request { + TODO("Not yet implemented") + } +} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Typealiases.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Typealiases.kt index 9e9a865f9f..399ef34cd8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Typealiases.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/content/Typealiases.kt @@ -32,5 +32,7 @@ typealias VisualMediaGroupMessage = CommonMessage typealias VideoMessage = CommonMessage typealias PhotoMessage = CommonMessage typealias AnimationMessage = CommonMessage +typealias ScheduledGiveawayContentMessage = CommonMessage +typealias GiveawayPublicResultsContentMessage = CommonMessage diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt index fd267c4c88..6942deb6ef 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCastsNew.kt @@ -197,11 +197,8 @@ import dev.inmo.tgbotapi.types.files.VideoFile import dev.inmo.tgbotapi.types.files.VideoNoteFile import dev.inmo.tgbotapi.types.files.VideoSticker import dev.inmo.tgbotapi.types.files.VoiceFile -import dev.inmo.tgbotapi.types.giveaway.Giveaway import dev.inmo.tgbotapi.types.giveaway.GiveawayCreated import dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults -import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults -import dev.inmo.tgbotapi.types.giveaway.GiveawayResults import dev.inmo.tgbotapi.types.location.LiveLocation import dev.inmo.tgbotapi.types.location.Location import dev.inmo.tgbotapi.types.location.StaticLocation @@ -298,6 +295,7 @@ import dev.inmo.tgbotapi.types.message.content.DiceContent import dev.inmo.tgbotapi.types.message.content.DocumentContent import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupPartContent import dev.inmo.tgbotapi.types.message.content.GameContent +import dev.inmo.tgbotapi.types.message.content.GiveawayPublicResultsContent import dev.inmo.tgbotapi.types.message.content.InvoiceContent import dev.inmo.tgbotapi.types.message.content.LiveLocationContent import dev.inmo.tgbotapi.types.message.content.LocationContent @@ -310,6 +308,7 @@ import dev.inmo.tgbotapi.types.message.content.MessageContent import dev.inmo.tgbotapi.types.message.content.PhotoContent import dev.inmo.tgbotapi.types.message.content.PollContent import dev.inmo.tgbotapi.types.message.content.ResendableContent +import dev.inmo.tgbotapi.types.message.content.ScheduledGiveawayContent import dev.inmo.tgbotapi.types.message.content.SpoilerableMediaContent import dev.inmo.tgbotapi.types.message.content.StaticLocationContent import dev.inmo.tgbotapi.types.message.content.StickerContent @@ -2781,15 +2780,6 @@ public inline fun TelegramMedia.titledTelegramMediaOrThrow(): TitledTelegramMedi public inline fun TelegramMedia.ifTitledTelegramMedia(block: (TitledTelegramMedia) -> T): T? = titledTelegramMediaOrNull() ?.let(block) -public inline fun ChatEvent.giveawayOrNull(): Giveaway? = this as? - dev.inmo.tgbotapi.types.giveaway.Giveaway - -public inline fun ChatEvent.giveawayOrThrow(): Giveaway = this as - dev.inmo.tgbotapi.types.giveaway.Giveaway - -public inline fun ChatEvent.ifGiveaway(block: (Giveaway) -> T): T? = giveawayOrNull() - ?.let(block) - public inline fun ChatEvent.giveawayCreatedOrNull(): GiveawayCreated? = this as? dev.inmo.tgbotapi.types.giveaway.GiveawayCreated @@ -2808,24 +2798,6 @@ public inline fun ChatEvent.giveawayPrivateResultsOrThrow(): GiveawayPrivateResu public inline fun ChatEvent.ifGiveawayPrivateResults(block: (GiveawayPrivateResults) -> T): T? = giveawayPrivateResultsOrNull() ?.let(block) -public inline fun ChatEvent.giveawayPublicResultsOrNull(): GiveawayPublicResults? = this as? - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults - -public inline fun ChatEvent.giveawayPublicResultsOrThrow(): GiveawayPublicResults = this as - dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults - -public inline fun ChatEvent.ifGiveawayPublicResults(block: (GiveawayPublicResults) -> T): T? = - giveawayPublicResultsOrNull() ?.let(block) - -public inline fun ChatEvent.giveawayResultsOrNull(): GiveawayResults? = this as? - dev.inmo.tgbotapi.types.giveaway.GiveawayResults - -public inline fun ChatEvent.giveawayResultsOrThrow(): GiveawayResults = this as - dev.inmo.tgbotapi.types.giveaway.GiveawayResults - -public inline fun ChatEvent.ifGiveawayResults(block: (GiveawayResults) -> T): T? = - giveawayResultsOrNull() ?.let(block) - public inline fun ChatEvent.channelChatCreatedOrNull(): ChannelChatCreated? = this as? dev.inmo.tgbotapi.types.message.ChatEvents.ChannelChatCreated @@ -3748,6 +3720,18 @@ public inline fun ResendableContent.gameContentOrThrow(): GameContent = this as public inline fun ResendableContent.ifGameContent(block: (GameContent) -> T): T? = gameContentOrNull() ?.let(block) +public inline fun ResendableContent.giveawayPublicResultsContentOrNull(): + GiveawayPublicResultsContent? = this as? + dev.inmo.tgbotapi.types.message.content.GiveawayPublicResultsContent + +public inline fun ResendableContent.giveawayPublicResultsContentOrThrow(): + GiveawayPublicResultsContent = this as + dev.inmo.tgbotapi.types.message.content.GiveawayPublicResultsContent + +public inline fun + ResendableContent.ifGiveawayPublicResultsContent(block: (GiveawayPublicResultsContent) -> T): T? + = giveawayPublicResultsContentOrNull() ?.let(block) + public inline fun ResendableContent.invoiceContentOrNull(): InvoiceContent? = this as? dev.inmo.tgbotapi.types.message.content.InvoiceContent @@ -3815,6 +3799,16 @@ public inline fun ResendableContent.pollContentOrThrow(): PollContent = this as public inline fun ResendableContent.ifPollContent(block: (PollContent) -> T): T? = pollContentOrNull() ?.let(block) +public inline fun ResendableContent.scheduledGiveawayContentOrNull(): ScheduledGiveawayContent? = + this as? dev.inmo.tgbotapi.types.message.content.ScheduledGiveawayContent + +public inline fun ResendableContent.scheduledGiveawayContentOrThrow(): ScheduledGiveawayContent = + this as dev.inmo.tgbotapi.types.message.content.ScheduledGiveawayContent + +public inline fun + ResendableContent.ifScheduledGiveawayContent(block: (ScheduledGiveawayContent) -> T): T? = + scheduledGiveawayContentOrNull() ?.let(block) + public inline fun ResendableContent.stickerContentOrNull(): StickerContent? = this as? dev.inmo.tgbotapi.types.message.content.StickerContent