diff --git a/CHANGELOG.md b/CHANGELOG.md index 216a85bd5a..0a36957944 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # TelegramBotAPI changelog +## 10.1.0 + +**Add support of [Telegram Bots API 7.1](https://core.telegram.org/bots/api-changelog#february-16-2024)** + +* `Version`: + * `Coroutines`: `1.7.3` -> `1.8.0` + * `MicroUtils`: `0.20.32` -> `0.20.34` + ## 10.0.1 * `Version`: diff --git a/README.md b/README.md index bf5b95739d..734d3b1bac 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-7.0-blue)](https://core.telegram.org/bots/api-changelog#december-29-2023) +# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-7.1-blue)](https://core.telegram.org/bots/api-changelog#february-16-2024) | Docs | [![KDocs](https://img.shields.io/static/v1?label=Dokka&message=KDocs&color=blue&logo=kotlin)](https://tgbotapi.inmo.dev/index.html) [![Mini tutorial](https://img.shields.io/static/v1?label=Mk&message=Docs&color=blue&logo=mkdocs)](https://docs.inmo.dev/tgbotapi/index.html) | |:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| diff --git a/gradle.properties b/gradle.properties index 91874c618e..b634e5c5ef 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ kotlin.incremental=true kotlin.incremental.js=true library_group=dev.inmo -library_version=10.0.1 +library_version=10.1.0 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fc5b4460e7..8e3312cedd 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ kotlin = "1.9.22" kotlin-serialization = "1.6.2" -kotlin-coroutines = "1.7.3" +kotlin-coroutines = "1.8.0" javax-activation = "1.1.1" @@ -13,7 +13,7 @@ ktor = "2.3.8" ksp = "1.9.22-1.0.17" kotlin-poet = "1.16.0" -microutils = "0.20.32" +microutils = "0.20.34" kslog = "1.3.2" versions = "0.51.0" diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt index 286e2f3c88..196dcbf149 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt @@ -214,3 +214,8 @@ suspend fun BehaviourContext.waitChatShared( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitEvents(initRequest, errorFactory) + +suspend fun BehaviourContext.waitChatBoostAdded( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEvents(initRequest, errorFactory) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt index 55d89bbc75..61246132b7 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventActionMessages.kt @@ -208,3 +208,8 @@ suspend fun BehaviourContext.waitChatSharedEventsMessages( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitEventsMessages(initRequest, errorFactory) + +suspend fun BehaviourContext.waitChatBoostAddedEventsMessages( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitEventsMessages(initRequest, errorFactory) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt index 6fe38413da..55ff317b64 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt @@ -823,3 +823,24 @@ suspend fun BC.onChatShared( markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEventWithCustomChatEventMessage(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.onChatBoostAdded( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 44b0f6df67..601b755768 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -45,6 +45,11 @@ value class CustomEmojiId( val appLink get() = "${internalTgAppLinksBeginning}emoji?id=$this" } +@Serializable +@JvmInline +value class StoryId( + val long: Long +) typealias Seconds = Int typealias MilliSeconds = Long @@ -246,6 +251,8 @@ const val profileAccentColorIdField = "profile_accent_color_id" const val backgroundCustomEmojiIdField = "background_custom_emoji_id" const val profileBackgroundCustomEmojiIdField = "profile_background_custom_emoji_id" const val hasVisibleHistoryField = "has_visible_history" +const val unrestrictBoostsCountField = "unrestrict_boost_count" +const val customEmojiStickerSetNameField = "custom_emoji_sticker_set_name" const val iconCustomEmojiIdField = "icon_custom_emoji_id" const val canJoinGroupsField = "can_join_groups" const val canReadAllGroupMessagesField = "can_read_all_group_messages" @@ -656,6 +663,7 @@ const val menuButtonField = "menu_button" const val boostIdField = "boost_id" const val boostField = "boost" +const val boostCountField = "boost_count" const val addDateField = "add_date" const val expirationDateField = "expiration_date" const val removeDateField = "remove_date" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt index 419a3bba83..445749a753 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ReplyInfo.kt @@ -9,7 +9,6 @@ import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults import dev.inmo.tgbotapi.types.giveaway.Giveaway import dev.inmo.tgbotapi.types.location.Location import dev.inmo.tgbotapi.types.message.MessageOrigin -import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.payments.Invoice import dev.inmo.tgbotapi.types.polls.Poll @@ -34,6 +33,14 @@ sealed interface ReplyInfo { get() = message.metaInfo } + @Serializable + data class ToStory( + val story: Story + ): ReplyInfo { + override val messageMeta: Message.MetaInfo? + get() = null + } + @Serializable(External.Companion::class) sealed interface External : ReplyInfo { val origin: MessageOrigin diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt index 0041828a48..c8af805302 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt @@ -184,6 +184,10 @@ data class ExtendedSupergroupChatImpl( override val profileBackgroundCustomEmojiId: CustomEmojiId? = null, @SerialName(hasVisibleHistoryField) override val newMembersSeeHistory: Boolean = false, + @SerialName(unrestrictBoostsCountField) + override val unrestrictBoostsCount: Int? = null, + @SerialName(customEmojiStickerSetNameField) + override val customEmojiStickerSetName: StickerSetName? = null, ) : ExtendedSupergroupChat @Serializable @@ -242,6 +246,10 @@ data class ExtendedForumChatImpl( override val profileBackgroundCustomEmojiId: CustomEmojiId? = null, @SerialName(hasVisibleHistoryField) override val newMembersSeeHistory: Boolean = false, + @SerialName(unrestrictBoostsCountField) + override val unrestrictBoostsCount: Int? = null, + @SerialName(customEmojiStickerSetNameField) + override val customEmojiStickerSetName: StickerSetName? = null, ) : ExtendedForumChat @Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt index b3887e7579..bdb3e4c2f9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt @@ -59,7 +59,9 @@ sealed interface ExtendedSupergroupChat : SupergroupChat, ExtendedGroupChat, Ext val stickerSetName: StickerSetName? val canSetStickerSet: Boolean val linkedChannelChatId: IdChatIdentifier? + val unrestrictBoostsCount: Int? val location: ChatLocation? + val customEmojiStickerSetName: StickerSetName? /** * This field represents field "join_to_send_messages" from API diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/ChatBoostAdded.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/ChatBoostAdded.kt new file mode 100644 index 0000000000..2153239057 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/ChatBoostAdded.kt @@ -0,0 +1,12 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents + +import dev.inmo.tgbotapi.types.boostCountField +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ChatBoostAdded( + @SerialName(boostCountField) + val count: Int +) : PublicChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt index c9d42f2bf6..de7930b18a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/GroupMessages.kt @@ -123,6 +123,7 @@ data class CommonGroupContentMessageImpl( override val content: T, override val senderBot: CommonBot?, override val mediaGroupId: MediaGroupIdentifier?, + override val senderBoostsCount: Int? ) : CommonGroupContentMessage { constructor( chat: PreviewGroupChat, @@ -137,8 +138,9 @@ data class CommonGroupContentMessageImpl( content: T, senderBot: CommonBot?, mediaGroupId: MediaGroupIdentifier?, + senderBoostsCount: Int?, ) : this( - chat, messageId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId + chat, messageId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId, senderBoostsCount ) } @@ -226,6 +228,7 @@ data class CommonForumContentMessageImpl( override val content: T, override val senderBot: CommonBot?, override val mediaGroupId: MediaGroupIdentifier?, + override val senderBoostsCount: Int?, ) : CommonForumContentMessage { constructor( chat: PreviewForumChat, @@ -241,7 +244,8 @@ data class CommonForumContentMessageImpl( content: T, senderBot: CommonBot?, mediaGroupId: MediaGroupIdentifier?, + senderBoostsCount: Int?, ) : this( - chat, messageId, threadId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId + chat, messageId, threadId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId, senderBoostsCount ) } 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 0a8735da19..86aa9e29cb 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 @@ -54,6 +54,7 @@ internal data class RawMessage( private val is_topic_message: Boolean? = null, private val is_automatic_forward: Boolean? = null, private val reply_to_message: RawMessage? = null, + private val reply_to_story: Story? = null, private val external_reply: ReplyInfo.External? = null, private val quote: TextQuote? = null, private val via_bot: CommonBot? = null, @@ -98,6 +99,7 @@ internal data class RawMessage( private val successful_payment: SuccessfulPayment? = null, private val giveaway: Giveaway? = null, private val giveaway_winners: GiveawayResults? = null, + private val sender_boost_count: Int? = null, private val users_shared: UsersShared? = null, private val chat_shared: ChatShared? = null, @@ -117,6 +119,9 @@ internal data class RawMessage( private val general_forum_topic_unhidden: GeneralForumTopicUnhidden? = null, private val write_access_allowed: WriteAccessAllowed? = null, + // Boost added to groups + private val boost_added: ChatBoostAdded? = null, + // AutoDelete Message time changed private val message_auto_delete_timer_changed: MessageAutoDeleteTimerChanged? = null, @@ -247,6 +252,7 @@ internal data class RawMessage( giveaway_created != null -> giveaway_created giveaway_winners is GiveawayPrivateResults -> giveaway_winners giveaway_completed != null -> giveaway_completed + boost_added != null -> boost_added else -> null } } @@ -295,6 +301,7 @@ internal data class RawMessage( reply_to_message != null -> ReplyInfo.Internal( reply_to_message.asMessage ) + reply_to_story != null -> ReplyInfo.ToStory(reply_to_story) external_reply != null -> external_reply else -> null } @@ -367,7 +374,8 @@ internal data class RawMessage( reply_markup, content, via_bot, - media_group_id + media_group_id, + sender_boost_count ) } } else { @@ -431,7 +439,8 @@ internal data class RawMessage( reply_markup, content, via_bot, - media_group_id + media_group_id, + sender_boost_count ) } } @@ -495,7 +504,8 @@ internal data class RawMessage( reply_markup, content, via_bot, - media_group_id + media_group_id, + sender_boost_count ) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupMessages.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupMessages.kt index 0ea78e8887..4f7f00be72 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupMessages.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/GroupMessages.kt @@ -8,6 +8,10 @@ sealed interface GroupContentMessage : PublicContentMessage< override val chat: PreviewGroupChat } +sealed interface PotentiallyFromUserGroupContentMessage : GroupContentMessage { + val senderBoostsCount: Int? +} + sealed interface ForumContentMessage : GroupContentMessage, PossiblyTopicMessage { override val chat: PreviewForumChat override val threadId: MessageThreadId @@ -28,7 +32,7 @@ interface AnonymousGroupContentMessage : GroupContentMessage get() = chat } -interface CommonGroupContentMessage : GroupContentMessage, FromUserMessage +interface CommonGroupContentMessage : GroupContentMessage, PotentiallyFromUserGroupContentMessage, FromUserMessage interface FromChannelForumContentMessage : FromChannelGroupContentMessage, ForumContentMessage @@ -37,4 +41,4 @@ interface AnonymousForumContentMessage : ForumContentMessage get() = chat } -interface CommonForumContentMessage : ForumContentMessage, FromUserMessage +interface CommonForumContentMessage : ForumContentMessage, PotentiallyFromUserGroupContentMessage, FromUserMessage diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stories/Story.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stories/Story.kt index 35154fd101..68ab2a34d8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stories/Story.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/stories/Story.kt @@ -1,7 +1,17 @@ package dev.inmo.tgbotapi.types.stories import dev.inmo.tgbotapi.types.ReplyInfo +import dev.inmo.tgbotapi.types.StoryId +import dev.inmo.tgbotapi.types.chat.PreviewChat +import dev.inmo.tgbotapi.types.chatField +import dev.inmo.tgbotapi.types.idField +import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -class Story : ReplyInfo.External.ContentVariant +data class Story( + @SerialName(idField) + val id: StoryId, + @SerialName(chatField) + val chat: PreviewChat +) : ReplyInfo.External.ContentVariant diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/MediaGroupContentMessageCreator.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/MediaGroupContentMessageCreator.kt index f8764c212f..a81465abeb 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/MediaGroupContentMessageCreator.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/MediaGroupContentMessageCreator.kt @@ -86,7 +86,8 @@ fun List>.asMedia sourceMessage.replyMarkup, content, sourceMessage.senderBot, - sourceMessage.mediaGroupId + sourceMessage.mediaGroupId, + sourceMessage.senderBoostsCount ) is ConnectedFromChannelGroupContentMessage -> ConnectedFromChannelGroupContentMessageImpl( sourceMessage.chat, @@ -146,7 +147,8 @@ fun List>.asMedia sourceMessage.replyMarkup, content, sourceMessage.senderBot, - sourceMessage.mediaGroupId + sourceMessage.mediaGroupId, + sourceMessage.senderBoostsCount ) is FromChannelForumContentMessage -> FromChannelForumContentMessageImpl( sourceMessage.chat, 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 e73520d8cd..7db7709e5b 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 @@ -222,6 +222,7 @@ import dev.inmo.tgbotapi.types.media.TitledTelegramMedia import dev.inmo.tgbotapi.types.media.VisualMediaGroupMemberTelegramMedia import dev.inmo.tgbotapi.types.message.ChannelEventMessage import dev.inmo.tgbotapi.types.message.ChatEvents.ChannelChatCreated +import dev.inmo.tgbotapi.types.message.ChatEvents.ChatBoostAdded import dev.inmo.tgbotapi.types.message.ChatEvents.DeleteChatPhoto import dev.inmo.tgbotapi.types.message.ChatEvents.GroupChatCreated import dev.inmo.tgbotapi.types.message.ChatEvents.LeftChatMemberEvent @@ -284,6 +285,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.PossiblyMediaGroupMessage import dev.inmo.tgbotapi.types.message.abstracts.PossiblyPaymentMessage import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage import dev.inmo.tgbotapi.types.message.abstracts.PossiblyTopicMessage +import dev.inmo.tgbotapi.types.message.abstracts.PotentiallyFromUserGroupContentMessage import dev.inmo.tgbotapi.types.message.abstracts.PrivateContentMessage import dev.inmo.tgbotapi.types.message.abstracts.PublicContentMessage import dev.inmo.tgbotapi.types.message.abstracts.SignedMessage @@ -1629,6 +1631,15 @@ public inline fun ReplyInfo.internalOrThrow(): ReplyInfo.Internal = this as public inline fun ReplyInfo.ifInternal(block: (ReplyInfo.Internal) -> T): T? = internalOrNull() ?.let(block) +public inline fun ReplyInfo.toStoryOrNull(): ReplyInfo.ToStory? = this as? + dev.inmo.tgbotapi.types.ReplyInfo.ToStory + +public inline fun ReplyInfo.toStoryOrThrow(): ReplyInfo.ToStory = this as + dev.inmo.tgbotapi.types.ReplyInfo.ToStory + +public inline fun ReplyInfo.ifToStory(block: (ReplyInfo.ToStory) -> T): T? = toStoryOrNull() + ?.let(block) + public inline fun BotAction.typingActionOrNull(): TypingAction? = this as? dev.inmo.tgbotapi.types.actions.TypingAction @@ -2882,6 +2893,15 @@ public inline fun ChatEvent.channelChatCreatedOrThrow(): ChannelChatCreated = th public inline fun ChatEvent.ifChannelChatCreated(block: (ChannelChatCreated) -> T): T? = channelChatCreatedOrNull() ?.let(block) +public inline fun ChatEvent.chatBoostAddedOrNull(): ChatBoostAdded? = this as? + dev.inmo.tgbotapi.types.message.ChatEvents.ChatBoostAdded + +public inline fun ChatEvent.chatBoostAddedOrThrow(): ChatBoostAdded = this as + dev.inmo.tgbotapi.types.message.ChatEvents.ChatBoostAdded + +public inline fun ChatEvent.ifChatBoostAdded(block: (ChatBoostAdded) -> T): T? = + chatBoostAddedOrNull() ?.let(block) + public inline fun ChatEvent.deleteChatPhotoOrNull(): DeleteChatPhoto? = this as? dev.inmo.tgbotapi.types.message.ChatEvents.DeleteChatPhoto @@ -3387,6 +3407,18 @@ public inline fun Message.ifGroupContentMessage(block: (GroupContentMessage) -> T): T? = groupContentMessageOrNull() ?.let(block) +public inline fun Message.potentiallyFromUserGroupContentMessageOrNull(): + PotentiallyFromUserGroupContentMessage? = this as? + dev.inmo.tgbotapi.types.message.abstracts.PotentiallyFromUserGroupContentMessage + +public inline fun Message.potentiallyFromUserGroupContentMessageOrThrow(): + PotentiallyFromUserGroupContentMessage = this as + dev.inmo.tgbotapi.types.message.abstracts.PotentiallyFromUserGroupContentMessage + +public inline fun + Message.ifPotentiallyFromUserGroupContentMessage(block: (PotentiallyFromUserGroupContentMessage) -> T): + T? = potentiallyFromUserGroupContentMessageOrNull() ?.let(block) + public inline fun Message.forumContentMessageOrNull(): ForumContentMessage? = this as? dev.inmo.tgbotapi.types.message.abstracts.ForumContentMessage