From 041c3ecc1b657ab6445d085738d998188d8cb3d5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 11 Feb 2023 18:57:46 +0600 Subject: [PATCH 1/6] start 5.1.1 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b8c7e45aa..99dedf75a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 5.1.1 + ## 5.1.0 [Bot API 6.5](https://core.telegram.org/bots/api-changelog#february-3-2023) support diff --git a/gradle.properties b/gradle.properties index 5290e27fd1..2b0c021b60 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ kotlin.incremental=true kotlin.incremental.js=true library_group=dev.inmo -library_version=5.1.0 +library_version=5.1.1 From dad42cf9390873c39e43bfcfce5cad46be45b218 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 13 Feb 2023 11:16:49 +0600 Subject: [PATCH 2/6] makeUserLink --- CHANGELOG.md | 3 +++ .../kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt | 3 ++- .../tgbotapi/extensions/utils/formatting/LinksFormatting.kt | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99dedf75a5..878dba441f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 5.1.1 +* `Core`: + * Add opportunity to get user link with `makeUserLink` + ## 5.1.0 [Bot API 6.5](https://core.telegram.org/bots/api-changelog#february-3-2023) support diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt index 625b8eaa4c..9165779964 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatIdentifier.kt @@ -14,6 +14,7 @@ import kotlinx.serialization.json.longOrNull import kotlin.jvm.JvmInline const val internalLinkBeginning = "https://t.me" +const val internalUserLinkBeginning = "tg://user?id=" @Serializable(ChatIdentifierSerializer::class) @ClassCastsIncluded @@ -66,7 +67,7 @@ fun IdChatIdentifier.toChatWithThreadId(threadId: MessageThreadId) = IdChatIdent */ @Warning("This API have restrictions in Telegram System") val Identifier.userLink: String - get() = "tg://user?id=$this" + get() = "$internalUserLinkBeginning$this" /** * https://core.telegram.org/bots/api#formatting-options */ diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt index d44a86475e..06fdef0e89 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt @@ -8,6 +8,7 @@ import io.ktor.http.encodeURLQueryComponent fun makeUsernameLink(username: String, threadId: MessageThreadId? = null) = "$internalLinkBeginning/$username${threadId ?.let { "/$it" } ?: ""}" +fun makeUserLink(userId: UserId) = userId.userLink fun makeChatLink(identifier: Identifier, threadId: MessageThreadId? = null) = identifier.toString().replace( linkIdRedundantPartRegex, "" From 5fc88e89b934623c65710c320d4c88ab778f6427 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 13 Feb 2023 11:49:36 +0600 Subject: [PATCH 3/6] Fixes in content waiting expectators --- CHANGELOG.md | 2 + .../expectations/WaitContentMessage.kt | 131 +++++++++++++----- .../utils/CommonMessageConversations.kt | 8 ++ 3 files changed, 104 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 878dba441f..faa8596f01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ * `Core`: * Add opportunity to get user link with `makeUserLink` +* `BehaviourBuilder`: + * Fixes in content waiting expectators ## 5.1.0 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 d908e016dd..fd569a204a 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 @@ -18,12 +18,14 @@ typealias CommonMessageToCommonMessageMapper = suspend CommonMessage.() -> @RiskFeature(lowLevelRiskFeatureMessage) suspend inline fun BehaviourContext.waitContentMessage( initRequest: Request<*>? = null, - includeMediaGroups: Boolean = true, noinline errorFactory: NullableRequestBuilder<*> = { null } ): Flow> = expectFlow( initRequest, errorFactory ) { + if (it !is BaseSentMessageUpdate) { + return@expectFlow emptyList() + } listOfNotNull((it.data as? CommonMessage<*>) ?.withContent()) } @@ -44,114 +46,169 @@ internal inline fun contentMessageConverter( if (content is T) this as CommonMessage else null } +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = true -) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContentMessage(initRequest, errorFactory) +suspend fun BehaviourContext.waitContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, +) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitContactMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContentMessage(initRequest, false, errorFactory) +) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitDiceMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContentMessage(initRequest, false, errorFactory) +) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitGameMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContentMessage(initRequest, false, errorFactory) +) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitLocationMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContentMessage(initRequest, false, errorFactory) +) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitLiveLocationMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContentMessage(initRequest, false, errorFactory) +) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitStaticLocationMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContentMessage(initRequest, false, errorFactory) +) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitPollMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContentMessage(initRequest, false, errorFactory) +) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitTextMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContentMessage(initRequest, false, errorFactory) +) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitVenueMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContentMessage(initRequest, false, errorFactory) +) = waitContentMessage(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitAudioMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = true -) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContentMessage(initRequest, errorFactory) +suspend fun BehaviourContext.waitAudioMediaGroupContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = true -) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContentMessage(initRequest, errorFactory) +suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitMediaMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = false -) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContentMessage(initRequest, errorFactory) +suspend fun BehaviourContext.waitMediaMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitAnyMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = true -) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContentMessage(initRequest, errorFactory) +suspend fun BehaviourContext.waitAnyMediaGroupContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitVisualMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = true -) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContentMessage(initRequest, errorFactory) +suspend fun BehaviourContext.waitVisualMediaGroupContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitTextedMediaContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = true -) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContentMessage(initRequest, errorFactory) +suspend fun BehaviourContext.waitTextedMediaContentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitAnimationMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContentMessage(initRequest, false, errorFactory) +) = waitContentMessage(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitAudioMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = false -) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContentMessage(initRequest, errorFactory) +suspend fun BehaviourContext.waitAudioMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitDocumentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = false -) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContentMessage(initRequest, errorFactory) +suspend fun BehaviourContext.waitDocumentMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitPhotoMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = false -) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContentMessage(initRequest, errorFactory) +suspend fun BehaviourContext.waitPhotoMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitStickerMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContentMessage(initRequest, false, errorFactory) +) = waitContentMessage(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitVideoMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = false -) = waitContentMessage(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContentMessage(initRequest, errorFactory) +suspend fun BehaviourContext.waitVideoMessage( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitVideoNoteMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContentMessage(initRequest, false, errorFactory) +) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitVoiceMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContentMessage(initRequest, false, errorFactory) +) = waitContentMessage(initRequest, errorFactory) suspend fun BehaviourContext.waitInvoiceMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContentMessage(initRequest, false, errorFactory) +) = waitContentMessage(initRequest, errorFactory) diff --git a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/CommonMessageConversations.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/CommonMessageConversations.kt index 172dab74cc..541de0bea5 100644 --- a/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/CommonMessageConversations.kt +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/CommonMessageConversations.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.extensions.utils import dev.inmo.tgbotapi.types.message.abstracts.* +import dev.inmo.tgbotapi.types.message.content.MediaGroupContent import dev.inmo.tgbotapi.types.message.content.MessageContent import kotlinx.coroutines.flow.* @@ -34,3 +35,10 @@ fun > Flow.onlySentViaBot() = map fun > Flow.withoutSentViaBot() = filter { it !is PossiblySentViaBot || it.senderBot == null } + +/** + * Filter the messages and checking that incoming [ContentMessage.content] is not [MediaGroupContent] + */ +fun > Flow.withoutMediaGroups() = filter { + it.content !is MediaGroupContent<*> +} From 48c4e90912fcf3cc1a26b4376768851c8f6ffd62 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 13 Feb 2023 12:00:09 +0600 Subject: [PATCH 4/6] fixes --- .../expectations/WaitContent.kt | 130 +++++++++++++----- 1 file changed, 92 insertions(+), 38 deletions(-) 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 86028c62a8..3cef39d70b 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 @@ -16,119 +16,173 @@ typealias CommonMessageToContentMapper = suspend CommonMessage.() -> T? @RiskFeature(lowLevelRiskFeatureMessage) suspend inline fun BehaviourContext.waitContent( initRequest: Request<*>? = null, - includeMediaGroups: Boolean = true, noinline errorFactory: NullableRequestBuilder<*> = { null } -): Flow = waitContentMessage(initRequest, includeMediaGroups, errorFactory).map { it.content } +): Flow = waitContentMessage(initRequest, errorFactory).map { it.content } +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = true -) = waitContent(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContent(initRequest, errorFactory) +suspend fun BehaviourContext.waitContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitContact( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContent(initRequest, false, errorFactory) +) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitDice( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContent(initRequest, false, errorFactory) +) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitGame( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContent(initRequest, false, errorFactory) +) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitLocation( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContent(initRequest, false, errorFactory) +) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitLiveLocation( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContent(initRequest, false, errorFactory) +) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitStaticLocation( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContent(initRequest, false, errorFactory) +) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitPoll( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContent(initRequest, false, errorFactory) +) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitText( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContent(initRequest, false, errorFactory) +) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitVenue( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContent(initRequest, false, errorFactory) +) = waitContent(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitAudioMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = true -) = waitContent(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContent(initRequest, errorFactory) +suspend fun BehaviourContext.waitAudioMediaGroupContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, +) = waitContent(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitDocumentMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = true -) = waitContent(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContent(initRequest, errorFactory) +suspend fun BehaviourContext.waitDocumentMediaGroupContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitMedia( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = false -) = waitContent(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContent(initRequest, errorFactory) +suspend fun BehaviourContext.waitMedia( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitAnyMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = true -) = waitContent(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContent(initRequest, errorFactory) +suspend fun BehaviourContext.waitAnyMediaGroupContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, +) = waitContent(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitVisualMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = true -) = waitContent(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContent(initRequest, errorFactory) +suspend fun BehaviourContext.waitVisualMediaGroupContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, +) = waitContent(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitTextedMediaContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = true -) = waitContent(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContent(initRequest, errorFactory) +suspend fun BehaviourContext.waitTextedMediaContent( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, +) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitAnimation( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContent(initRequest, false, errorFactory) +) = waitContent(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitAudio( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = false -) = waitContent(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContent(initRequest, errorFactory) +suspend fun BehaviourContext.waitAudio( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, +) = waitContent(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitDocument( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = false -) = waitContent(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContent(initRequest, errorFactory) +suspend fun BehaviourContext.waitDocument( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, +) = waitContent(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitPhoto( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = false -) = waitContent(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContent(initRequest, errorFactory) +suspend fun BehaviourContext.waitPhoto( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, +) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitSticker( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContent(initRequest, false, errorFactory) +) = waitContent(initRequest, errorFactory) +@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") suspend fun BehaviourContext.waitVideo( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, - includeMediaGroups: Boolean = false -) = waitContent(initRequest, includeMediaGroups, errorFactory) + includeMediaGroups: Boolean +) = waitContent(initRequest, errorFactory) +suspend fun BehaviourContext.waitVideo( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null } +) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitVideoNote( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContent(initRequest, false, errorFactory) +) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitVoice( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContent(initRequest, false, errorFactory) +) = waitContent(initRequest, errorFactory) suspend fun BehaviourContext.waitInvoice( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } -) = waitContent(initRequest, false, errorFactory) +) = waitContent(initRequest, errorFactory) From 0416b200b8e9f84a87ca3409500f4fc95a9c17a9 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 13 Feb 2023 12:03:17 +0600 Subject: [PATCH 5/6] fixes :) --- .../extensions/behaviour_builder/expectations/WaitContent.kt | 2 +- .../behaviour_builder/expectations/WaitContentMessage.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 3cef39d70b..62f0307f7f 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 @@ -26,7 +26,7 @@ suspend fun BehaviourContext.waitContent( errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean ) = waitContent(initRequest, errorFactory) -suspend fun BehaviourContext.waitContent( +suspend fun BehaviourContext.waitAnyContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContent(initRequest, errorFactory) 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 fd569a204a..74497e60c5 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 @@ -52,7 +52,7 @@ suspend fun BehaviourContext.waitContentMessage( errorFactory: NullableRequestBuilder<*> = { null }, includeMediaGroups: Boolean ) = waitContentMessage(initRequest, errorFactory) -suspend fun BehaviourContext.waitContentMessage( +suspend fun BehaviourContext.waitAnyContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, ) = waitContentMessage(initRequest, errorFactory) From 1c94e86b40569292f3c6da9316f7ac8f980c86d3 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 13 Feb 2023 12:06:28 +0600 Subject: [PATCH 6/6] small improvements --- .../expectations/WaitContent.kt | 25 ++++++++++-------- .../expectations/WaitContentMessage.kt | 26 +++++++++++-------- 2 files changed, 29 insertions(+), 22 deletions(-) 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 62f0307f7f..eed6617247 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 @@ -20,7 +20,10 @@ suspend inline fun BehaviourContext.waitContent( ): Flow = waitContentMessage(initRequest, errorFactory).map { it.content } -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated( + includeMediaGroupsDeprecationMessage, + ReplaceWith("waitAnyContent(initRequest, errorFactory)", "dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitAnyContent") +) suspend fun BehaviourContext.waitContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -66,7 +69,7 @@ suspend fun BehaviourContext.waitVenue( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContent(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitAudioMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -76,7 +79,7 @@ suspend fun BehaviourContext.waitAudioMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, ) = waitContent(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitDocumentMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -86,7 +89,7 @@ suspend fun BehaviourContext.waitDocumentMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContent(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitMedia( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -96,7 +99,7 @@ suspend fun BehaviourContext.waitMedia( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContent(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitAnyMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -106,7 +109,7 @@ suspend fun BehaviourContext.waitAnyMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, ) = waitContent(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitVisualMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -116,7 +119,7 @@ suspend fun BehaviourContext.waitVisualMediaGroupContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, ) = waitContent(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitTextedMediaContent( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -130,7 +133,7 @@ suspend fun BehaviourContext.waitAnimation( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContent(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitAudio( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -140,7 +143,7 @@ suspend fun BehaviourContext.waitAudio( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, ) = waitContent(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitDocument( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -150,7 +153,7 @@ suspend fun BehaviourContext.waitDocument( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, ) = waitContent(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitPhoto( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -164,7 +167,7 @@ suspend fun BehaviourContext.waitSticker( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContent(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitVideo( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, 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 74497e60c5..8f0c069aae 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 @@ -13,6 +13,7 @@ import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage import kotlinx.coroutines.flow.Flow +const val includeMediaGroupsDeprecationMessage = "includeMediaGroups is deprecated and its usage will not lead to any changes" typealias CommonMessageToCommonMessageMapper = suspend CommonMessage.() -> CommonMessage? @RiskFeature(lowLevelRiskFeatureMessage) @@ -46,7 +47,10 @@ internal inline fun contentMessageConverter( if (content is T) this as CommonMessage else null } -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated( + includeMediaGroupsDeprecationMessage, + ReplaceWith("waitAnyContentMessage(initRequest, errorFactory)", "dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitAnyContentMessage") +) suspend fun BehaviourContext.waitContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -92,7 +96,7 @@ suspend fun BehaviourContext.waitVenueMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitAudioMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -102,7 +106,7 @@ suspend fun BehaviourContext.waitAudioMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -112,7 +116,7 @@ suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitMediaMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -122,7 +126,7 @@ suspend fun BehaviourContext.waitMediaMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitAnyMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -132,7 +136,7 @@ suspend fun BehaviourContext.waitAnyMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitVisualMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -142,7 +146,7 @@ suspend fun BehaviourContext.waitVisualMediaGroupContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitTextedMediaContentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -156,7 +160,7 @@ suspend fun BehaviourContext.waitAnimationMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitAudioMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -166,7 +170,7 @@ suspend fun BehaviourContext.waitAudioMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitDocumentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -176,7 +180,7 @@ suspend fun BehaviourContext.waitDocumentMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitPhotoMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -190,7 +194,7 @@ suspend fun BehaviourContext.waitStickerMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null } ) = waitContentMessage(initRequest, errorFactory) -@Deprecated("includeMediaGroups is deprecated and its usage will not lead to any changes") +@Deprecated(includeMediaGroupsDeprecationMessage) suspend fun BehaviourContext.waitVideoMessage( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null },