From 2aa6497374bce6b724d11f615b851691b95b9fae Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 1 Oct 2021 15:45:37 +0600 Subject: [PATCH 01/40] start 0.36.0 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a19c868f7..49ac0ac817 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 0.36.0 + ## 0.35.9 * `Common`: diff --git a/gradle.properties b/gradle.properties index fdb5b4b8bc..32b8ec4580 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,6 +17,6 @@ micro_utils_version=0.5.28 javax_activation_version=1.1.1 library_group=dev.inmo -library_version=0.35.9 +library_version=0.36.0 github_release_plugin_version=2.2.12 From 40bd8d098727f43e53b6cacb03c02b5b35bbdcf6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 1 Oct 2021 15:46:07 +0600 Subject: [PATCH 02/40] update dependencies --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 32b8ec4580..c690485bc7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,11 +8,11 @@ kotlin.incremental.js=true kotlin_version=1.5.31 kotlin_coroutines_version=1.5.2 kotlin_serialisation_runtime_version=1.2.2 -klock_version=2.4.2 +klock_version=2.4.3 uuid_version=0.3.1 ktor_version=1.6.3 -micro_utils_version=0.5.28 +micro_utils_version=0.5.31 javax_activation_version=1.1.1 From 5b98c5f821a25da61cc0edb82a049246685a62a8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 1 Oct 2021 16:40:04 +0600 Subject: [PATCH 03/40] update dependencies --- CHANGELOG.md | 8 + gradle.properties | 4 +- .../tgbotapi/CommonAbstracts/TextSource.kt | 79 ------ .../Ktor/base/MultipartRequestCallFactory.kt | 3 - .../bot/Ktor/base/SimpleRequestCallFactory.kt | 3 - .../tgbotapi/requests/abstracts/InputFile.kt | 10 - .../requests/chat/get/GetChatMemberCount.kt | 3 - .../requests/chat/members/BanChatMember.kt | 3 - .../types/ChatMember/LeftChatMemberImpl.kt | 3 - .../types/ChatMember/MemberChatMemberImpl.kt | 3 - .../abstracts/ChosenInlineResult.kt | 6 - .../InlineQueries/abstracts/InlineQuery.kt | 6 - .../abstracts/InputMessageContent.kt | 6 - .../MessageEntity/textsources/TextSource.kt | 3 - .../inmo/tgbotapi/types/buttons/ReplyForce.kt | 3 - .../inmo/tgbotapi/types/files/PathedFile.kt | 3 - .../updateshandlers/FlowsUpdatesFilter.kt | 55 ---- .../dev/inmo/tgbotapi/utils/StorageFile.kt | 25 -- .../tgbotapi/extensions/api/DownloadFile.kt | 25 -- .../api/chat/get/GetChatMemberCount.kt | 10 - .../api/chat/members/BanChatMember.kt | 32 --- .../extensions/api/send/games/SendGame.kt | 36 --- .../api/send/media/SendAnimation.kt | 125 --------- .../extensions/api/send/media/SendAudio.kt | 94 ------- .../extensions/api/send/media/SendDocument.kt | 90 ------ .../api/send/media/SendMediaGroup.kt | 57 ---- .../extensions/api/send/media/SendPhoto.kt | 83 ------ .../extensions/api/send/media/SendSticker.kt | 37 --- .../extensions/api/send/media/SendVideo.kt | 90 ------ .../api/send/media/SendVideoNote.kt | 43 --- .../extensions/api/send/media/SendVoice.kt | 85 ------ .../api/send/payments/SendInvoice.kt | 29 -- .../extensions/api/send/polls/SendPoll.kt | 111 -------- .../behaviour_builder/BehaviourBuilders.kt | 32 +-- .../CallbackQueryTriggers.kt | 109 -------- .../ChatMemberUpdatedTriggers.kt | 39 --- .../triggers_handling/CommandHandling.kt | 112 -------- .../triggers_handling/ContentTriggers.kt | 261 ------------------ .../triggers_handling/EventTriggers.kt | 144 ---------- .../triggers_handling/InlineQueryTriggers.kt | 27 -- .../triggers_handling/MediaGroupTriggers.kt | 52 ---- .../triggers_handling/PassportTriggers.kt | 13 - .../utils/extensions/FlowsUpdatesFilter.kt | 14 - .../inmo/tgbotapi/types/files/PathedFile.kt | 23 +- 44 files changed, 12 insertions(+), 1987 deletions(-) delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/TextSource.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/ChosenInlineResult.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/InlineQuery.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/InputMessageContent.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 49ac0ac817..b0ed2b5720 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ ## 0.36.0 +**ALL PREVIOUS DEPRECATIONS HAVE BEEN REMOVED** + +* `Common`: + * `Version`: + * `Serialization`: `1.2.2` -> `1.3.0` + * `Ktor`: `1.6.3` -> `1.6.4` + * `MicroUtils`: `0.5.28` -> `0.5.31` + ## 0.35.9 * `Common`: diff --git a/gradle.properties b/gradle.properties index c690485bc7..7b05ee0f74 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,10 +7,10 @@ kotlin.incremental.js=true kotlin_version=1.5.31 kotlin_coroutines_version=1.5.2 -kotlin_serialisation_runtime_version=1.2.2 +kotlin_serialisation_runtime_version=1.3.0 klock_version=2.4.3 uuid_version=0.3.1 -ktor_version=1.6.3 +ktor_version=1.6.4 micro_utils_version=0.5.31 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/TextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/TextSource.kt deleted file mode 100644 index 951cb4b17d..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/TextSource.kt +++ /dev/null @@ -1,79 +0,0 @@ -package dev.inmo.tgbotapi.CommonAbstracts - -import dev.inmo.tgbotapi.types.MessageEntity.textsources.* -import dev.inmo.tgbotapi.types.MessageEntity.textsources.MultilevelTextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource -import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList -import dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForCaption -import dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForMessage -import dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForText -import dev.inmo.tgbotapi.types.captionLength -import dev.inmo.tgbotapi.types.textLength -import dev.inmo.tgbotapi.utils.extensions.makeString - -const val DirectInvocationOfTextSourceConstructor = - "It is strongly not recommended to use constructors directly instead of factory methods" - -@Deprecated( - "Replaced", - ReplaceWith("TextSourcesList", "dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList") -) -typealias TextSourcesList = TextSourcesList - -@Deprecated("Replaced", ReplaceWith("TextSource", "dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource")) -typealias TextSource = TextSource - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.MessageEntity.textsources.plus")) -inline operator fun TextSource.plus(other: TextSource) = - listOf(this, other) - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.MessageEntity.textsources.plus")) -inline operator fun TextSource.plus(other: List) = - listOf(this) + other - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.MessageEntity.textsources.plus")) -inline operator fun TextSource.plus(text: String) = - listOf(this, regular(text)) - -@Suppress("NOTHING_TO_INLINE") -@Deprecated("Replaced", ReplaceWith("plus", "dev.inmo.tgbotapi.types.MessageEntity.textsources.plus")) -inline operator fun List.plus(text: String) = this + regular(text) - -@Deprecated( - "Replaced", - ReplaceWith("MultilevelTextSource", "dev.inmo.tgbotapi.types.MessageEntity.textsources.MultilevelTextSource") -) -typealias MultilevelTextSource = MultilevelTextSource - -@Deprecated("Replaced", ReplaceWith("makeString()", "dev.inmo.tgbotapi.utils.extensions.makeString")) -fun List.makeString() = makeString() - -@Deprecated( - "Replaced", - ReplaceWith("separateForMessage", "dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForMessage") -) -fun List.separateForMessage(limit: IntRange, numberOfParts: Int? = null) = - separateForMessage(limit, numberOfParts) - -/** - * This method will prepare [TextSource]s list for messages. Remember, that first part will be separated with - * [captionLength] and all others with - */ -@Deprecated( - "Replaced", - ReplaceWith("separateForCaption", "dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForCaption") -) -fun List.separateForCaption() = separateForCaption() - -/** - * This method will prepare [TextSource]s list for messages with [textLength] - */ -@Suppress("NOTHING_TO_INLINE") -@Deprecated( - "Replaced", - ReplaceWith("separateForText", "dev.inmo.tgbotapi.types.MessageEntity.textsources.separateForText") -) -inline fun List.separateForText() = separateForText() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/MultipartRequestCallFactory.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/MultipartRequestCallFactory.kt index fab01c75fb..feb0daeb65 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/MultipartRequestCallFactory.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/MultipartRequestCallFactory.kt @@ -35,7 +35,4 @@ class MultipartRequestCallFactory : AbstractRequestCallFactory() { } ) } - - @Deprecated("Use class MultipartRequestCallFactory() constructor call instead of just MultipartRequestCallFactory") - companion object : KtorCallFactory by MultipartRequestCallFactory() } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/SimpleRequestCallFactory.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/SimpleRequestCallFactory.kt index 6c83ac9eeb..e774819815 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/SimpleRequestCallFactory.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/SimpleRequestCallFactory.kt @@ -20,7 +20,4 @@ class SimpleRequestCallFactory : AbstractRequestCallFactory() { ContentType.Application.Json ) } - - @Deprecated("Use class SimpleRequestCallFactory() constructor call instead of just SimpleRequestCallFactory") - companion object : KtorCallFactory by SimpleRequestCallFactory() } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt index 834437b25f..8c71b6c6c8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/abstracts/InputFile.kt @@ -64,21 +64,11 @@ data class MultipartFile ( val filename: String = file.storageFileInfo.fileName ) : InputFile() { override val fileId: String = file.storageFileInfo.generateCustomName() - - @Deprecated("This constructor is redundant. Use constructor without mime type") - constructor(file: StorageFile, mimeType: String, filename: String): this(file, filename) } @Suppress("NOTHING_TO_INLINE", "unused") inline fun StorageFile.asMultipartFile() = MultipartFile(this) -@Deprecated("This method is redundant. Use asMultipartFile without mime type") -@Suppress("NOTHING_TO_INLINE", "unused") -inline fun ByteArray.asMultipartFile( - fileName: String, - mimeType: MimeType -) = MultipartFile(asStorageFile(fileName)) - @Suppress("NOTHING_TO_INLINE", "unused") suspend inline fun ByteReadChannel.asMultipartFile( fileName: String diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/get/GetChatMemberCount.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/get/GetChatMemberCount.kt index c8c5a688b8..af54d4992f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/get/GetChatMemberCount.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/get/GetChatMemberCount.kt @@ -18,6 +18,3 @@ data class GetChatMemberCount( override val requestSerializer: SerializationStrategy<*> get() = serializer() } - -@Deprecated("Renamed", ReplaceWith("GetChatMemberCount", "dev.inmo.tgbotapi.requests.chat.get.GetChatMemberCount")) -typealias GetChatMembersCount = GetChatMemberCount diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/BanChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/BanChatMember.kt index 2dacaab43c..0aac06c4f6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/BanChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/BanChatMember.kt @@ -23,6 +23,3 @@ data class BanChatMember( override val requestSerializer: SerializationStrategy<*> get() = serializer() } - -@Deprecated("Renamed", ReplaceWith("BanChatMember", "dev.inmo.tgbotapi.requests.chat.members.BanChatMember")) -typealias KickChatMember = BanChatMember diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/LeftChatMemberImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/LeftChatMemberImpl.kt index 50990b860c..d12e4b551b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/LeftChatMemberImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/LeftChatMemberImpl.kt @@ -10,6 +10,3 @@ data class LeftChatMemberImpl(@SerialName(userField) override val user: User) : @Required private val type: String = "left" } - -@Deprecated("Renamed", ReplaceWith("LeftChatMemberImpl", "dev.inmo.tgbotapi.types.ChatMember.LeftChatMemberImpl")) -typealias LeftChatMember = LeftChatMemberImpl diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/MemberChatMemberImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/MemberChatMemberImpl.kt index 3adbac1b3c..0f76788380 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/MemberChatMemberImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/MemberChatMemberImpl.kt @@ -10,6 +10,3 @@ data class MemberChatMemberImpl(@SerialName(userField) override val user: User) @Required private val type: String = "member" } - -@Deprecated("Renamed", ReplaceWith("MemberChatMember", "dev.inmo.tgbotapi.types.ChatMember.MemberChatMemberImpl")) -typealias MemberChatMember = MemberChatMemberImpl diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/ChosenInlineResult.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/ChosenInlineResult.kt deleted file mode 100644 index 999d0deba6..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/ChosenInlineResult.kt +++ /dev/null @@ -1,6 +0,0 @@ -package dev.inmo.tgbotapi.types.InlineQueries.abstracts - -import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.ChosenInlineResult - -@Deprecated("Replaced", ReplaceWith("ChosenInlineResult", "dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.ChosenInlineResult")) -typealias ChosenInlineResult = ChosenInlineResult diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/InlineQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/InlineQuery.kt deleted file mode 100644 index 8d73477fa8..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/InlineQuery.kt +++ /dev/null @@ -1,6 +0,0 @@ -package dev.inmo.tgbotapi.types.InlineQueries.abstracts - -import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery - -@Deprecated("Replaced", ReplaceWith("InlineQuery", "dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery")) -typealias InlineQuery = InlineQuery diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/InputMessageContent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/InputMessageContent.kt deleted file mode 100644 index e3fb5789b0..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/abstracts/InputMessageContent.kt +++ /dev/null @@ -1,6 +0,0 @@ -package dev.inmo.tgbotapi.types.InlineQueries.abstracts - -import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent - -@Deprecated("Replaced", ReplaceWith("InputMessageContent", "dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputMessageContent")) -typealias InputMessageContent = InputMessageContent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSource.kt index 340ccd1937..539410980d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextSource.kt @@ -2,7 +2,6 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources import dev.inmo.tgbotapi.types.captionLength import dev.inmo.tgbotapi.types.textLength -import dev.inmo.tgbotapi.utils.extensions.makeString import kotlinx.serialization.Serializable const val DirectInvocationOfTextSourceConstructor = "It is strongly not recommended to use constructors directly instead of factory methods" @@ -43,8 +42,6 @@ sealed interface MultilevelTextSource : TextSource { } } -@Deprecated("Replaced", ReplaceWith("makeString()", "dev.inmo.tgbotapi.utils.extensions.makeString")) -fun TextSourcesList.makeString() = makeString(null) fun List.separateForMessage(limit: IntRange, numberOfParts: Int? = null): List> { if (isEmpty()) { return emptyList() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyForce.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyForce.kt index bfa3ad377e..d8d68db3ad 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyForce.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/ReplyForce.kt @@ -26,6 +26,3 @@ data class ReplyForce( } } } - -@Deprecated("Renamed", ReplaceWith("ReplyForce", "dev.inmo.tgbotapi.types.buttons.ReplyForce")) -typealias ForceReply = ReplyForce diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt index 247aa63c12..e1dd2ac001 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt @@ -24,8 +24,5 @@ data class PathedFile( } } -@Deprecated("Use fileName property instead", ReplaceWith("fileName")) -val PathedFile.filename: FileName - get() = filePath.filenameFromUrl fun TelegramAPIUrlsKeeper.resolveFileURL(file: PathedFile): String = "$fileBaseUrl/${file.filePath}" fun PathedFile.fullUrl(keeper: TelegramAPIUrlsKeeper): String = keeper.resolveFileURL(this) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt index a926a0c719..afc186883d 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt @@ -32,61 +32,6 @@ interface FlowsUpdatesFilter : UpdatesFilter { val chatMemberUpdatesFlow: Flow val myChatMemberUpdatesFlow: Flow val unknownUpdatesFlow: Flow - - @Deprecated("Renamed", ReplaceWith("messagesFlow")) - val messageFlow: Flow - get() = messagesFlow - @Deprecated("Renamed", ReplaceWith("messageMediaGroupsFlow")) - val messageMediaGroupFlow: Flow - get() = messageMediaGroupsFlow - @Deprecated("Renamed", ReplaceWith("editedMessagesFlow")) - val editedMessageFlow: Flow - get() = editedMessagesFlow - @Deprecated("Renamed", ReplaceWith("editedMessageMediaGroupsFlow")) - val editedMessageMediaGroupFlow: Flow - get() = editedMessageMediaGroupsFlow - @Deprecated("Renamed", ReplaceWith("channelPostsFlow")) - val channelPostFlow: Flow - get() = channelPostsFlow - @Deprecated("Renamed", ReplaceWith("channelPostMediaGroupsFlow")) - val channelPostMediaGroupFlow: Flow - get() = channelPostMediaGroupsFlow - @Deprecated("Renamed", ReplaceWith("editedChannelPostsFlow")) - val editedChannelPostFlow: Flow - get() = editedChannelPostsFlow - @Deprecated("Renamed", ReplaceWith("editedChannelPostMediaGroupsFlow")) - val editedChannelPostMediaGroupFlow: Flow - get() = editedChannelPostMediaGroupsFlow - @Deprecated("Renamed", ReplaceWith("chosenInlineResultsFlow")) - val chosenInlineResultFlow: Flow - get() = chosenInlineResultsFlow - @Deprecated("Renamed", ReplaceWith("inlineQueriesFlow")) - val inlineQueryFlow: Flow - get() = inlineQueriesFlow - @Deprecated("Renamed", ReplaceWith("callbackQueriesFlow")) - val callbackQueryFlow: Flow - get() = callbackQueriesFlow - @Deprecated("Renamed", ReplaceWith("shippingQueriesFlow")) - val shippingQueryFlow: Flow - get() = shippingQueriesFlow - @Deprecated("Renamed", ReplaceWith("preCheckoutQueriesFlow")) - val preCheckoutQueryFlow: Flow - get() = preCheckoutQueriesFlow - @Deprecated("Renamed", ReplaceWith("pollsFlow")) - val pollFlow: Flow - get() = pollsFlow - @Deprecated("Renamed", ReplaceWith("pollAnswersFlow")) - val pollAnswerFlow: Flow - get() = pollAnswersFlow - @Deprecated("Renamed", ReplaceWith("chatMemberUpdatesFlow")) - val chatMemberUpdatedFlow: Flow - get() = chatMemberUpdatesFlow - @Deprecated("Renamed", ReplaceWith("myChatMemberUpdatesFlow")) - val myChatMemberUpdatedFlow: Flow - get() = myChatMemberUpdatesFlow - @Deprecated("Renamed", ReplaceWith("unknownUpdatesFlow")) - val unknownUpdateTypeFlow: Flow - get() = unknownUpdatesFlow } /** diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/StorageFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/StorageFile.kt index a67bb9f19e..2296e232dd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/StorageFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/StorageFile.kt @@ -16,12 +16,6 @@ import kotlinx.serialization.Serializable data class StorageFileInfo( val fileName: String ) { - @Deprecated("This constructor is redundant. Use constructor without mime type") - constructor( - contentType: String, - fileName: String - ): this(fileName) - /** * This methods is required for random generation of name for keeping warranties about unique file name */ @@ -45,18 +39,6 @@ data class StorageFile( get() = inputSource() } -@Deprecated("This constructor is redundant. Use constructor without mime type") -@Suppress("NOTHING_TO_INLINE") -inline fun StorageFile( - fileName: String, - bytes: ByteArray, - mimeType: MimeType -) = StorageFile( - StorageFileInfo(fileName) -) { - ByteReadPacket(bytes) -} - @Suppress("NOTHING_TO_INLINE") inline fun StorageFile( fileName: String, @@ -81,13 +63,6 @@ inline fun ByteArray.asStorageFile( fileName: String ) = StorageFile(fileName, this) -@Deprecated("This constructor is redundant. Use constructor without mime type") -@Suppress("NOTHING_TO_INLINE", "unused") -inline fun ByteArray.asStorageFile( - fileName: String, - mimeType: MimeType -) = asStorageFile(fileName) - @Suppress("NOTHING_TO_INLINE", "unused") suspend inline fun ByteReadChannel.asStorageFile( fileName: String diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DownloadFile.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DownloadFile.kt index 627f75ec8b..c3ca7ab6e0 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DownloadFile.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DownloadFile.kt @@ -6,28 +6,3 @@ import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.files.PathedFile import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent - -@Deprecated("Replaced", ReplaceWith("downloadFile", "dev.inmo.tgbotapi.extensions.api.files.downloadFile")) -suspend fun TelegramBot.downloadFile( - filePath: String -): ByteArray = downloadFile(filePath) - -@Deprecated("Replaced", ReplaceWith("downloadFile", "dev.inmo.tgbotapi.extensions.api.files.downloadFile")) -suspend fun TelegramBot.downloadFile( - pathedFile: PathedFile -): ByteArray = downloadFile(pathedFile) - -@Deprecated("Replaced", ReplaceWith("downloadFile", "dev.inmo.tgbotapi.extensions.api.files.downloadFile")) -suspend fun TelegramBot.downloadFile( - fileId: FileId -): ByteArray = downloadFile(fileId) - -@Deprecated("Replaced", ReplaceWith("downloadFile", "dev.inmo.tgbotapi.extensions.api.files.downloadFile")) -suspend fun TelegramBot.downloadFile( - file: TelegramMediaFile -): ByteArray = downloadFile(file) - -@Deprecated("Replaced", ReplaceWith("downloadFile", "dev.inmo.tgbotapi.extensions.api.files.downloadFile")) -suspend fun TelegramBot.downloadFile( - file: MediaContent -): ByteArray = downloadFile(file) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatMemberCount.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatMemberCount.kt index 0f165b759a..b53fe39ac6 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatMemberCount.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatMemberCount.kt @@ -12,13 +12,3 @@ suspend fun TelegramBot.getChatMemberCount( suspend fun TelegramBot.getChatMemberCount( chat: PublicChat ) = getChatMemberCount(chat.id) - -@Deprecated("Renamed", ReplaceWith("getChatMemberCount", "dev.inmo.tgbotapi.extensions.api.chat.get.getChatMemberCount")) -suspend fun TelegramBot.getChatMembersCount( - chatId: ChatIdentifier -) = getChatMemberCount(chatId) - -@Deprecated("Renamed", ReplaceWith("getChatMemberCount", "dev.inmo.tgbotapi.extensions.api.chat.get.getChatMemberCount")) -suspend fun TelegramBot.getChatMembersCount( - chat: PublicChat -) = getChatMemberCount(chat) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatMember.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatMember.kt index 6cf936caa6..dc8a069e78 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatMember.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatMember.kt @@ -32,35 +32,3 @@ suspend fun TelegramBot.banChatMember( untilDate: TelegramDate? = null, revokeMessages: Boolean? = null ) = banChatMember(chat.id, user.id, untilDate, revokeMessages) - -@Deprecated("Renamed", ReplaceWith("banChatMember", "dev.inmo.tgbotapi.extensions.api.chat.members.banChatMember")) -suspend fun TelegramBot.kickChatMember( - chatId: ChatIdentifier, - userId: UserId, - untilDate: TelegramDate? = null, - revokeMessages: Boolean? = null -) = banChatMember(chatId, userId, untilDate, revokeMessages) - -@Deprecated("Renamed", ReplaceWith("banChatMember", "dev.inmo.tgbotapi.extensions.api.chat.members.banChatMember")) -suspend fun TelegramBot.kickChatMember( - chat: PublicChat, - userId: UserId, - untilDate: TelegramDate? = null, - revokeMessages: Boolean? = null -) = banChatMember(chat, userId, untilDate, revokeMessages) - -@Deprecated("Renamed", ReplaceWith("banChatMember", "dev.inmo.tgbotapi.extensions.api.chat.members.banChatMember")) -suspend fun TelegramBot.kickChatMember( - chatId: ChatId, - user: User, - untilDate: TelegramDate? = null, - revokeMessages: Boolean? = null -) = banChatMember(chatId, user, untilDate, revokeMessages) - -@Deprecated("Renamed", ReplaceWith("banChatMember", "dev.inmo.tgbotapi.extensions.api.chat.members.banChatMember")) -suspend fun TelegramBot.kickChatMember( - chat: PublicChat, - user: User, - untilDate: TelegramDate? = null, - revokeMessages: Boolean? = null -) = banChatMember(chat, user, untilDate, revokeMessages) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/games/SendGame.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/games/SendGame.kt index 5dd0fa73d0..fea4bc7185 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/games/SendGame.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/games/SendGame.kt @@ -56,39 +56,3 @@ suspend fun TelegramBot.sendGame( ) = sendGame( chat.id, game.title, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup ) - -@Deprecated( - "Replaced", - ReplaceWith("replyWithGame", "dev.inmo.tgbotapi.extensions.api.send.replyWithGame") -) -suspend inline fun TelegramBot.replyWithGame( - to: Message, - gameShortName: String, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = replyWithGame(to, gameShortName, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("replyWithGame", "dev.inmo.tgbotapi.extensions.api.send.replyWithGame") -) -suspend inline fun TelegramBot.replyWithGame( - to: Message, - game: Game, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = replyWithGame(to, game, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.reply( - to: Message, - game: Game, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, game, disableNotification, allowSendingWithoutReply, replyMarkup) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt index 67a3d7ba79..fa3210e83a 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt @@ -159,128 +159,3 @@ suspend fun TelegramBot.sendAnimation( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAnimation(chat.id, animation, entities, duration, width, height, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("replyWithAnimation", "dev.inmo.tgbotapi.extensions.api.send.replyWithAnimation") -) -suspend inline fun TelegramBot.replyWithAnimation( - to: Message, - animation: InputFile, - thumb: InputFile? = null, - entities: TextSourcesList, - duration: Long? = null, - width: Int? = null, - height: Int? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = replyWithAnimation( - to, - animation, - entities, - thumb, - duration, - width, - height, - disableNotification, - allowSendingWithoutReply, - replyMarkup -) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithAnimation( - to: Message, - animation: AnimationFile, - entities: TextSourcesList, - duration: Long? = null, - width: Int? = null, - height: Int? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, animation, entities, duration, width, height, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.reply( - to: Message, - animation: AnimationFile, - entities: TextSourcesList, - duration: Long? = null, - width: Int? = null, - height: Int? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, animation, entities, duration, width, height, disableNotification, allowSendingWithoutReply, replyMarkup) - - -@Deprecated( - "Replaced", - ReplaceWith("replyWithAnimation", "dev.inmo.tgbotapi.extensions.api.send.replyWithAnimation") -) -suspend inline fun TelegramBot.replyWithAnimation( - to: Message, - animation: InputFile, - thumb: InputFile? = null, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - width: Int? = null, - height: Int? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = replyWithAnimation( - to, - animation, - thumb, - text, - parseMode, - duration, - width, - height, - disableNotification, - allowSendingWithoutReply, - replyMarkup -) - -@Deprecated( - "Replaced", - ReplaceWith("replyWithAnimation", "dev.inmo.tgbotapi.extensions.api.send.replyWithAnimation") -) -suspend inline fun TelegramBot.replyWithAnimation( - to: Message, - animation: AnimationFile, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - width: Int? = null, - height: Int? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, animation, text, parseMode, duration, width, height, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.reply( - to: Message, - animation: AnimationFile, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - width: Int? = null, - height: Int? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, animation, text, parseMode, duration, width, height, disableNotification, allowSendingWithoutReply, replyMarkup) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt index e3846e02f4..b7cd0846b9 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt @@ -147,97 +147,3 @@ suspend inline fun TelegramBot.sendAudio( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendAudio(chat.id, audio, entities, title, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) - - -@Deprecated( - "Replaced", - ReplaceWith("replyWithAudio", "dev.inmo.tgbotapi.extensions.api.send.replyWithAudio") -) -suspend inline fun TelegramBot.replyWithAudio( - to: Message, - audio: InputFile, - thumb: InputFile? = null, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - performer: String? = null, - title: String? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = replyWithAudio(to, audio, thumb, text, parseMode, duration, performer, title, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithAudio( - to: Message, - audio: AudioFile, - text: String? = null, - parseMode: ParseMode? = null, - title: String? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, audio, text, parseMode, title, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.reply( - to: Message, - audio: AudioFile, - text: String? = null, - parseMode: ParseMode? = null, - title: String? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, audio, text, parseMode, title, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("replyWithAudio", "dev.inmo.tgbotapi.extensions.api.send.replyWithAudio") -) -suspend inline fun TelegramBot.replyWithAudio( - to: Message, - audio: InputFile, - thumb: InputFile? = null, - entities: TextSourcesList, - duration: Long? = null, - performer: String? = null, - title: String? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = replyWithAudio(to, audio, thumb, entities, duration, performer, title, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithAudio( - to: Message, - audio: AudioFile, - entities: TextSourcesList, - title: String? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, audio, entities, title, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.repl") -) -suspend inline fun TelegramBot.reply( - to: Message, - audio: AudioFile, - entities: TextSourcesList, - title: String? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, audio, entities, title, disableNotification, allowSendingWithoutReply, replyMarkup) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt index bd3ce148e5..2766ee1d49 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt @@ -138,93 +138,3 @@ suspend inline fun TelegramBot.sendDocument( replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null ) = sendDocument(chat.id, document, entities, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) - - -@Deprecated( - "Replaced", - ReplaceWith("replyWithDocument", "dev.inmo.tgbotapi.extensions.api.send.replyWithDocument") -) -suspend inline fun TelegramBot.replyWithDocument( - to: Message, - document: InputFile, - thumb: InputFile? = null, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null, - disableContentTypeDetection: Boolean? = null -) = replyWithDocument(to, document, thumb, text, parseMode, disableNotification, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithDocument( - to: Message, - document: DocumentFile, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null, - disableContentTypeDetection: Boolean? = null -) = reply(to, document, text, parseMode, disableNotification, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.reply( - to: Message, - document: DocumentFile, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null, - disableContentTypeDetection: Boolean? = null -) = reply(to, document, text, parseMode, disableNotification, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) - -@Deprecated( - "Replaced", - ReplaceWith("replyWithDocument", "dev.inmo.tgbotapi.extensions.api.send.replyWithDocument") -) -suspend inline fun TelegramBot.replyWithDocument( - to: Message, - document: InputFile, - thumb: InputFile? = null, - entities: TextSourcesList, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null, - disableContentTypeDetection: Boolean? = null -) = replyWithDocument(to, document, thumb, entities, disableNotification, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithDocument( - to: Message, - document: DocumentFile, - entities: TextSourcesList, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null, - disableContentTypeDetection: Boolean? = null -) = reply(to, document, entities, disableNotification, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.reply( - to: Message, - document: DocumentFile, - entities: TextSourcesList, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null, - disableContentTypeDetection: Boolean? = null -) = reply(to, document, entities, disableNotification, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt index 7bc3706479..7a14aaf82e 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt @@ -127,60 +127,3 @@ suspend fun TelegramBot.sendVisualMediaGroup( ) = sendVisualMediaGroup( chat.id, media, disableNotification, replyToMessageId, allowSendingWithoutReply ) - - -@Deprecated( - "Replaced", - ReplaceWith("replyWithMediaGroup", "dev.inmo.tgbotapi.extensions.api.send.replyWithMediaGroup") -) -@RiskFeature(rawSendingMediaGroupsWarning) -suspend inline fun TelegramBot.replyWithMediaGroup( - to: Message, - media: List, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null -) = replyWithMediaGroup(to, media, disableNotification, allowSendingWithoutReply) - -@Deprecated( - "Replaced", - ReplaceWith("replyWithPlaylist", "dev.inmo.tgbotapi.extensions.api.send.replyWithPlaylist") -) -suspend inline fun TelegramBot.replyWithPlaylist( - to: Message, - media: List, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null -) = replyWithPlaylist(to, media, disableNotification, allowSendingWithoutReply) - -@Deprecated( - "Replaced", - ReplaceWith("replyWithDocuments", "dev.inmo.tgbotapi.extensions.api.send.replyWithDocuments") -) -suspend inline fun TelegramBot.replyWithDocumentsGroup( - to: Message, - media: List, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null -) = replyWithDocuments(to, media, disableNotification, allowSendingWithoutReply) - -@Deprecated( - "Replaced", - ReplaceWith("replyWithGallery", "dev.inmo.tgbotapi.extensions.api.send.replyWithGallery") -) -suspend inline fun TelegramBot.replyWithVisualMediaGroup( - to: Message, - media: List, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null -) = replyWithGallery(to, media, disableNotification, allowSendingWithoutReply) - -@Deprecated( - "Replaced", - ReplaceWith("replyWithMediaGroup", "dev.inmo.tgbotapi.extensions.api.send.replyWithMediaGroup") -) -suspend inline fun TelegramBot.reply( - to: Message, - media: List, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null -) = replyWithMediaGroup(to, media, disableNotification, allowSendingWithoutReply) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt index 6b562f5c0e..1decf11793 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt @@ -120,86 +120,3 @@ suspend inline fun TelegramBot.sendPhoto( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendPhoto(chat.id, photo, entities, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) - - -@Deprecated( - "Replaced", - ReplaceWith("replyWithPhoto", "dev.inmo.tgbotapi.extensions.api.send.replyWithPhoto") -) -suspend inline fun TelegramBot.replyWithPhoto( - to: Message, - fileId: InputFile, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = replyWithPhoto(to, fileId, text, parseMode, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithPhoto( - to: Message, - photo: Photo, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, photo, text, parseMode, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.reply( - to: Message, - photo: Photo, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, photo, text, parseMode, disableNotification, allowSendingWithoutReply, replyMarkup) - - -@Deprecated( - "Replaced", - ReplaceWith("replyWithPhoto", "dev.inmo.tgbotapi.extensions.api.send.replyWithPhoto") -) -suspend inline fun TelegramBot.replyWithPhoto( - to: Message, - fileId: InputFile, - entities: TextSourcesList, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = replyWithPhoto(to, fileId, entities, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithPhoto( - to: Message, - photo: Photo, - entities: TextSourcesList, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, photo, entities, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.reply( - to: Message, - photo: Photo, - entities: TextSourcesList, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, photo, entities, disableNotification, allowSendingWithoutReply, replyMarkup) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt index 08b00f0704..03d489b6bf 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt @@ -49,40 +49,3 @@ suspend fun TelegramBot.sendSticker( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendSticker(chat, sticker.fileId, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) - - -@Deprecated( - "Replaced", - ReplaceWith("replyWithSticker", "dev.inmo.tgbotapi.extensions.api.send.replyWithSticker") -) -suspend inline fun TelegramBot.replyWithSticker( - to: Message, - sticker: InputFile, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = replyWithSticker(to, sticker, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithSticker( - to: Message, - sticker: Sticker, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, sticker, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.reply( - to: Message, - sticker: Sticker, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, sticker, disableNotification, allowSendingWithoutReply, replyMarkup) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt index b4b29b3292..6cc62cb512 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt @@ -146,93 +146,3 @@ suspend inline fun TelegramBot.sendVideo( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVideo(chat.id, video, entities, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) - - -@Deprecated( - "Replaced", - ReplaceWith("replyWithVideo", "dev.inmo.tgbotapi.extensions.api.send.replyWithVideo") -) -suspend inline fun TelegramBot.replyWithVideo( - to: Message, - video: InputFile, - thumb: InputFile? = null, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - width: Int? = null, - height: Int? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = replyWithVideo(to, video, thumb, text, parseMode, duration, width, height, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithVideo( - to: Message, - video: VideoFile, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, video, text, parseMode, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.reply( - to: Message, - video: VideoFile, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, video, text, parseMode, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("replyWithVideo", "dev.inmo.tgbotapi.extensions.api.send.replyWithVideo") -) -suspend inline fun TelegramBot.replyWithVideo( - to: Message, - video: InputFile, - thumb: InputFile? = null, - entities: TextSourcesList, - duration: Long? = null, - width: Int? = null, - height: Int? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = replyWithVideo(to, video, thumb, entities, duration, width, height, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithVideo( - to: Message, - video: VideoFile, - entities: TextSourcesList, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, video, entities, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.reply( - to: Message, - video: VideoFile, - entities: TextSourcesList, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, video, entities, disableNotification, allowSendingWithoutReply, replyMarkup) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt index 211d8b3427..bc54f04403 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt @@ -1,8 +1,6 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.send.reply -import dev.inmo.tgbotapi.extensions.api.send.replyWithVideoNote import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendVideoNote import dev.inmo.tgbotapi.types.ChatIdentifier @@ -10,7 +8,6 @@ import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.files.VideoNoteFile -import dev.inmo.tgbotapi.types.message.abstracts.Message suspend fun TelegramBot.sendVideoNote( chatId: ChatIdentifier, @@ -67,43 +64,3 @@ suspend fun TelegramBot.sendVideoNote( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVideoNote(chat.id, videoNote, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) - - -@Deprecated( - "Replaced", - ReplaceWith("replyWithVideoNote", "dev.inmo.tgbotapi.extensions.api.send.replyWithVideoNote") -) -suspend inline fun TelegramBot.replyWithVideoNote( - to: Message, - videoNote: InputFile, - thumb: InputFile? = null, - duration: Long? = null, - size: Int? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = replyWithVideoNote(to, videoNote, thumb, duration, size, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithVideoNote( - to: Message, - videoNote: VideoNoteFile, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, videoNote, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.reply( - to: Message, - videoNote: VideoNoteFile, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, videoNote, disableNotification, allowSendingWithoutReply, replyMarkup) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt index 697c2d181c..3474250cfc 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt @@ -129,88 +129,3 @@ suspend inline fun TelegramBot.sendVoice( allowSendingWithoutReply: Boolean? = null, replyMarkup: KeyboardMarkup? = null ) = sendVoice(chat.id, voice, entities, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) - - -@Deprecated( - "Replaced", - ReplaceWith("replyWithVoice", "dev.inmo.tgbotapi.extensions.api.send.replyWithVoice") -) -suspend inline fun TelegramBot.replyWithVoice( - to: Message, - voice: InputFile, - text: String? = null, - parseMode: ParseMode? = null, - duration: Long? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = replyWithVoice(to, voice, text, parseMode, duration, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithVoice( - to: Message, - voice: VoiceFile, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, voice, text, parseMode, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.reply( - to: Message, - voice: VoiceFile, - text: String? = null, - parseMode: ParseMode? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, voice, text, parseMode, disableNotification, allowSendingWithoutReply, replyMarkup) - - -@Deprecated( - "Replaced", - ReplaceWith("replyWithVoice", "dev.inmo.tgbotapi.extensions.api.send.replyWithVoice") -) -suspend inline fun TelegramBot.replyWithVoice( - to: Message, - voice: InputFile, - entities: TextSourcesList, - duration: Long? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = replyWithVoice(to, voice, entities, duration, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithVoice( - to: Message, - voice: VoiceFile, - entities: TextSourcesList, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, voice, entities, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.reply( - to: Message, - voice: VoiceFile, - entities: TextSourcesList, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, voice, entities, disableNotification, allowSendingWithoutReply, replyMarkup) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt index 9aaabef97d..5489f27b17 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt @@ -60,32 +60,3 @@ suspend fun TelegramBot.sendInvoice( allowSendingWithoutReply: Boolean? = null, replyMarkup: InlineKeyboardMarkup? = null ) = sendInvoice(user.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) - - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithInvoice( - to: Message, - title: String, - description: String, - payload: String, - providerToken: String, - currency: Currency, - prices: List, - maxTipAmount: Int? = null, - suggestedTipAmounts: List? = null, - startParameter: StartParameter? = null, - providerData: String? = null, - requireName: Boolean = false, - requirePhoneNumber: Boolean = false, - requireEmail: Boolean = false, - requireShippingAddress: Boolean = false, - shouldSendPhoneNumberToProvider: Boolean = false, - shouldSendEmailToProvider: Boolean = false, - priceDependOnShipAddress: Boolean = false, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: InlineKeyboardMarkup? = null -) = reply(to, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, allowSendingWithoutReply, replyMarkup) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt index 96db4a23d0..c6df9d1ca1 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt @@ -227,114 +227,3 @@ suspend inline fun TelegramBot.sendQuizPoll( ) = sendQuizPoll( chat.id, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup ) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithRegularPoll( - to: Message, - question: String, - options: List, - isAnonymous: Boolean = true, - isClosed: Boolean = false, - allowMultipleAnswers: Boolean = false, - closeInfo: ScheduledCloseInfo? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithRegularPoll( - to: Message, - poll: RegularPoll, - isClosed: Boolean = false, - question: String = poll.question, - options: List = poll.options.map { it.text }, - isAnonymous: Boolean = poll.isAnonymous, - allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, - closeInfo: ScheduledCloseInfo? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithQuizPoll( - to: Message, - question: String, - options: List, - correctOptionId: Int, - isAnonymous: Boolean = true, - isClosed: Boolean = false, - explanation: String? = null, - parseMode: ParseMode? = null, - closeInfo: ScheduledCloseInfo? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithQuizPoll( - to: Message, - isClosed: Boolean = false, - quizPoll: QuizPoll, - question: String = quizPoll.question, - options: List = quizPoll.options.map { it.text }, - correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"), - isAnonymous: Boolean = quizPoll.isAnonymous, - explanation: String? = null, - parseMode: ParseMode? = null, - closeInfo: ScheduledCloseInfo? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, quizPoll, isClosed, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, disableNotification, allowSendingWithoutReply, replyMarkup) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithQuizPoll( - to: Message, - question: String, - options: List, - correctOptionId: Int, - isAnonymous: Boolean = true, - isClosed: Boolean = false, - entities: TextSourcesList, - closeInfo: ScheduledCloseInfo? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, question, options, correctOptionId, isAnonymous, isClosed) - -@Deprecated( - "Replaced", - ReplaceWith("reply", "dev.inmo.tgbotapi.extensions.api.send.reply") -) -suspend inline fun TelegramBot.replyWithQuizPoll( - to: Message, - isClosed: Boolean = false, - quizPoll: QuizPoll, - question: String = quizPoll.question, - options: List = quizPoll.options.map { it.text }, - correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"), - isAnonymous: Boolean = quizPoll.isAnonymous, - entities: TextSourcesList, - closeInfo: ScheduledCloseInfo? = null, - disableNotification: Boolean = false, - allowSendingWithoutReply: Boolean? = null, - replyMarkup: KeyboardMarkup? = null -) = reply(to, quizPoll, entities, isClosed, question, options, correctOptionId, isAnonymous, closeInfo, disableNotification, allowSendingWithoutReply, replyMarkup) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt index 6ec5c5a862..00e0a527d4 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt @@ -16,36 +16,6 @@ import kotlinx.coroutines.plus */ expect var defaultCoroutineScopeProvider: () -> CoroutineScope -/** - * Use this method in case you wish to make some additional actions with [flowUpdatesFilter]. - * - * **WARNING** This method WILL NOT launch any listening of updates. Use something like - * [startGettingOfUpdatesByLongPolling] or tools for work with webhooks - * - * @see [BehaviourContext] - * @see startGettingOfUpdatesByLongPolling - */ -@PreviewFeature -@Deprecated("Parameters has been reordered. Replace scope and flowUpdatesFilter for correct order") -suspend fun TelegramBot.buildBehaviour( - scope: CoroutineScope, - flowUpdatesFilter: FlowsUpdatesFilter, - defaultExceptionsHandler: ExceptionHandler? = null, - block: BehaviourContextReceiver -) { - BehaviourContext( - this, - scope.let { - if (defaultExceptionsHandler == null) { - it - } else { - it + ContextSafelyExceptionHandler(defaultExceptionsHandler) - } - }, - flowUpdatesFilter - ).block() -} - /** * Use this method in case you wish to make some additional actions with [flowUpdatesFilter]. * @@ -90,8 +60,8 @@ suspend fun TelegramBot.buildBehaviour( block: BehaviourContextReceiver ) = FlowsUpdatesFilter().let { buildBehaviour( - scope, it, + scope, defaultExceptionsHandler, block ) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt index 4de838699d..dd972014fd 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt @@ -20,115 +20,6 @@ internal suspend inline fun BehaviourContext.onCallb (it.asCallbackQueryUpdate() ?.data as? T) ?.let(::listOfNotNull) } -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onDataCallbackQuery( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter? = null, - markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onCallbackQuery( - additionalFilter, - if (includeFilterByChatInBehaviourSubContext) CallbackQueryFilterByUser else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onGameShortNameCallbackQuery( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter? = null, - markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onCallbackQuery( - additionalFilter, - if (includeFilterByChatInBehaviourSubContext) CallbackQueryFilterByUser else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onInlineMessageIdCallbackQuery( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter? = null, - markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onCallbackQuery( - additionalFilter, - if (includeFilterByChatInBehaviourSubContext) CallbackQueryFilterByUser else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onInlineMessageIdDataCallbackQuery( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter? = null, - markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onCallbackQuery( - additionalFilter, - if (includeFilterByChatInBehaviourSubContext) CallbackQueryFilterByUser else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onInlineMessageIdGameShortNameCallbackQuery( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter? = null, - markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onCallbackQuery( - additionalFilter, - if (includeFilterByChatInBehaviourSubContext) CallbackQueryFilterByUser else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onMessageCallbackQuery( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter? = null, - markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onCallbackQuery( - additionalFilter, - if (includeFilterByChatInBehaviourSubContext) CallbackQueryFilterByUser else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onMessageDataCallbackQuery( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter? = null, - markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onCallbackQuery( - additionalFilter, - if (includeFilterByChatInBehaviourSubContext) CallbackQueryFilterByUser else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onMessageGameShortNameCallbackQuery( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter? = null, - markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onCallbackQuery( - additionalFilter, - if (includeFilterByChatInBehaviourSubContext) CallbackQueryFilterByUser else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onUnknownCallbackQueryType( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter? = null, - markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onCallbackQuery( - additionalFilter, - if (includeFilterByChatInBehaviourSubContext) CallbackQueryFilterByUser else null, - 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, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMemberUpdatedTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMemberUpdatedTriggers.kt index f6dfb202fe..f39006f3a2 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMemberUpdatedTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMemberUpdatedTriggers.kt @@ -22,45 +22,6 @@ internal suspend inline fun BehaviourConte ((it as? U) ?.data) ?.let(::listOfNotNull) } -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onChatMemberUpdated( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter? = null, - markerFactory: MarkerFactory = ByChatChatMemberUpdatedMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onChatMemberUpdatedInternal( - additionalFilter, - if (includeFilterByChatInBehaviourSubContext) ChatMemberUpdatedFilterByChat else null, - markerFactory, - scenarioReceiver -) - -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onCommonChatMemberUpdated( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter? = null, - markerFactory: MarkerFactory = ByChatChatMemberUpdatedMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onChatMemberUpdatedInternal( - additionalFilter, - if (includeFilterByChatInBehaviourSubContext) ChatMemberUpdatedFilterByChat else null, - markerFactory, - scenarioReceiver -) - -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onMyChatMemberUpdated( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter? = null, - markerFactory: MarkerFactory = ByChatChatMemberUpdatedMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onChatMemberUpdatedInternal( - additionalFilter, - if (includeFilterByChatInBehaviourSubContext) ChatMemberUpdatedFilterByChat else null, - markerFactory, - scenarioReceiver -) - /** * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt index 6fc9e8317a..5273249781 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt @@ -15,118 +15,6 @@ import dev.inmo.tgbotapi.types.message.content.TextContent import dev.inmo.tgbotapi.types.update.abstracts.Update import kotlinx.coroutines.Job -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.command( - commandRegex: Regex, - requireOnlyCommandInMessage: Boolean = true, - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -): Job = onText( - includeFilterByChatInBehaviourSubContext, - CommonMessageFilter { message -> - val content = message.content - val textSources = content.textSources - val sizeRequirement = if (requireOnlyCommandInMessage) { - textSources.size == 1 - } else { - true - } - sizeRequirement && textSources.any { - commandRegex.matches(it.asBotCommandTextSource() ?.command ?: return@any false) - } && (additionalFilter ?.invoke(message) != false) - }.let { - additionalFilter ?.times(it) ?: it - }, - markerFactory, - scenarioReceiver -) - -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.command( - command: String, - requireOnlyCommandInMessage: Boolean = true, - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = command(command.toRegex(), requireOnlyCommandInMessage, includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver) - -@Deprecated(OldAPITriggersDeprecationText) -suspend inline fun BehaviourContext.onCommand( - commandRegex: Regex, - requireOnlyCommandInMessage: Boolean = true, - includeFilterByChatInBehaviourSubContext: Boolean, - noinline additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTypeReceiver> -): Job = command(commandRegex, requireOnlyCommandInMessage, includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver) - -@Deprecated(OldAPITriggersDeprecationText) -suspend inline fun BehaviourContext.onCommand( - command: String, - requireOnlyCommandInMessage: Boolean = true, - includeFilterByChatInBehaviourSubContext: Boolean, - noinline additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTypeReceiver> -): Job = onCommand(command.toRegex(), requireOnlyCommandInMessage, includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver) - -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.commandWithArgs( - commandRegex: Regex, - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTwoTypesReceiver, Array> -) = command( - commandRegex, - requireOnlyCommandInMessage = false, - includeFilterByChatInBehaviourSubContext = includeFilterByChatInBehaviourSubContext, - additionalFilter = additionalFilter, - markerFactory = markerFactory -) { - val args = it.parseCommandsWithParams().let { commandsWithArgs -> - val key = commandsWithArgs.keys.firstOrNull { it.matches(commandRegex) } ?: return@let null - commandsWithArgs[key] - } ?: emptyArray() - scenarioReceiver(it, args) -} - -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.commandWithArgs( - command: String, - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTwoTypesReceiver, Array> -) = commandWithArgs( - command.toRegex(), - includeFilterByChatInBehaviourSubContext = includeFilterByChatInBehaviourSubContext, - additionalFilter = additionalFilter, - markerFactory = markerFactory, - scenarioReceiver = scenarioReceiver -) - -@Deprecated(OldAPITriggersDeprecationText) -suspend inline fun BehaviourContext.onCommandWithArgs( - commandRegex: Regex, - includeFilterByChatInBehaviourSubContext: Boolean, - noinline additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTwoTypesReceiver, Array> -): Job = commandWithArgs(commandRegex, includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver) - -@Deprecated(OldAPITriggersDeprecationText) -suspend inline fun BehaviourContext.onCommandWithArgs( - command: String, - includeFilterByChatInBehaviourSubContext: Boolean, - noinline additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTwoTypesReceiver, Array> -): Job = onCommandWithArgs(command.toRegex(), includeFilterByChatInBehaviourSubContext, additionalFilter, markerFactory, scenarioReceiver) - suspend fun BehaviourContext.command( commandRegex: Regex, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt index 246eaccdc6..028a97d102 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt @@ -37,267 +37,6 @@ internal suspend inline fun BehaviourContext.onCont } } -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onContentMessage( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: CommonMessageFilter? = null, - includeMediaGroups: Boolean = true, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: if (includeMediaGroups) null else CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onContact( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onDice( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onGame( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onLocation( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onPoll( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onText( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onVenue( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onAudioMediaGroup( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onDocumentMediaGroupContent( - includeFilterByChatInBehaviourSubContext: Boolean, - includeMediaGroups: Boolean = true, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: if (includeMediaGroups) null else CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onMediaCollection( - includeFilterByChatInBehaviourSubContext: Boolean, - includeMediaGroups: Boolean = false, - additionalFilter: SimpleFilter>>? = null, - markerFactory: MarkerFactory>, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver>> -) = onContent( - additionalFilter ?: if (includeMediaGroups) null else CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onMedia( - includeFilterByChatInBehaviourSubContext: Boolean, - includeMediaGroups: Boolean = true, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: if (includeMediaGroups) null else CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onAnimation( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onAudio( - includeFilterByChatInBehaviourSubContext: Boolean, - includeMediaGroups: Boolean = false, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: if (includeMediaGroups) null else CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onDocument( - includeFilterByChatInBehaviourSubContext: Boolean, - includeMediaGroups: Boolean = false, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: if (includeMediaGroups) null else CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onPhoto( - includeFilterByChatInBehaviourSubContext: Boolean, - includeMediaGroups: Boolean = false, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: if (includeMediaGroups) null else CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onSticker( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onVideo( - includeFilterByChatInBehaviourSubContext: Boolean, - includeMediaGroups: Boolean = false, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: if (includeMediaGroups) null else CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onVideoNote( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onVoice( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onInvoice( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: CommonMessageFilter? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onContent( - additionalFilter ?: CommonMessageFilterExcludeMediaGroups, - if (includeFilterByChatInBehaviourSubContext) { MessageFilterByChat } else null, - markerFactory, - scenarioReceiver -) - /** * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt index b8fd04acc3..52876f5374 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt @@ -24,150 +24,6 @@ internal suspend inline fun BehaviourContext.onEvent( (it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.takeIf { it.chatEvent is T } as? ChatEventMessage) ?.let(::listOfNotNull) } -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onChannelEvent( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onChatEvent( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onVoiceChatEvent( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onVoiceChatStartedEvent( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onVoiceChatEndedEvent( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onVoiceChatParticipantsInvitedEvent( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onMessageAutoDeleteTimerChangedEvent( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onCommonEvent( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onGroupEvent( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onSupergroupEvent( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) - -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onChannelChatCreated( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onDeleteChatPhoto( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onGroupChatCreated( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onLeftChatMember( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onNewChatMembers( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onNewChatPhoto( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onNewChatTitle( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onPinnedMessage( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onProximityAlertTriggered( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onSupergroupChatCreated( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>? = null, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = onEvent(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, 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, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt index 52567eab55..be677995c9 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt @@ -18,33 +18,6 @@ internal suspend inline fun BehaviourContext.onInlineQ (it.asInlineQueryUpdate() ?.data as? T) ?.let(::listOfNotNull) } - -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onAnyInlineQuery( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter? = null, - markerFactory: MarkerFactory = ByUserInlineQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onInlineQuery(additionalFilter, if (includeFilterByChatInBehaviourSubContext) InlineQueryFilterByUser else null, markerFactory, scenarioReceiver) - -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onBaseInlineQuery( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter? = null, - markerFactory: MarkerFactory = ByUserInlineQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onInlineQuery(additionalFilter, if (includeFilterByChatInBehaviourSubContext) InlineQueryFilterByUser else null, markerFactory, scenarioReceiver) - -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onLocationInlineQuery( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter? = null, - markerFactory: MarkerFactory = ByUserInlineQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onInlineQuery(additionalFilter, if (includeFilterByChatInBehaviourSubContext) InlineQueryFilterByUser else null, 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, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt index f402d97c0a..7ba44da28f 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt @@ -25,58 +25,6 @@ internal suspend inline fun BehaviourContext.bui (it.asSentMediaGroupUpdate() ?.data ?.takeIf { it.all { it is T } } as? List>) ?.let(::listOfNotNull) } -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onMediaGroup( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>>? = null, - markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver>> -) = buildMediaGroupTrigger(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessagesFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onPlaylist( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>>? = null, - markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver>> -) = buildMediaGroupTrigger(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessagesFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onDocumentsGroup( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>>? = null, - markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver>> -) = buildMediaGroupTrigger(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessagesFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onVisualGallery( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>>? = null, - markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver>> -) = buildMediaGroupTrigger(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessagesFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onVisualMediaGroup( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>>? = null, - markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver>> -) = onVisualGallery(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessagesFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onPhotoGallery( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>>? = null, - markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver>> -) = buildMediaGroupTrigger(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessagesFilterByChat else null, markerFactory, scenarioReceiver) -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onVideoGallery( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter>>? = null, - markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver>> -) = buildMediaGroupTrigger(additionalFilter, if (includeFilterByChatInBehaviourSubContext) MessagesFilterByChat else null, 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, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PassportTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PassportTriggers.kt index 31de2cd1ba..84f1c177ec 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PassportTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PassportTriggers.kt @@ -20,19 +20,6 @@ internal suspend inline fun BehaviourCont (it.asMessageUpdate() ?.data ?.asPassportMessage() ?.takeIf { it.passportData.data.any { it is T } }) ?.let(::listOfNotNull) } -@Deprecated(OldAPITriggersDeprecationText) -suspend fun BehaviourContext.onPassportMessage( - includeFilterByChatInBehaviourSubContext: Boolean, - additionalFilter: SimpleFilter? = null, - markerFactory: MarkerFactory = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onPassportMessageWith( - additionalFilter, - if (includeFilterByChatInBehaviourSubContext) MessageFilterByChat else null, - markerFactory, - scenarioReceiver -) - /** * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/FlowsUpdatesFilter.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/FlowsUpdatesFilter.kt index 168c4ca798..202785be46 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/FlowsUpdatesFilter.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/FlowsUpdatesFilter.kt @@ -5,17 +5,3 @@ import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.merge - -@Deprecated("Will be removed soon", ReplaceWith("messagesFlow + channelPostsFlow")) -val FlowsUpdatesFilter.allSentMessagesFlow: Flow - get() = merge( - messagesFlow, - channelPostsFlow - ) - -@Deprecated("Will be removed soon", ReplaceWith("messageMediaGroupsFlow + channelPostMediaGroupsFlow")) -val FlowsUpdatesFilter.allSentMediaGroupsFlow: Flow - get() = merge( - messageMediaGroupsFlow, - channelPostMediaGroupsFlow - ) diff --git a/tgbotapi.extensions.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt b/tgbotapi.extensions.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt index e0cfe38006..cffc04184f 100644 --- a/tgbotapi.extensions.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt +++ b/tgbotapi.extensions.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt @@ -2,29 +2,8 @@ package dev.inmo.tgbotapi.types.files import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper import java.io.* -import java.io.File import java.net.URL fun PathedFile.asStream( - telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper + telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper ): InputStream = URL(this.fullUrl(telegramAPIUrlsKeeper)).openStream() - -@Deprecated("This api will be removed soon. Use `downloadFile` instead") -fun PathedFile.asFile( - telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper, - dest: File = File.createTempFile(this.fileUniqueId, this.filename), - defaultBufferSize: Int = DEFAULT_BUFFER_SIZE -): File { - this.asStream(telegramAPIUrlsKeeper).use { input -> - FileOutputStream(dest).use { out -> - input.copyTo(out, defaultBufferSize) - } - } - return dest -} - -@Deprecated("This api will be removed soon. Use `downloadFile` instead") -fun PathedFile.asBytes( - telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper -): ByteArray = this.asStream(telegramAPIUrlsKeeper) - .use { input -> input.readBytes() } From 7f9faa69c8cf9c1d2b85b2eab53617ebd7b66911 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 1 Oct 2021 19:38:22 +0600 Subject: [PATCH 04/40] new dsls for keyboards #472 --- .../types/CallbackQuery/DataCallbackQuery.kt | 5 + .../InlineKeyboardButton.kt | 59 +++++++- .../tgbotapi/types/buttons/KeyboardButton.kt | 33 +++++ .../types/buttons/KeyboardButtonPollType.kt | 20 +++ .../kotlin/dev/inmo/tgbotapi/utils/Matrix.kt | 7 +- .../tgbotapi/extensions/api/DownloadFile.kt | 6 - .../extensions/api/LiveLocationProvider.kt | 28 ++++ .../inmo/tgbotapi/extensions/api/StopPoll.kt | 16 +++ .../EditChatMessageLiveLocation.kt | 24 ++++ .../StopChatMessageLiveLocation.kt | 12 ++ .../StopInlineMessageLiveLocation.kt | 4 + .../ReplyMarkup/EditChatMessageReplyMarkup.kt | 12 ++ .../EditInlineMessageReplyMarkup.kt | 4 + .../edit/caption/EditChatMessageCaption.kt | 24 ++++ .../edit/caption/EditInlineMessageCaption.kt | 8 ++ .../api/edit/media/EditChatMessageMedia.kt | 12 ++ .../api/edit/media/EditInlineMessageMedia.kt | 4 + .../api/edit/text/EditChatMessageText.kt | 24 ++++ .../api/edit/text/EditInlineMessageText.kt | 8 ++ .../api/files/DownloadFileStream.kt | 1 - .../extensions/api/send/CopyMessage.kt | 48 +++++++ .../tgbotapi/extensions/api/send/Replies.kt | 40 ++++++ .../extensions/api/send/SendActionDSL.kt | 3 +- .../extensions/api/send/SendContact.kt | 16 +++ .../tgbotapi/extensions/api/send/SendDice.kt | 8 ++ .../extensions/api/send/SendLocation.kt | 32 +++++ .../extensions/api/send/SendMessage.kt | 32 +++++ .../tgbotapi/extensions/api/send/SendVenue.kt | 24 ++++ .../extensions/api/send/games/SendGame.kt | 19 ++- .../api/send/media/SendAnimation.kt | 35 ++++- .../extensions/api/send/media/SendAudio.kt | 35 ++++- .../extensions/api/send/media/SendDocument.kt | 35 ++++- .../api/send/media/SendMediaGroup.kt | 5 - .../extensions/api/send/media/SendPhoto.kt | 35 ++++- .../extensions/api/send/media/SendSticker.kt | 19 ++- .../extensions/api/send/media/SendVideo.kt | 35 ++++- .../api/send/media/SendVideoNote.kt | 16 +++ .../extensions/api/send/media/SendVoice.kt | 37 ++++- .../api/send/payments/SendInvoice.kt | 10 +- .../extensions/api/send/polls/SendPoll.kt | 50 ++++++- .../types/buttons/InlineKeyboardBuilder.kt | 130 ++++++++++++++++++ .../types/buttons/ReplyKeyboardBuilder.kt | 102 ++++++++++++++ 42 files changed, 1028 insertions(+), 49 deletions(-) create mode 100644 tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt create mode 100644 tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/DataCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/DataCallbackQuery.kt index 47bb6000b6..9858b3a996 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/DataCallbackQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/DataCallbackQuery.kt @@ -1,5 +1,10 @@ package dev.inmo.tgbotapi.types.CallbackQuery +/** + * [CallbackQuery] with [data] field + * + * @see dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton + */ sealed interface DataCallbackQuery : CallbackQuery { val data: String } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt index 19f79faf4d..e2693ae023 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/InlineKeyboardButtons/InlineKeyboardButton.kt @@ -2,10 +2,13 @@ package dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.games.CallbackGame -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import kotlinx.serialization.* import kotlinx.serialization.json.JsonElement +/** + * Some button of [dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup]. See inheritors and visit + * https://core.telegram.org/bots/api#inlinekeyboardbutton for more info + */ @Serializable(InlineKeyboardButtonSerializer::class) sealed interface InlineKeyboardButton { val text: String @@ -17,30 +20,56 @@ data class UnknownInlineKeyboardButton internal constructor( val rawData: JsonElement ) : InlineKeyboardButton +/** + * This type of button must always be the first button in the first row. Visit + * https://core.telegram.org/bots/api#payments for mor info + */ @Serializable data class PayInlineKeyboardButton( override val text: String, + @Deprecated("Don't use this button due to removing of this in near release") + @Transient + val pay: Boolean = true +) : InlineKeyboardButton { + @ExperimentalSerializationApi + @EncodeDefault @SerialName(payField) - val pay: Boolean -) : InlineKeyboardButton + private val toPay = true +} +/** + * Simple button with [callbackData] which you are able to catch this type of updates and data using + * [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onDataCallbackQuery] in + * case you are using Behaviour Builder OR [dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter.callbackQueriesFlow] + * with [kotlinx.coroutines.flow.filterIsInstance] and filtering by type [dev.inmo.tgbotapi.types.CallbackQuery.DataCallbackQuery] + */ @Serializable data class CallbackDataInlineKeyboardButton( @SerialName(textField) override val text: String, + /** + * You will receive this data in [dev.inmo.tgbotapi.types.CallbackQuery.DataCallbackQuery.data] field + */ @SerialName(callbackDataField) val callbackData: String ) : InlineKeyboardButton +/** + * Button with [callbackGame] + */ @Serializable data class CallbackGameInlineKeyboardButton( @SerialName(textField) override val text: String ) : InlineKeyboardButton { @SerialName(callbackGameField) + @EncodeDefault private val callbackGame = CallbackGame } +/** + * You may use this button to automatically authorize your user on [loginUrl] + */ @Serializable data class LoginURLInlineKeyboardButton( override val text: String, @@ -48,6 +77,16 @@ data class LoginURLInlineKeyboardButton( val loginUrl: LoginURL ) : InlineKeyboardButton +/** + * Complex button with [switchInlineQueryCurrentChat] which will be sent to you in an [dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery] + * which you may catch in [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onBaseInlineQuery] and get + * from [dev.inmo.tgbotapi.types.InlineQueries.query.BaseInlineQuery.query] (or changed by user query in case he will be + * the fastest hand in the wild west). Can be forwarded in any chat with message in case if it is the only one button in + * message, but will be converted to a [SwitchInlineQueryInlineKeyboardButton]. + * Remember that clicking on this button will automatically insert username of this bot in current chat, paste + * [switchInlineQueryCurrentChat] as a query and create and inline request to your bot + * Visit https://core.telegram.org/bots/api#inlinekeyboardbutton for more info + */ @Serializable data class SwitchInlineQueryCurrentChatInlineKeyboardButton( override val text: String, @@ -55,6 +94,15 @@ data class SwitchInlineQueryCurrentChatInlineKeyboardButton( val switchInlineQueryCurrentChat: String ) : InlineKeyboardButton +/** + * Complex button with [switchInlineQuery] which will be sent to you in an [dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery] + * which you may catch in [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onBaseInlineQuery] and get + * from [dev.inmo.tgbotapi.types.InlineQueries.query.BaseInlineQuery.query] (or changed by user query in case he will be + * the fastest hand in the wild west). Can be forwarded in any chat with message in case if it is the only one button in message. + * Remember that clicking on this button will automatically insert username of this bot in the chosen by user chat, paste + * [switchInlineQuery] as a query and create and inline request to your bot. + * Visit https://core.telegram.org/bots/api#inlinekeyboardbutton for more info + */ @Serializable data class SwitchInlineQueryInlineKeyboardButton( override val text: String, @@ -62,6 +110,9 @@ data class SwitchInlineQueryInlineKeyboardButton( val switchInlineQuery: String ) : InlineKeyboardButton +/** + * Simple [url] button. Can be forwarded in any chat with message in case if it is the only one button in message + */ @Serializable data class URLInlineKeyboardButton( override val text: String, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt index 8993a1ab30..688dd3da03 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButton.kt @@ -9,11 +9,21 @@ import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.json.* +/** + * Representation union of https://core.telegram.org/bots/api#keyboardbutton . See inheritors for more info + */ @Serializable(KeyboardButtonSerializer::class) sealed interface KeyboardButton { val text: String } +/** + * Simple button. user will send text of this button. You will be able to catch this text in updates and data using + * [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onText] in + * case you are using Behaviour Builder OR with [dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter.messagesFlow] + * and [kotlinx.coroutines.flow.filterIsInstance] and filtering by type + * [dev.inmo.tgbotapi.types.message.abstracts.CommonMessage] and [dev.inmo.tgbotapi.extensions.utils.onlyTextContentMessages] +*/ @Serializable data class SimpleKeyboardButton( override val text: String @@ -25,22 +35,45 @@ data class UnknownKeyboardButton internal constructor( val raw: String ) : KeyboardButton +/** + * Private chats only. When user will tap on this button, his contact (with his number and name) will be sent to the bot. You will be able + * to catch this contact in updates and data using [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onContact] in + * case you are using Behaviour Builder OR with [dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter.messagesFlow] + * and [kotlinx.coroutines.flow.filterIsInstance] and filtering by type + * [dev.inmo.tgbotapi.types.message.abstracts.CommonMessage] and [dev.inmo.tgbotapi.extensions.utils.onlyContactContentMessages] +*/ @Serializable data class RequestContactKeyboardButton( override val text: String ) : KeyboardButton { @SerialName(requestContactField) + @EncodeDefault val requestContact: Boolean = true } +/** + * Private chats only. When user will tap on this button, his location will be sent to the bot. You will be able + * to catch this location in updates and data using [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onLocation] in + * case you are using Behaviour Builder OR with [dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter.messagesFlow] + * and [kotlinx.coroutines.flow.filterIsInstance] and filtering by type + * [dev.inmo.tgbotapi.types.message.abstracts.CommonMessage] and [dev.inmo.tgbotapi.extensions.utils.onlyLocationContentMessages] + */ @Serializable data class RequestLocationKeyboardButton( override val text: String ) : KeyboardButton { @SerialName(requestLocationField) + @EncodeDefault val requestLocation: Boolean = true } +/** + * Private chats only. When user will tap on this button, he will be asked for the poll with [requestPoll] options. You will be able + * to catch this poll in updates and data using [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onPoll] in + * case you are using Behaviour Builder OR with [dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter.messagesFlow] + * and [kotlinx.coroutines.flow.filterIsInstance] and filtering by type + * [dev.inmo.tgbotapi.types.message.abstracts.CommonMessage] and [dev.inmo.tgbotapi.extensions.utils.onlyPollContentMessages] + */ @Serializable data class RequestPollKeyboardButton( override val text: String, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButtonPollType.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButtonPollType.kt index e049a332a5..9bb09d2df6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButtonPollType.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/KeyboardButtonPollType.kt @@ -1,5 +1,6 @@ package dev.inmo.tgbotapi.types.buttons +import dev.inmo.micro_utils.common.Warning import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.KSerializer @@ -9,19 +10,38 @@ import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.json.* +/** + * Poll type for [RequestPollKeyboardButton]. Visit https://core.telegram.org/bots/api#keyboardbuttonpolltype for more + * info and see inheritors. + * + * @see KeyboardButtonPollTypeSerializer + */ @Serializable(KeyboardButtonPollTypeSerializer::class) sealed interface KeyboardButtonPollType { val type: String } @Serializable +@Warning("This type should be used only in cases you are sure that it is required") class UnknownKeyboardButtonPollType internal constructor(override val type: String): KeyboardButtonPollType +/** + * Just a regular poll type + * + * @see dev.inmo.tgbotapi.types.polls.RegularPoll + * @see RequestPollKeyboardButton + */ @Serializable object RegularKeyboardButtonPollType : KeyboardButtonPollType { override val type: String = regularPollType } +/** + * Quiz poll type + * + * @see dev.inmo.tgbotapi.types.polls.QuizPoll + * @see RequestPollKeyboardButton + */ @Serializable object QuizKeyboardButtonPollType : KeyboardButtonPollType { override val type: String = quizPollType diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Matrix.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Matrix.kt index 8bfe5717da..8187de14cc 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Matrix.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Matrix.kt @@ -32,7 +32,7 @@ fun flatMatrix(vararg elements: T): Matrix { operator fun RowBuilder.plus(t: T) = add(t) -class RowBuilder { +open class RowBuilder { private val mutRow: MutableList = ArrayList() val row: List get() = mutRow @@ -41,11 +41,12 @@ class RowBuilder { operator fun T.unaryPlus() = add(this) } -class MatrixBuilder { +open class MatrixBuilder { private val mutMatrix: MutableList> = ArrayList() val matrix: Matrix - get() = mutMatrix + get() = mutMatrix.toList() fun add(t: List) = mutMatrix.add(t) operator fun plus(t: List) = add(t) + operator fun T.unaryPlus() = add(listOf(this)) } diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DownloadFile.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DownloadFile.kt index c3ca7ab6e0..5d20323f3a 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DownloadFile.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DownloadFile.kt @@ -1,8 +1,2 @@ package dev.inmo.tgbotapi.extensions.api -import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.files.downloadFile -import dev.inmo.tgbotapi.requests.abstracts.FileId -import dev.inmo.tgbotapi.types.files.PathedFile -import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile -import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt index 659f38da0a..2a063c8e46 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt @@ -48,6 +48,10 @@ class LiveLocationProvider internal constructor( val lastLocation: LiveLocation get() = message.content.location as LiveLocation + /** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun updateLocation( location: LiveLocation, replyMarkup: InlineKeyboardMarkup? = null @@ -73,6 +77,10 @@ class LiveLocationProvider internal constructor( } } +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.startLiveLocation( scope: CoroutineScope, chatId: ChatIdentifier, @@ -112,6 +120,10 @@ suspend fun TelegramBot.startLiveLocation( ) } +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.startLiveLocation( scope: CoroutineScope, chat: Chat, @@ -140,6 +152,10 @@ suspend fun TelegramBot.startLiveLocation( replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.startLiveLocation( scope: CoroutineScope, chatId: ChatId, @@ -167,6 +183,10 @@ suspend fun TelegramBot.startLiveLocation( replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.startLiveLocation( scope: CoroutineScope, chat: Chat, @@ -194,6 +214,10 @@ suspend fun TelegramBot.startLiveLocation( replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.replyWithLiveLocation( to: Message, scope: CoroutineScope, @@ -221,6 +245,10 @@ suspend inline fun TelegramBot.replyWithLiveLocation( replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.replyWithLiveLocation( to: Message, scope: CoroutineScope, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/StopPoll.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/StopPoll.kt index 7c535c5233..c7e2106767 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/StopPoll.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/StopPoll.kt @@ -7,6 +7,10 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.message.abstracts.Message +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.stopPoll( chatId: ChatIdentifier, messageId: MessageIdentifier, @@ -15,18 +19,30 @@ suspend fun TelegramBot.stopPoll( StopPoll(chatId, messageId, replyMarkup) ) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.stopPoll( chat: Chat, messageId: MessageIdentifier, replyMarkup: InlineKeyboardMarkup? = null ) = stopPoll(chat.id, messageId, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.stopPoll( chatId: ChatId, message: Message, replyMarkup: InlineKeyboardMarkup? = null ) = stopPoll(chatId, message.messageId, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.stopPoll( chat: Chat, message: Message, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditChatMessageLiveLocation.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditChatMessageLiveLocation.kt index 2548f015a2..e1fd361138 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditChatMessageLiveLocation.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditChatMessageLiveLocation.kt @@ -9,6 +9,10 @@ import dev.inmo.tgbotapi.types.location.LiveLocation import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.LocationContent +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editLiveLocation( chatId: ChatIdentifier, messageId: MessageIdentifier, @@ -24,6 +28,10 @@ suspend fun TelegramBot.editLiveLocation( ) ) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editLiveLocation( chat: Chat, messageId: MessageIdentifier, @@ -35,6 +43,10 @@ suspend fun TelegramBot.editLiveLocation( replyMarkup: InlineKeyboardMarkup? = null ) = editLiveLocation(chat.id, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editLiveLocation( message: ContentMessage, latitude: Double, @@ -45,6 +57,10 @@ suspend fun TelegramBot.editLiveLocation( replyMarkup: InlineKeyboardMarkup? = null ) = editLiveLocation(message.chat, message.messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editLiveLocation( chatId: ChatIdentifier, messageId: MessageIdentifier, @@ -56,6 +72,10 @@ suspend fun TelegramBot.editLiveLocation( ) ) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editLiveLocation( chat: Chat, messageId: MessageIdentifier, @@ -63,6 +83,10 @@ suspend fun TelegramBot.editLiveLocation( replyMarkup: InlineKeyboardMarkup? = null ) = editLiveLocation(chat.id, messageId, location.latitude, location.longitude, location.horizontalAccuracy, location.heading, location.proximityAlertRadius, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editLiveLocation( message: ContentMessage, location: LiveLocation, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopChatMessageLiveLocation.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopChatMessageLiveLocation.kt index 5a8d2ead28..14865a4a4e 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopChatMessageLiveLocation.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopChatMessageLiveLocation.kt @@ -9,6 +9,10 @@ import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.LocationContent +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.stopLiveLocation( chatId: ChatIdentifier, messageId: MessageIdentifier, @@ -19,12 +23,20 @@ suspend fun TelegramBot.stopLiveLocation( ) ) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.stopLiveLocation( chat: Chat, messageId: MessageIdentifier, replyMarkup: InlineKeyboardMarkup? = null ) = stopLiveLocation(chat.id, messageId, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.stopLiveLocation( message: ContentMessage, replyMarkup: InlineKeyboardMarkup? = null diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopInlineMessageLiveLocation.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopInlineMessageLiveLocation.kt index cdba949683..14aa6c3934 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopInlineMessageLiveLocation.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopInlineMessageLiveLocation.kt @@ -5,6 +5,10 @@ import dev.inmo.tgbotapi.requests.edit.LiveLocation.StopInlineMessageLiveLocatio import dev.inmo.tgbotapi.types.InlineMessageIdentifier import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.stopLiveLocation( inlineMessageId: InlineMessageIdentifier, replyMarkup: InlineKeyboardMarkup? = null diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt index 3a8d089fa5..b65d15f8c1 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt @@ -8,6 +8,10 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.message.abstracts.Message +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageReplyMarkup( chatId: ChatIdentifier, messageId: MessageIdentifier, @@ -16,12 +20,20 @@ suspend fun TelegramBot.editMessageReplyMarkup( EditChatMessageReplyMarkup(chatId, messageId, replyMarkup) ) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageReplyMarkup( chat: Chat, messageId: MessageIdentifier, replyMarkup: InlineKeyboardMarkup? = null ) = editMessageReplyMarkup(chat.id, messageId, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageReplyMarkup( message: Message, replyMarkup: InlineKeyboardMarkup? = null diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt index 123c168522..f00c1133e3 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt @@ -5,6 +5,10 @@ import dev.inmo.tgbotapi.requests.edit.ReplyMarkup.EditInlineMessageReplyMarkup import dev.inmo.tgbotapi.types.InlineMessageIdentifier import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageReplyMarkup( inlineMessageId: InlineMessageIdentifier, replyMarkup: InlineKeyboardMarkup? = null diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt index 4ed6b395f0..09cf7b3839 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt @@ -13,6 +13,10 @@ import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageCaption( chatId: ChatIdentifier, messageId: MessageIdentifier, @@ -23,6 +27,10 @@ suspend fun TelegramBot.editMessageCaption( EditChatMessageCaption(chatId, messageId, text, parseMode, replyMarkup) ) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageCaption( chat: Chat, messageId: MessageIdentifier, @@ -31,6 +39,10 @@ suspend fun TelegramBot.editMessageCaption( replyMarkup: InlineKeyboardMarkup? = null ) = editMessageCaption(chat.id, messageId, text, parseMode, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageCaption( message: ContentMessage, text: String, @@ -40,6 +52,10 @@ suspend fun TelegramBot.editMessageCaption( return editMessageCaption(message.chat.id, message.messageId, text, parseMode, replyMarkup) } +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageCaption( chatId: ChatIdentifier, messageId: MessageIdentifier, @@ -49,6 +65,10 @@ suspend fun TelegramBot.editMessageCaption( EditChatMessageCaption(chatId, messageId, entities, replyMarkup) ) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageCaption( chat: Chat, messageId: MessageIdentifier, @@ -56,6 +76,10 @@ suspend fun TelegramBot.editMessageCaption( replyMarkup: InlineKeyboardMarkup? = null ) = editMessageCaption(chat.id, messageId, entities, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageCaption( message: ContentMessage, entities: List, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditInlineMessageCaption.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditInlineMessageCaption.kt index 1ee2224a42..8f0f89b2a6 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditInlineMessageCaption.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditInlineMessageCaption.kt @@ -7,6 +7,10 @@ import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageCaption( inlineMessageId: InlineMessageIdentifier, text: String, @@ -14,6 +18,10 @@ suspend fun TelegramBot.editMessageCaption( replyMarkup: InlineKeyboardMarkup? = null ) = execute(EditInlineMessageCaption(inlineMessageId, text, parseMode, replyMarkup)) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageCaption( inlineMessageId: InlineMessageIdentifier, entities: TextSourcesList, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditChatMessageMedia.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditChatMessageMedia.kt index 58c19261c7..b927dc0ef9 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditChatMessageMedia.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditChatMessageMedia.kt @@ -10,6 +10,10 @@ import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageMedia( chatId: ChatIdentifier, messageId: MessageIdentifier, @@ -19,6 +23,10 @@ suspend fun TelegramBot.editMessageMedia( EditChatMessageMedia(chatId, messageId, media, replyMarkup) ) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageMedia( chat: Chat, messageId: MessageIdentifier, @@ -26,6 +34,10 @@ suspend fun TelegramBot.editMessageMedia( replyMarkup: InlineKeyboardMarkup? = null ) = editMessageMedia(chat.id, messageId, media, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageMedia( message: ContentMessage, media: InputMedia, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditInlineMessageMedia.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditInlineMessageMedia.kt index 31128eb6a7..dec47763cc 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditInlineMessageMedia.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditInlineMessageMedia.kt @@ -6,6 +6,10 @@ import dev.inmo.tgbotapi.types.InlineMessageIdentifier import dev.inmo.tgbotapi.types.InputMedia.InputMedia import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageCaption( inlineMessageId: InlineMessageIdentifier, media: InputMedia, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt index fa94728a9e..8ca8ef5c06 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt @@ -11,6 +11,10 @@ import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.content.TextContent +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageText( chatId: ChatIdentifier, messageId: MessageIdentifier, @@ -22,6 +26,10 @@ suspend fun TelegramBot.editMessageText( EditChatMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup) ) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageText( chat: Chat, messageId: MessageIdentifier, @@ -31,6 +39,10 @@ suspend fun TelegramBot.editMessageText( replyMarkup: InlineKeyboardMarkup? = null ) = editMessageText(chat.id, messageId, text, parseMode, disableWebPagePreview, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageText( message: ContentMessage, text: String, @@ -39,6 +51,10 @@ suspend fun TelegramBot.editMessageText( replyMarkup: InlineKeyboardMarkup? = null ) = editMessageText(message.chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageText( chatId: ChatIdentifier, messageId: MessageIdentifier, @@ -49,6 +65,10 @@ suspend fun TelegramBot.editMessageText( EditChatMessageText(chatId, messageId, entities, disableWebPagePreview, replyMarkup) ) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageText( chat: Chat, messageId: MessageIdentifier, @@ -57,6 +77,10 @@ suspend fun TelegramBot.editMessageText( replyMarkup: InlineKeyboardMarkup? = null ) = editMessageText(chat.id, messageId, entities, disableWebPagePreview, replyMarkup) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageText( message: ContentMessage, entities: TextSourcesList, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt index 1293e4a3fa..1411e2cf87 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt @@ -7,6 +7,10 @@ import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageText( inlineMessageId: InlineMessageIdentifier, text: String, @@ -15,6 +19,10 @@ suspend fun TelegramBot.editMessageText( replyMarkup: InlineKeyboardMarkup? = null ) = execute(EditInlineMessageText(inlineMessageId, text, parseMode, disableWebPagePreview, replyMarkup)) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.editMessageText( inlineMessageId: InlineMessageIdentifier, entities: TextSourcesList, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileStream.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileStream.kt index f601f643c9..f2c35a6d95 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileStream.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileStream.kt @@ -2,7 +2,6 @@ package dev.inmo.tgbotapi.extensions.api.files import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo -import dev.inmo.tgbotapi.requests.DownloadFileStream import dev.inmo.tgbotapi.requests.abstracts.FileId import dev.inmo.tgbotapi.types.files.PathedFile import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt index c7f2281461..d616675575 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt @@ -10,6 +10,10 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.message.abstracts.Message +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.copyMessage( fromChatId: ChatIdentifier, toChatId: ChatIdentifier, @@ -24,6 +28,10 @@ suspend inline fun TelegramBot.copyMessage( CopyMessage(fromChatId, toChatId, messageId, text, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.copyMessage( fromChat: Chat, toChatId: ChatIdentifier, @@ -36,6 +44,10 @@ suspend inline fun TelegramBot.copyMessage( replyMarkup: KeyboardMarkup? = null ) = copyMessage(fromChat.id, toChatId, messageId, text, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.copyMessage( fromChatId: ChatIdentifier, toChat: Chat, @@ -48,6 +60,10 @@ suspend inline fun TelegramBot.copyMessage( replyMarkup: KeyboardMarkup? = null ) = copyMessage(fromChatId, toChat.id, messageId, text, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.copyMessage( fromChat: Chat, toChat: Chat, @@ -60,6 +76,10 @@ suspend inline fun TelegramBot.copyMessage( replyMarkup: KeyboardMarkup? = null ) = copyMessage(fromChat.id, toChat.id, messageId, text, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.copyMessage( toChatId: ChatIdentifier, message: Message, @@ -71,6 +91,10 @@ suspend inline fun TelegramBot.copyMessage( replyMarkup: KeyboardMarkup? = null ) = copyMessage(message.chat, toChatId, message.messageId, text, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.copyMessage( toChat: Chat, message: Message, @@ -83,6 +107,10 @@ suspend inline fun TelegramBot.copyMessage( ) = copyMessage(message.chat, toChat, message.messageId, text, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.copyMessage( fromChatId: ChatIdentifier, toChatId: ChatIdentifier, @@ -96,6 +124,10 @@ suspend inline fun TelegramBot.copyMessage( CopyMessage(fromChatId, toChatId, messageId, entities, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.copyMessage( fromChat: Chat, toChatId: ChatIdentifier, @@ -107,6 +139,10 @@ suspend inline fun TelegramBot.copyMessage( replyMarkup: KeyboardMarkup? = null ) = copyMessage(fromChat.id, toChatId, messageId, entities, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.copyMessage( fromChatId: ChatIdentifier, toChat: Chat, @@ -118,6 +154,10 @@ suspend inline fun TelegramBot.copyMessage( replyMarkup: KeyboardMarkup? = null ) = copyMessage(fromChatId, toChat.id, messageId, entities, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.copyMessage( fromChat: Chat, toChat: Chat, @@ -129,6 +169,10 @@ suspend inline fun TelegramBot.copyMessage( replyMarkup: KeyboardMarkup? = null ) = copyMessage(fromChat.id, toChat.id, messageId, entities, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.copyMessage( toChatId: ChatIdentifier, message: Message, @@ -139,6 +183,10 @@ suspend inline fun TelegramBot.copyMessage( replyMarkup: KeyboardMarkup? = null ) = copyMessage(message.chat, toChatId, message.messageId, entities, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.copyMessage( toChat: Chat, message: Message, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt index fb0e8e0ad0..306c2ad1aa 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt @@ -28,6 +28,10 @@ import dev.inmo.tgbotapi.utils.RiskFeature // Contact +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.reply( to: Message, phoneNumber: String, @@ -47,6 +51,10 @@ suspend inline fun TelegramBot.reply( replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.reply( to: Message, contact: Contact, @@ -65,6 +73,10 @@ suspend inline fun TelegramBot.reply( // Dice +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.replyWithDice( to: Message, animationType: DiceAnimationType? = null, @@ -73,6 +85,10 @@ suspend inline fun TelegramBot.replyWithDice( replyMarkup: KeyboardMarkup? = null ) = sendDice(to.chat, animationType, disableNotification, to.messageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.reply( to: Message, animationType: DiceAnimationType, @@ -84,6 +100,10 @@ suspend inline fun TelegramBot.reply( // Location +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.reply( to: Message, latitude: Double, @@ -99,6 +119,10 @@ suspend inline fun TelegramBot.reply( replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.reply( to: Message, location: StaticLocation, @@ -115,6 +139,10 @@ suspend inline fun TelegramBot.reply( // Text message +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.reply( to: Message, text: String, @@ -134,6 +162,10 @@ suspend inline fun TelegramBot.reply( replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.reply( to: Message, entities: TextSourcesList, @@ -154,6 +186,10 @@ suspend inline fun TelegramBot.reply( // Venue +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.reply( to: Message, latitude: Double, @@ -646,6 +682,10 @@ suspend inline fun TelegramBot.reply( // Invoice +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend inline fun TelegramBot.reply( to: Message, title: String, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt index 024abedfff..d4ebb42816 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt @@ -1,6 +1,7 @@ package dev.inmo.tgbotapi.extensions.api.send -import dev.inmo.micro_utils.coroutines.* +import dev.inmo.micro_utils.coroutines.safelyWithResult +import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.requests.send.SendAction import dev.inmo.tgbotapi.types.* diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendContact.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendContact.kt index 85fb7693db..fc73848a31 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendContact.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendContact.kt @@ -6,6 +6,10 @@ import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendContact( chatId: ChatIdentifier, phoneNumber: String, @@ -21,6 +25,10 @@ suspend fun TelegramBot.sendContact( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendContact( chatId: ChatIdentifier, contact: Contact, @@ -34,6 +42,10 @@ suspend fun TelegramBot.sendContact( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendContact( chat: Chat, phoneNumber: String, @@ -47,6 +59,10 @@ suspend fun TelegramBot.sendContact( chat.id, phoneNumber, firstName, lastName, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendContact( chat: Chat, contact: Contact, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendDice.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendDice.kt index 9cac916e02..78622249bb 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendDice.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendDice.kt @@ -8,6 +8,10 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.dice.DiceAnimationType +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendDice( chatId: ChatIdentifier, animationType: DiceAnimationType? = null, @@ -19,6 +23,10 @@ suspend fun TelegramBot.sendDice( SendDice(chatId, animationType, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendDice( chat: Chat, animationType: DiceAnimationType? = null, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLocation.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLocation.kt index 12990c8031..b28da8d0c2 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLocation.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLocation.kt @@ -8,6 +8,10 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.location.StaticLocation +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendLocation( chatId: ChatIdentifier, latitude: Double, @@ -26,6 +30,10 @@ suspend fun TelegramBot.sendLocation( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendLocation( chatId: ChatIdentifier, location: StaticLocation, @@ -41,6 +49,10 @@ suspend fun TelegramBot.sendLocation( replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendLocation( chat: Chat, latitude: Double, @@ -57,6 +69,10 @@ suspend fun TelegramBot.sendLocation( replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendLocation( chat: Chat, location: StaticLocation, @@ -72,6 +88,10 @@ suspend fun TelegramBot.sendLocation( replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendStaticLocation( chatId: ChatIdentifier, latitude: Double, @@ -81,6 +101,10 @@ suspend fun TelegramBot.sendStaticLocation( replyMarkup: KeyboardMarkup? = null ) = sendLocation(chatId, latitude, longitude, disableNotification, replyToMessageId, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendStaticLocation( chatId: ChatIdentifier, location: StaticLocation, @@ -89,6 +113,10 @@ suspend fun TelegramBot.sendStaticLocation( replyMarkup: KeyboardMarkup? = null ) = sendLocation(chatId, location.latitude, location.longitude, disableNotification, replyToMessageId, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendStaticLocation( chat: Chat, latitude: Double, @@ -98,6 +126,10 @@ suspend fun TelegramBot.sendStaticLocation( replyMarkup: KeyboardMarkup? = null ) = sendLocation(chat.id, latitude, longitude, disableNotification, replyToMessageId, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendStaticLocation( chat: Chat, location: StaticLocation, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt index 9b1bcf899d..0ec10e0eee 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt @@ -9,6 +9,10 @@ import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendMessage( chatId: ChatIdentifier, text: String, @@ -22,6 +26,10 @@ suspend fun TelegramBot.sendMessage( SendTextMessage(chatId, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendTextMessage( chatId: ChatIdentifier, text: String, @@ -35,6 +43,10 @@ suspend fun TelegramBot.sendTextMessage( chatId, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendMessage( chat: Chat, text: String, @@ -47,6 +59,10 @@ suspend fun TelegramBot.sendMessage( ) = sendMessage(chat.id, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendTextMessage( chat: Chat, text: String, @@ -58,6 +74,10 @@ suspend fun TelegramBot.sendTextMessage( replyMarkup: KeyboardMarkup? = null ) = sendTextMessage(chat.id, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendMessage( chatId: ChatIdentifier, entities: TextSourcesList, @@ -70,6 +90,10 @@ suspend fun TelegramBot.sendMessage( SendTextMessage(chatId, entities, disableWebPagePreview, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendTextMessage( chatId: ChatIdentifier, entities: TextSourcesList, @@ -82,6 +106,10 @@ suspend fun TelegramBot.sendTextMessage( chatId, entities, disableWebPagePreview, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendMessage( chat: Chat, entities: TextSourcesList, @@ -93,6 +121,10 @@ suspend fun TelegramBot.sendMessage( ) = sendMessage(chat.id, entities, disableWebPagePreview, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendTextMessage( chat: Chat, entities: TextSourcesList, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendVenue.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendVenue.kt index 6cfcbe6cf8..b56153d786 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendVenue.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendVenue.kt @@ -8,6 +8,10 @@ import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.location.StaticLocation import dev.inmo.tgbotapi.types.venue.Venue +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendVenue( chatId: ChatIdentifier, latitude: Double, @@ -40,6 +44,10 @@ suspend fun TelegramBot.sendVenue( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendVenue( chat: Chat, latitude: Double, @@ -70,6 +78,10 @@ suspend fun TelegramBot.sendVenue( replyMarkup = replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendVenue( chatId: ChatIdentifier, location: StaticLocation, @@ -99,6 +111,10 @@ suspend fun TelegramBot.sendVenue( replyMarkup = replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendVenue( chat: Chat, location: StaticLocation, @@ -128,6 +144,10 @@ suspend fun TelegramBot.sendVenue( replyMarkup = replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendVenue( chatId: ChatIdentifier, venue: Venue, @@ -146,6 +166,10 @@ suspend fun TelegramBot.sendVenue( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendVenue( chat: Chat, venue: Venue, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/games/SendGame.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/games/SendGame.kt index fea4bc7185..beec35e4ed 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/games/SendGame.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/games/SendGame.kt @@ -1,16 +1,17 @@ package dev.inmo.tgbotapi.extensions.api.send.games import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.send.reply -import dev.inmo.tgbotapi.extensions.api.send.replyWithGame import dev.inmo.tgbotapi.requests.send.games.SendGame import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.games.Game -import dev.inmo.tgbotapi.types.message.abstracts.Message +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendGame( chatId: ChatIdentifier, gameShortName: String, @@ -24,6 +25,10 @@ suspend fun TelegramBot.sendGame( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendGame( chat: Chat, gameShortName: String, @@ -35,6 +40,10 @@ suspend fun TelegramBot.sendGame( chat.id, gameShortName, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendGame( chatId: ChatIdentifier, game: Game, @@ -46,6 +55,10 @@ suspend fun TelegramBot.sendGame( chatId, game.title, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendGame( chat: Chat, game: Game, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt index fa3210e83a..0d14ad66b9 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt @@ -1,8 +1,6 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.send.reply -import dev.inmo.tgbotapi.extensions.api.send.replyWithAnimation import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendAnimation import dev.inmo.tgbotapi.types.ChatIdentifier @@ -12,8 +10,11 @@ import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.files.AnimationFile -import dev.inmo.tgbotapi.types.message.abstracts.Message +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendAnimation( chatId: ChatIdentifier, animation: InputFile, @@ -44,6 +45,10 @@ suspend fun TelegramBot.sendAnimation( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendAnimation( chatId: ChatIdentifier, animation: AnimationFile, @@ -60,6 +65,10 @@ suspend fun TelegramBot.sendAnimation( chatId, animation.fileId, animation.thumb ?.fileId, text, parseMode, duration, width, height, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendAnimation( chat: Chat, animation: InputFile, @@ -75,6 +84,10 @@ suspend fun TelegramBot.sendAnimation( replyMarkup: KeyboardMarkup? = null ) = sendAnimation(chat.id, animation, thumb, text, parseMode, duration, width, height, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendAnimation( chat: Chat, animation: AnimationFile, @@ -90,6 +103,10 @@ suspend fun TelegramBot.sendAnimation( ) = sendAnimation(chat.id, animation, text, parseMode, duration, width, height, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendAnimation( chatId: ChatIdentifier, animation: InputFile, @@ -118,6 +135,10 @@ suspend fun TelegramBot.sendAnimation( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendAnimation( chatId: ChatIdentifier, animation: AnimationFile, @@ -133,6 +154,10 @@ suspend fun TelegramBot.sendAnimation( chatId, animation.fileId, animation.thumb ?.fileId, entities, duration, width, height, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendAnimation( chat: Chat, animation: InputFile, @@ -147,6 +172,10 @@ suspend fun TelegramBot.sendAnimation( replyMarkup: KeyboardMarkup? = null ) = sendAnimation(chat.id, animation, thumb, entities, duration, width, height, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendAnimation( chat: Chat, animation: AnimationFile, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt index b7cd0846b9..646870807f 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt @@ -1,8 +1,6 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.send.reply -import dev.inmo.tgbotapi.extensions.api.send.replyWithAudio import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendAudio import dev.inmo.tgbotapi.types.ChatIdentifier @@ -12,8 +10,11 @@ import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.files.AudioFile -import dev.inmo.tgbotapi.types.message.abstracts.Message +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendAudio( chatId: ChatIdentifier, audio: InputFile, @@ -44,6 +45,10 @@ suspend fun TelegramBot.sendAudio( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendAudio( chat: Chat, audio: InputFile, @@ -59,6 +64,10 @@ suspend fun TelegramBot.sendAudio( replyMarkup: KeyboardMarkup? = null ) = sendAudio(chat.id, audio, thumb, text, parseMode, duration, performer, title, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendAudio( chatId: ChatIdentifier, audio: AudioFile, @@ -71,6 +80,10 @@ suspend fun TelegramBot.sendAudio( replyMarkup: KeyboardMarkup? = null ) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendAudio( chat: Chat, audio: AudioFile, @@ -84,6 +97,10 @@ suspend fun TelegramBot.sendAudio( ) = sendAudio(chat.id, audio, text, parseMode, title, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendAudio( chatId: ChatIdentifier, audio: InputFile, @@ -112,6 +129,10 @@ suspend inline fun TelegramBot.sendAudio( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendAudio( chat: Chat, audio: InputFile, @@ -126,6 +147,10 @@ suspend inline fun TelegramBot.sendAudio( replyMarkup: KeyboardMarkup? = null ) = sendAudio(chat.id, audio, thumb, entities, duration, performer, title, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendAudio( chatId: ChatIdentifier, audio: AudioFile, @@ -137,6 +162,10 @@ suspend inline fun TelegramBot.sendAudio( replyMarkup: KeyboardMarkup? = null ) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, entities, audio.duration, audio.performer, title, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendAudio( chat: Chat, audio: AudioFile, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt index 2766ee1d49..13d3e25a54 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt @@ -1,8 +1,6 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.send.reply -import dev.inmo.tgbotapi.extensions.api.send.replyWithDocument import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendDocument import dev.inmo.tgbotapi.types.ChatIdentifier @@ -12,8 +10,11 @@ import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.files.DocumentFile -import dev.inmo.tgbotapi.types.message.abstracts.Message +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendDocument( chatId: ChatIdentifier, document: InputFile, @@ -40,6 +41,10 @@ suspend fun TelegramBot.sendDocument( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendDocument( chat: Chat, document: InputFile, @@ -53,6 +58,10 @@ suspend fun TelegramBot.sendDocument( disableContentTypeDetection: Boolean? = null ) = sendDocument(chat.id, document, thumb, text, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendDocument( chatId: ChatIdentifier, document: DocumentFile, @@ -67,6 +76,10 @@ suspend fun TelegramBot.sendDocument( chatId, document.fileId, document.thumb ?.fileId, text, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendDocument( chat: Chat, document: DocumentFile, @@ -79,6 +92,10 @@ suspend fun TelegramBot.sendDocument( disableContentTypeDetection: Boolean? = null ) = sendDocument(chat.id, document, text, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendDocument( chatId: ChatIdentifier, document: InputFile, @@ -103,6 +120,10 @@ suspend inline fun TelegramBot.sendDocument( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendDocument( chat: Chat, document: InputFile, @@ -115,6 +136,10 @@ suspend inline fun TelegramBot.sendDocument( disableContentTypeDetection: Boolean? = null ) = sendDocument(chat.id, document, thumb, entities, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendDocument( chatId: ChatIdentifier, document: DocumentFile, @@ -128,6 +153,10 @@ suspend inline fun TelegramBot.sendDocument( chatId, document.fileId, document.thumb ?.fileId, entities, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendDocument( chat: Chat, document: DocumentFile, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt index 7a14aaf82e..abc11f38bb 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt @@ -1,16 +1,11 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.send.replyWithDocuments -import dev.inmo.tgbotapi.extensions.api.send.replyWithGallery -import dev.inmo.tgbotapi.extensions.api.send.replyWithMediaGroup -import dev.inmo.tgbotapi.extensions.api.send.replyWithPlaylist import dev.inmo.tgbotapi.requests.send.media.* import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.InputMedia.* import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.chat.abstracts.Chat -import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent import dev.inmo.tgbotapi.utils.RiskFeature diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt index 1decf11793..6ae7bc6d46 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt @@ -1,8 +1,6 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.send.reply -import dev.inmo.tgbotapi.extensions.api.send.replyWithPhoto import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendPhoto import dev.inmo.tgbotapi.types.ChatIdentifier @@ -13,8 +11,11 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.files.Photo import dev.inmo.tgbotapi.types.files.biggest -import dev.inmo.tgbotapi.types.message.abstracts.Message +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendPhoto( chatId: ChatIdentifier, fileId: InputFile, @@ -37,6 +38,10 @@ suspend fun TelegramBot.sendPhoto( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendPhoto( chat: Chat, fileId: InputFile, @@ -48,6 +53,10 @@ suspend fun TelegramBot.sendPhoto( replyMarkup: KeyboardMarkup? = null ) = sendPhoto(chat.id, fileId, text, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendPhoto( chatId: ChatIdentifier, photo: Photo, @@ -59,6 +68,10 @@ suspend fun TelegramBot.sendPhoto( replyMarkup: KeyboardMarkup? = null ) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), text, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendPhoto( chat: Chat, photo: Photo, @@ -71,6 +84,10 @@ suspend fun TelegramBot.sendPhoto( ) = sendPhoto(chat.id, photo, text, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, fileId: InputFile, @@ -91,6 +108,10 @@ suspend inline fun TelegramBot.sendPhoto( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendPhoto( chat: Chat, fileId: InputFile, @@ -101,6 +122,10 @@ suspend inline fun TelegramBot.sendPhoto( replyMarkup: KeyboardMarkup? = null ) = sendPhoto(chat.id, fileId, entities, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendPhoto( chatId: ChatIdentifier, photo: Photo, @@ -111,6 +136,10 @@ suspend inline fun TelegramBot.sendPhoto( replyMarkup: KeyboardMarkup? = null ) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), entities, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendPhoto( chat: Chat, photo: Photo, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt index 03d489b6bf..1a06fbc617 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt @@ -1,8 +1,6 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.send.reply -import dev.inmo.tgbotapi.extensions.api.send.replyWithSticker import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendSticker import dev.inmo.tgbotapi.types.ChatIdentifier @@ -10,8 +8,11 @@ import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.files.Sticker -import dev.inmo.tgbotapi.types.message.abstracts.Message +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendSticker( chatId: ChatIdentifier, sticker: InputFile, @@ -23,6 +24,10 @@ suspend fun TelegramBot.sendSticker( SendSticker(chatId, sticker, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendSticker( chat: Chat, sticker: InputFile, @@ -32,6 +37,10 @@ suspend fun TelegramBot.sendSticker( replyMarkup: KeyboardMarkup? = null ) = sendSticker(chat.id, sticker, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendSticker( chatId: ChatIdentifier, sticker: Sticker, @@ -41,6 +50,10 @@ suspend fun TelegramBot.sendSticker( replyMarkup: KeyboardMarkup? = null ) = sendSticker(chatId, sticker.fileId, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendSticker( chat: Chat, sticker: Sticker, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt index 6cc62cb512..4460af5284 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt @@ -1,8 +1,6 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.send.reply -import dev.inmo.tgbotapi.extensions.api.send.replyWithVideo import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendVideo import dev.inmo.tgbotapi.types.ChatIdentifier @@ -12,8 +10,11 @@ import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.files.VideoFile -import dev.inmo.tgbotapi.types.message.abstracts.Message +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendVideo( chatId: ChatIdentifier, video: InputFile, @@ -45,6 +46,10 @@ suspend fun TelegramBot.sendVideo( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendVideo( chatId: ChatIdentifier, video: VideoFile, @@ -56,6 +61,10 @@ suspend fun TelegramBot.sendVideo( replyMarkup: KeyboardMarkup? = null ) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendVideo( chat: Chat, video: InputFile, @@ -72,6 +81,10 @@ suspend fun TelegramBot.sendVideo( ) = sendVideo(chat.id, video, thumb, text, parseMode, duration, width, height, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendVideo( chat: Chat, video: VideoFile, @@ -83,6 +96,10 @@ suspend fun TelegramBot.sendVideo( replyMarkup: KeyboardMarkup? = null ) = sendVideo(chat.id, video, text, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendVideo( chatId: ChatIdentifier, video: InputFile, @@ -112,6 +129,10 @@ suspend inline fun TelegramBot.sendVideo( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendVideo( chatId: ChatIdentifier, video: VideoFile, @@ -122,6 +143,10 @@ suspend inline fun TelegramBot.sendVideo( replyMarkup: KeyboardMarkup? = null ) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, entities, video.duration, video.width, video.height, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendVideo( chat: Chat, video: InputFile, @@ -137,6 +162,10 @@ suspend inline fun TelegramBot.sendVideo( ) = sendVideo(chat.id, video, thumb, entities, duration, width, height, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendVideo( chat: Chat, video: VideoFile, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt index bc54f04403..5a9a734f1a 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt @@ -9,6 +9,10 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.files.VideoNoteFile +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendVideoNote( chatId: ChatIdentifier, videoNote: InputFile, @@ -33,6 +37,10 @@ suspend fun TelegramBot.sendVideoNote( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendVideoNote( chatId: ChatIdentifier, videoNote: VideoNoteFile, @@ -44,6 +52,10 @@ suspend fun TelegramBot.sendVideoNote( chatId, videoNote.fileId, videoNote.thumb ?.fileId, videoNote.duration, videoNote.width, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendVideoNote( chat: Chat, videoNote: InputFile, @@ -56,6 +68,10 @@ suspend fun TelegramBot.sendVideoNote( replyMarkup: KeyboardMarkup? = null ) = sendVideoNote(chat.id, videoNote, thumb, duration, size, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendVideoNote( chat: Chat, videoNote: VideoNoteFile, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt index 3474250cfc..5f32941240 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt @@ -1,19 +1,21 @@ package dev.inmo.tgbotapi.extensions.api.send.media import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.send.reply -import dev.inmo.tgbotapi.extensions.api.send.replyWithVoice import dev.inmo.tgbotapi.requests.abstracts.InputFile import dev.inmo.tgbotapi.requests.send.media.SendVoice import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.ParseMode.ParseMode +import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.files.VoiceFile -import dev.inmo.tgbotapi.types.message.abstracts.Message +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendVoice( chatId: ChatIdentifier, voice: InputFile, @@ -38,6 +40,10 @@ suspend fun TelegramBot.sendVoice( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendVoice( chat: Chat, voice: InputFile, @@ -50,6 +56,10 @@ suspend fun TelegramBot.sendVoice( replyMarkup: KeyboardMarkup? = null ) = sendVoice(chat.id, voice, text, parseMode, duration, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendVoice( chatId: ChatIdentifier, voice: VoiceFile, @@ -63,6 +73,10 @@ suspend fun TelegramBot.sendVoice( chatId, voice.fileId, text, parseMode, voice.duration, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendVoice( chat: Chat, voice: VoiceFile, @@ -75,6 +89,10 @@ suspend fun TelegramBot.sendVoice( ) = sendVoice(chat.id, voice, text, parseMode, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendVoice( chatId: ChatIdentifier, voice: InputFile, @@ -97,6 +115,10 @@ suspend inline fun TelegramBot.sendVoice( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendVoice( chat: Chat, voice: InputFile, @@ -108,6 +130,10 @@ suspend inline fun TelegramBot.sendVoice( replyMarkup: KeyboardMarkup? = null ) = sendVoice(chat.id, voice, entities, duration, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendVoice( chatId: ChatIdentifier, voice: VoiceFile, @@ -119,7 +145,10 @@ suspend inline fun TelegramBot.sendVoice( ) = sendVoice( chatId, voice.fileId, entities, voice.duration, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup ) - +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendVoice( chat: Chat, voice: VoiceFile, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt index 5489f27b17..f97ecffa50 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt @@ -1,14 +1,16 @@ package dev.inmo.tgbotapi.extensions.api.send.payments import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.send.reply import dev.inmo.tgbotapi.requests.send.payments.SendInvoice import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup -import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.payments.LabeledPrice import dev.inmo.tgbotapi.types.payments.abstracts.Currency +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.sendInvoice( chatId: ChatId, title: String, @@ -36,6 +38,10 @@ suspend fun TelegramBot.sendInvoice( SendInvoice(chatId, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts ?.sorted(), startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) +/** + * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] + * as a builder for that + */ suspend fun TelegramBot.sendInvoice( user: CommonUser, title: String, diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt index c6df9d1ca1..b499b88f5b 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.extensions.api.send.polls import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.extensions.api.send.reply import dev.inmo.tgbotapi.requests.send.polls.SendQuizPoll import dev.inmo.tgbotapi.requests.send.polls.SendRegularPoll import dev.inmo.tgbotapi.types.ChatIdentifier @@ -10,9 +9,12 @@ import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.ParseMode.ParseMode import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat -import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.polls.* +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendRegularPoll( chatId: ChatIdentifier, question: String, @@ -30,6 +32,10 @@ suspend fun TelegramBot.sendRegularPoll( chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendRegularPoll( chatId: ChatIdentifier, poll: RegularPoll, @@ -45,6 +51,10 @@ suspend fun TelegramBot.sendRegularPoll( replyMarkup: KeyboardMarkup? = null ) = sendRegularPoll(chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendRegularPoll( chat: Chat, question: String, @@ -61,6 +71,10 @@ suspend fun TelegramBot.sendRegularPoll( chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendRegularPoll( chat: Chat, poll: RegularPoll, @@ -79,6 +93,10 @@ suspend fun TelegramBot.sendRegularPoll( ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendQuizPoll( chatId: ChatIdentifier, question: String, @@ -99,6 +117,10 @@ suspend fun TelegramBot.sendQuizPoll( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendQuizPoll( chat: Chat, question: String, @@ -117,6 +139,10 @@ suspend fun TelegramBot.sendQuizPoll( chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendQuizPoll( chatId: ChatIdentifier, isClosed: Boolean = false, @@ -136,6 +162,10 @@ suspend fun TelegramBot.sendQuizPoll( chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend fun TelegramBot.sendQuizPoll( chat: Chat, isClosed: Boolean = false, @@ -156,6 +186,10 @@ suspend fun TelegramBot.sendQuizPoll( ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendQuizPoll( chatId: ChatIdentifier, question: String, @@ -175,6 +209,10 @@ suspend inline fun TelegramBot.sendQuizPoll( ) ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendQuizPoll( chat: Chat, question: String, @@ -192,6 +230,10 @@ suspend inline fun TelegramBot.sendQuizPoll( chat.id, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendQuizPoll( chatId: ChatIdentifier, isClosed: Boolean = false, @@ -210,6 +252,10 @@ suspend inline fun TelegramBot.sendQuizPoll( chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, replyToMessageId, allowSendingWithoutReply, replyMarkup ) +/** + * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or + * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param + */ suspend inline fun TelegramBot.sendQuizPoll( chat: Chat, isClosed: Boolean = false, diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt new file mode 100644 index 0000000000..1d348269b8 --- /dev/null +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt @@ -0,0 +1,130 @@ +package dev.inmo.tgbotapi.extensions.utils.types.buttons + +import dev.inmo.tgbotapi.types.LoginURL +import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.* +import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup +import dev.inmo.tgbotapi.utils.MatrixBuilder +import dev.inmo.tgbotapi.utils.RowBuilder + +/** + * Core DSL part of Inline Keyboard DSL. Can accept only [InlineKeyboardButton] and returns ready to use + * [InlineKeyboardMarkup] via [build] method + * + * @see inlineKeyboard + * @see InlineKeyboardBuilder.row + * @see InlineKeyboardRowBuilder + */ +class InlineKeyboardBuilder : MatrixBuilder() { + /** + * Creates [InlineKeyboardMarkup] using internal [matrix] + */ + fun build() = InlineKeyboardMarkup(matrix) +} + +/** + * Row builder of [InlineKeyboardBuilder] + * + * @see inlineKeyboard + * @see InlineKeyboardBuilder.row + */ +class InlineKeyboardRowBuilder : RowBuilder() + +/** + * Factory-function for [InlineKeyboardBuilder]. It will [apply] [block] to internally created [InlineKeyboardMarkup] + * and [InlineKeyboardBuilder.build] [InlineKeyboardMarkup] then + * + * @see InlineKeyboardBuilder.row + */ +inline fun inlineKeyboard( + crossinline block: InlineKeyboardBuilder.() -> Unit +) = InlineKeyboardBuilder().apply(block).build() + +/** + * Creates an [InlineKeyboardRowBuilder] and [apply] [block] with this builder + * + * @see payButton + * @see dataButton + * @see gameButton + * @see loginButton + * @see inlineQueryInCurrentChatButton + * @see inlineQueryButton + * @see urlButton + */ +inline fun InlineKeyboardBuilder.row( + crossinline block: InlineKeyboardRowBuilder.() -> Unit +) = add(InlineKeyboardRowBuilder().apply(block).row) + +/** + * Creates and put [PayInlineKeyboardButton] + * + * @see inlineKeyboard + * @see InlineKeyboardBuilder.row + */ +inline fun InlineKeyboardRowBuilder.payButton( + text: String +) = add(PayInlineKeyboardButton(text)) + +/** + * Creates and put [CallbackDataInlineKeyboardButton] + * + * @see inlineKeyboard + * @see InlineKeyboardBuilder.row + */ +inline fun InlineKeyboardRowBuilder.dataButton( + text: String, + data: String +) = add(CallbackDataInlineKeyboardButton(text, data)) + +/** + * Creates and put [CallbackGameInlineKeyboardButton] + * + * @see inlineKeyboard + * @see InlineKeyboardBuilder.row + */ +inline fun InlineKeyboardRowBuilder.gameButton( + text: String +) = add(CallbackGameInlineKeyboardButton(text)) + +/** + * Creates and put [LoginURLInlineKeyboardButton] + * + * @see inlineKeyboard + * @see InlineKeyboardBuilder.row + */ +inline fun InlineKeyboardRowBuilder.loginButton( + text: String, + loginUrl: LoginURL +) = add(LoginURLInlineKeyboardButton(text, loginUrl)) + +/** + * Creates and put [SwitchInlineQueryCurrentChatInlineKeyboardButton] + * + * @see inlineKeyboard + * @see InlineKeyboardBuilder.row + */ +inline fun InlineKeyboardRowBuilder.inlineQueryInCurrentChatButton( + text: String, + data: String +) = add(SwitchInlineQueryCurrentChatInlineKeyboardButton(text, data)) + +/** + * Creates and put [SwitchInlineQueryInlineKeyboardButton] + * + * @see inlineKeyboard + * @see InlineKeyboardBuilder.row + */ +inline fun InlineKeyboardRowBuilder.inlineQueryButton( + text: String, + data: String +) = add(SwitchInlineQueryInlineKeyboardButton(text, data)) + +/** + * Creates and put [URLInlineKeyboardButton] + * + * @see inlineKeyboard + * @see InlineKeyboardBuilder.row + */ +inline fun InlineKeyboardRowBuilder.urlButton( + text: String, + url: String +) = add(URLInlineKeyboardButton(text, url)) diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt new file mode 100644 index 0000000000..f359d0e5ee --- /dev/null +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt @@ -0,0 +1,102 @@ +package dev.inmo.tgbotapi.extensions.utils.types.buttons + +import dev.inmo.tgbotapi.types.buttons.* +import dev.inmo.tgbotapi.types.inputFieldPlaceholderField +import dev.inmo.tgbotapi.utils.MatrixBuilder +import dev.inmo.tgbotapi.utils.RowBuilder +import kotlinx.serialization.SerialName + +/** + * Core DSL part of Keyboard DSL. Can accept only [KeyboardButton] and returns ready to use + * [ReplyKeyboardMarkup] via [build] method + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + * @see ReplyKeyboardRowBuilder + */ +class ReplyKeyboardBuilder : MatrixBuilder() { + /** + * Creates [InlineKeyboardMarkup] using internal [matrix] + */ + fun build( + resizeKeyboard: Boolean? = null, + oneTimeKeyboard: Boolean? = null, + inputFieldPlaceholder: String? = null, + selective: Boolean? = null, + ) = ReplyKeyboardMarkup(matrix, resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) +} + +/** + * Row builder of [KeyboardButton] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +class ReplyKeyboardRowBuilder : RowBuilder() + +/** + * Factory-function for [ReplyKeyboardBuilder]. It will [apply] [block] to internally created [ReplyKeyboardMarkup] + * and [ReplyKeyboardBuilder.build] [ReplyKeyboardMarkup] then + * + * @see ReplyKeyboardBuilder.row + */ +inline fun replyKeyboard( + resizeKeyboard: Boolean? = null, + oneTimeKeyboard: Boolean? = null, + inputFieldPlaceholder: String? = null, + selective: Boolean? = null, + crossinline block: ReplyKeyboardBuilder.() -> Unit +) = ReplyKeyboardBuilder().apply(block).build(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) + +/** + * Creates an [ReplyKeyboardRowBuilder] and [apply] [block] with this builder + * + * @see simpleButton + * @see requestContactButton + * @see requestLocationButton + * @see requestPollButton + */ +inline fun ReplyKeyboardBuilder.row( + crossinline block: ReplyKeyboardRowBuilder.() -> Unit +) = add(ReplyKeyboardRowBuilder().apply(block).row) + +/** + * Creates and put [SimpleKeyboardButton] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun ReplyKeyboardRowBuilder.simpleButton( + text: String +) = add(SimpleKeyboardButton(text)) + +/** + * Creates and put [RequestContactKeyboardButton] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun ReplyKeyboardRowBuilder.requestContactButton( + text: String +) = add(RequestContactKeyboardButton(text)) + +/** + * Creates and put [RequestLocationKeyboardButton] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun ReplyKeyboardRowBuilder.requestLocationButton( + text: String +) = add(RequestLocationKeyboardButton(text)) + +/** + * Creates and put [RequestPollKeyboardButton] + * + * @see replyKeyboard + * @see ReplyKeyboardBuilder.row + */ +inline fun ReplyKeyboardRowBuilder.requestPollButton( + text: String, + pollType: KeyboardButtonPollType +) = add(RequestPollKeyboardButton(text, pollType)) From 9a3fc19992a2d6a4dedd1a51ec5ef969db7cce05 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 1 Oct 2021 19:42:12 +0600 Subject: [PATCH 05/40] update packages_publish workflow --- .github/workflows/packages_publishing.yml | 2 ++ CHANGELOG.md | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/packages_publishing.yml b/.github/workflows/packages_publishing.yml index dc7e43744b..c16ebdcb19 100644 --- a/.github/workflows/packages_publishing.yml +++ b/.github/workflows/packages_publishing.yml @@ -17,6 +17,8 @@ jobs: cat gradle.properties | sed -e "s/^library_version=\([0-9\.]*\)/library_version=\1-branch_$branch-build${{ github.run_number }}/" > gradle.properties.tmp rm gradle.properties mv gradle.properties.tmp gradle.properties + - name: Build + run: ./gradlew build - name: Publish continue-on-error: true run: ./gradlew publishAllPublicationsToGithubPackagesRepository --no-parallel -x signJsPublication -x signJvmPublication -x signKotlinMultiplatformPublication diff --git a/CHANGELOG.md b/CHANGELOG.md index b0ed2b5720..da77e88dfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ * `Serialization`: `1.2.2` -> `1.3.0` * `Ktor`: `1.6.3` -> `1.6.4` * `MicroUtils`: `0.5.28` -> `0.5.31` +* `Utils`: + * Two new dsl: + * `inlineKeyboard` for creating `InlineKeyboardMarkup` + * `replyKeyboard` for creating `ReplyKeyboardMarkup` ## 0.35.9 From edcebb03c098510d2cda9eaf552458b74e5f4b06 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 1 Oct 2021 19:57:03 +0600 Subject: [PATCH 06/40] add note about deprecation of PayInlineKeyboardButton --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index da77e88dfb..145ec48e91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ * `Serialization`: `1.2.2` -> `1.3.0` * `Ktor`: `1.6.3` -> `1.6.4` * `MicroUtils`: `0.5.28` -> `0.5.31` +* `Core`: + * `PayInlineKeyboardButton#pay` now is deprecated * `Utils`: * Two new dsl: * `inlineKeyboard` for creating `InlineKeyboardMarkup` From 6557e8af10dfe7d16f1511a9c807552dafa81837 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 1 Oct 2021 20:07:14 +0600 Subject: [PATCH 07/40] upfixes in changelog --- CHANGELOG.md | 2 ++ .../kotlin/dev/inmo/tgbotapi/extensions/api/DownloadFile.kt | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DownloadFile.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 145ec48e91..b75bec0e50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ * `MicroUtils`: `0.5.28` -> `0.5.31` * `Core`: * `PayInlineKeyboardButton#pay` now is deprecated + * `RowBuilder` and `MatrixBuilder` now are open and available for extending + * `MatrixBuilder#matrix` will return read-only new list instead of original internal `mutMatrix` * `Utils`: * Two new dsl: * `inlineKeyboard` for creating `InlineKeyboardMarkup` diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DownloadFile.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DownloadFile.kt deleted file mode 100644 index 5d20323f3a..0000000000 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DownloadFile.kt +++ /dev/null @@ -1,2 +0,0 @@ -package dev.inmo.tgbotapi.extensions.api - From 702c1bc1ffc55ef56af447f0dda619179f97332b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 2 Oct 2021 00:52:29 +0600 Subject: [PATCH 08/40] fix build --- .../types/MessageEntity/textsources/BotCommandTextSource.kt | 1 - .../types/MessageEntity/textsources/CodeTextSource.kt | 1 - .../tgbotapi/types/MessageEntity/textsources/PreTextSource.kt | 1 - .../types/MessageEntity/textsources/RegularTextSource.kt | 1 - .../types/MessageEntity/textsources/TextLinkTextSource.kt | 1 - .../tgbotapi/types/MessageEntity/textsources/URLTextSource.kt | 1 - .../inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt | 2 +- .../kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt | 4 ++-- 8 files changed, 3 insertions(+), 9 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BotCommandTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BotCommandTextSource.kt index 472fa3bf7f..f659e7b9ea 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BotCommandTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/BotCommandTextSource.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CodeTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CodeTextSource.kt index b7dd572785..f783b2363c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CodeTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/CodeTextSource.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PreTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PreTextSource.kt index 63dd4f56c7..988952d75b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PreTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/PreTextSource.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/RegularTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/RegularTextSource.kt index 002c1ffae6..ae9ca3e9e9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/RegularTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/RegularTextSource.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextLinkTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextLinkTextSource.kt index 7ea9747518..46eaf6c440 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextLinkTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/TextLinkTextSource.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/URLTextSource.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/URLTextSource.kt index fcd68aa678..54ac9944e9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/URLTextSource.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/MessageEntity/textsources/URLTextSource.kt @@ -1,6 +1,5 @@ package dev.inmo.tgbotapi.types.MessageEntity.textsources -import dev.inmo.tgbotapi.CommonAbstracts.DirectInvocationOfTextSourceConstructor import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.internal.* import kotlinx.serialization.Serializable diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt index eb62df598a..613c923146 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt @@ -37,8 +37,8 @@ suspend fun telegramBotWithBehaviour( builder ).apply { buildBehaviour( - scope ?: CoroutineScope(coroutineContext), flowsUpdatesFilter, + scope ?: CoroutineScope(coroutineContext), defaultExceptionsHandler, block ) diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt index 5813d6b84a..c56c3c44f3 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -2314,10 +2314,10 @@ inline fun TelegramMediaFile.asThumbedMediaFile(): ThumbedMediaFile? = this as? inline fun TelegramMediaFile.requireThumbedMediaFile(): ThumbedMediaFile = this as ThumbedMediaFile @PreviewFeature -inline fun KeyboardMarkup.whenForceReply(block: (ForceReply) -> T) = asForceReply() ?.let(block) +inline fun KeyboardMarkup.whenForceReply(block: (ReplyForce) -> T) = asForceReply() ?.let(block) @PreviewFeature -inline fun KeyboardMarkup.asForceReply(): ForceReply? = this as? ReplyForce +inline fun KeyboardMarkup.asForceReply(): ReplyForce? = this as? ReplyForce @PreviewFeature inline fun KeyboardMarkup.requireForceReply(): ReplyForce = this as ReplyForce From e51a4b77029c0493f65abc9147eb2165167abeee Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 3 Oct 2021 11:43:15 +0600 Subject: [PATCH 09/40] SuccessfulPaymentEvent --- CHANGELOG.md | 2 + .../message/ChatEvents/DeleteChatPhoto.kt | 4 +- .../message/ChatEvents/LeftChatMember.kt | 4 +- .../types/message/ChatEvents/NewChatPhoto.kt | 4 +- .../types/message/ChatEvents/NewChatTitle.kt | 4 +- .../ChatEvents/ProximityAlertTriggered.kt | 4 +- .../ChatEvents/abstracts/CommonEvent.kt | 2 +- .../ChatEvents/abstracts/CommonGroupEvent.kt | 3 + .../ChatEvents/abstracts/PrivateEvent.kt | 3 + .../ChatEvents/abstracts/VoiceChatEvent.kt | 2 +- .../types/message/PrivateEventMessage.kt | 15 +++++ .../types/message/PrivateMessageImpl.kt | 8 ++- .../inmo/tgbotapi/types/message/RawMessage.kt | 23 ++++---- .../payments/SuccessfulPaymentEvent.kt | 11 ++++ .../message/payments/SuccessfulPaymentInfo.kt | 8 --- .../expectations/WaitEventAction.kt | 25 ++++++++ .../triggers_handling/EventTriggers.kt | 58 +++++++++++++++++++ .../tgbotapi/extensions/utils/ClassCasts.kt | 15 ++++- .../utils/shortcuts/EventsShortcuts.kt | 24 ++++++++ 19 files changed, 180 insertions(+), 39 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonGroupEvent.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/PrivateEvent.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateEventMessage.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/SuccessfulPaymentEvent.kt delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/SuccessfulPaymentInfo.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index b75bec0e50..4781e0e399 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ * `PayInlineKeyboardButton#pay` now is deprecated * `RowBuilder` and `MatrixBuilder` now are open and available for extending * `MatrixBuilder#matrix` will return read-only new list instead of original internal `mutMatrix` + * Introduced new type of events `SuccessfulPaymentEvent` instead of putting of payment inside of message + * New type of events union: `CommonGroupEvent` * `Utils`: * Two new dsl: * `inlineKeyboard` for creating `InlineKeyboardMarkup` diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/DeleteChatPhoto.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/DeleteChatPhoto.kt index db88fc3dac..88401cc144 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/DeleteChatPhoto.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/DeleteChatPhoto.kt @@ -1,5 +1,5 @@ package dev.inmo.tgbotapi.types.message.ChatEvents -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonGroupEvent -class DeleteChatPhoto: CommonEvent +class DeleteChatPhoto: CommonGroupEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt index 22a9def5f3..682ff86a91 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt @@ -1,8 +1,8 @@ package dev.inmo.tgbotapi.types.message.ChatEvents import dev.inmo.tgbotapi.types.User -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonGroupEvent data class LeftChatMember( val user: User -) : CommonEvent +) : CommonGroupEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatPhoto.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatPhoto.kt index a12f00ec52..34640e408c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatPhoto.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatPhoto.kt @@ -1,8 +1,8 @@ package dev.inmo.tgbotapi.types.message.ChatEvents import dev.inmo.tgbotapi.types.files.Photo -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonGroupEvent data class NewChatPhoto( val photo: Photo -): CommonEvent +): CommonGroupEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatTitle.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatTitle.kt index 3b1eaf6533..6ed5a469f6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatTitle.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatTitle.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.types.message.ChatEvents -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonGroupEvent data class NewChatTitle( val title: String -): CommonEvent +): CommonGroupEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/ProximityAlertTriggered.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/ProximityAlertTriggered.kt index e502522020..25604f2238 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/ProximityAlertTriggered.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/ProximityAlertTriggered.kt @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.message.ChatEvents import dev.inmo.tgbotapi.types.Meters import dev.inmo.tgbotapi.types.User -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonGroupEvent import kotlinx.serialization.Serializable /** @@ -14,4 +14,4 @@ data class ProximityAlertTriggered( val traveler: User, val watcher: User, val distance: Meters -) : CommonEvent +) : CommonGroupEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonEvent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonEvent.kt index feb9af40ff..0228be76e6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonEvent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonEvent.kt @@ -1,3 +1,3 @@ package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts -interface CommonEvent : ChannelEvent, GroupEvent, SupergroupEvent \ No newline at end of file +interface CommonEvent : CommonGroupEvent, PrivateEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonGroupEvent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonGroupEvent.kt new file mode 100644 index 0000000000..6432af9b0e --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonGroupEvent.kt @@ -0,0 +1,3 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts + +interface CommonGroupEvent : ChannelEvent, GroupEvent, SupergroupEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/PrivateEvent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/PrivateEvent.kt new file mode 100644 index 0000000000..b241669b98 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/PrivateEvent.kt @@ -0,0 +1,3 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts + +interface PrivateEvent : ChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt index 289fc5daac..33cf8c7a99 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt @@ -1,3 +1,3 @@ package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts -interface VoiceChatEvent : CommonEvent +interface VoiceChatEvent : CommonGroupEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateEventMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateEventMessage.kt new file mode 100644 index 0000000000..86a9a51845 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateEventMessage.kt @@ -0,0 +1,15 @@ +package dev.inmo.tgbotapi.types.message + +import com.soywiz.klock.DateTime +import dev.inmo.tgbotapi.types.MessageIdentifier +import dev.inmo.tgbotapi.types.chat.abstracts.ChannelChat +import dev.inmo.tgbotapi.types.chat.abstracts.PrivateChat +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PrivateEvent +import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage + +data class PrivateEventMessage( + override val messageId: MessageIdentifier, + override val chat: PrivateChat, + override val chatEvent: T, + override val date: DateTime +) : ChatEventMessage diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateMessageImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateMessageImpl.kt index 75a928c049..599fce4c76 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateMessageImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateMessageImpl.kt @@ -7,7 +7,7 @@ import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.PrivateContentMessage import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent -import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentInfo +import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent data class PrivateContentMessageImpl( override val messageId: MessageIdentifier, @@ -20,5 +20,7 @@ data class PrivateContentMessageImpl( override val replyTo: Message?, override val replyMarkup: InlineKeyboardMarkup?, override val senderBot: CommonBot?, - val paymentInfo: SuccessfulPaymentInfo? -) : PrivateContentMessage +) : PrivateContentMessage { + @Deprecated("This value will always be null. You may get SuccessfulPayment as one of ChatEvents") + val paymentInfo: SuccessfulPaymentEvent? = null +} 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 086b33b792..c17051fd19 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 @@ -17,8 +17,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.UnknownMessageType import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent import dev.inmo.tgbotapi.types.message.content.media.* -import dev.inmo.tgbotapi.types.message.payments.InvoiceContent -import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentInfo +import dev.inmo.tgbotapi.types.message.payments.* import dev.inmo.tgbotapi.types.passport.PassportData import dev.inmo.tgbotapi.types.payments.Invoice import dev.inmo.tgbotapi.types.payments.SuccessfulPayment @@ -197,18 +196,11 @@ internal data class RawMessage( channel_chat_created -> ChannelChatCreated() pinned_message != null -> PinnedMessage(pinned_message.asMessage) proximity_alert_triggered != null -> proximity_alert_triggered + successful_payment != null -> SuccessfulPaymentEvent(successful_payment) else -> null } } - private val paymentInfo: SuccessfulPaymentInfo? by lazy { - when { - successful_payment != null -> SuccessfulPaymentInfo(successful_payment) - else -> null - } - } - - val asMessage: Message by lazy { try { chatEvent?.let { chatEvent -> @@ -233,6 +225,12 @@ internal data class RawMessage( chatEvent as? ChannelEvent ?: throwWrongChatEvent(ChannelEvent::class, chatEvent), date.asDate ) + is PrivateChat -> PrivateEventMessage( + messageId, + chat, + chatEvent as? PrivateEvent ?: throwWrongChatEvent(PrivateEvent::class, chatEvent), + date.asDate + ) else -> error("Expected one of the public chats, but was $chat (in extracting of chat event message)") } } ?: content?.let { content -> @@ -335,8 +333,7 @@ internal data class RawMessage( forwarded, reply_to_message?.asMessage, reply_markup, - via_bot, - paymentInfo + via_bot ) else -> error("Unknown type of chat: $chat") } @@ -359,7 +356,7 @@ internal data class RawMessage( } } - private fun throwWrongChatEvent(expected: KClass<*>, but: ChatEvent): CommonEvent { + private fun throwWrongChatEvent(expected: KClass<*>, but: ChatEvent): Nothing { error("Wrong type of chat event: expected $expected, but was $but") } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/SuccessfulPaymentEvent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/SuccessfulPaymentEvent.kt new file mode 100644 index 0000000000..e981ab08a4 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/SuccessfulPaymentEvent.kt @@ -0,0 +1,11 @@ +package dev.inmo.tgbotapi.types.message.payments + +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent +import dev.inmo.tgbotapi.types.message.payments.abstracts.PaymentInfo +import dev.inmo.tgbotapi.types.payments.SuccessfulPayment + +@Deprecated("Renamed", ReplaceWith("SuccessfulPaymentEvent", "dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent")) +typealias SuccessfulPaymentInfo = SuccessfulPaymentEvent +data class SuccessfulPaymentEvent( + val payment: SuccessfulPayment +) : PaymentInfo, CommonEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/SuccessfulPaymentInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/SuccessfulPaymentInfo.kt deleted file mode 100644 index 50a1620155..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/payments/SuccessfulPaymentInfo.kt +++ /dev/null @@ -1,8 +0,0 @@ -package dev.inmo.tgbotapi.types.message.payments - -import dev.inmo.tgbotapi.types.message.payments.abstracts.PaymentInfo -import dev.inmo.tgbotapi.types.payments.SuccessfulPayment - -data class SuccessfulPaymentInfo( - val payment: SuccessfulPayment -) : PaymentInfo diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt index c0f7d534be..96b5de3c83 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt @@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* import dev.inmo.tgbotapi.types.message.ChatEvents.voice.* import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage +import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent import kotlinx.coroutines.flow.toList typealias EventMessageToEventMapper = suspend ChatEventMessage.() -> T? @@ -72,6 +73,14 @@ suspend fun BehaviourContext.waitChannelEvents( mapper: EventMessageToEventMapper? = null ) = waitEvents(count, initRequest, errorFactory, filter, mapper) +suspend fun BehaviourContext.waitPrivateEvents( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: SimpleFilter>? = null, + mapper: EventMessageToEventMapper? = null +) = waitEvents(count, initRequest, errorFactory, filter, mapper) + suspend fun BehaviourContext.waitChatEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -117,6 +126,14 @@ suspend fun BehaviourContext.waitMessageAutoDeleteTimerChangedEvents( mapper: EventMessageToEventMapper? = null ) = waitEvents(count, initRequest, errorFactory, filter, mapper) + +suspend fun BehaviourContext.waitCommonGroupEvents( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: SimpleFilter>? = null, + mapper: EventMessageToEventMapper? = null +) = waitEvents(count, initRequest, errorFactory, filter, mapper) suspend fun BehaviourContext.waitCommonEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -124,6 +141,7 @@ suspend fun BehaviourContext.waitCommonEvents( filter: SimpleFilter>? = null, mapper: EventMessageToEventMapper? = null ) = waitEvents(count, initRequest, errorFactory, filter, mapper) + suspend fun BehaviourContext.waitGroupEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, @@ -209,3 +227,10 @@ suspend fun BehaviourContext.waitSupergroupChatCreatedEvents( filter: SimpleFilter>? = null, mapper: EventMessageToEventMapper? = null ) = waitEvents(count, initRequest, errorFactory, filter, mapper) +suspend fun BehaviourContext.waitSuccessfulPaymentEvents( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: SimpleFilter>? = null, + mapper: EventMessageToEventMapper? = null +) = waitEvents(count, initRequest, errorFactory, filter, mapper) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt index 52876f5374..1ee51b3c6c 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt @@ -13,6 +13,7 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* import dev.inmo.tgbotapi.types.message.ChatEvents.voice.* import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage +import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent import dev.inmo.tgbotapi.types.update.abstracts.Update internal suspend inline fun BehaviourContext.onEvent( @@ -43,6 +44,25 @@ suspend fun BehaviourContext.onChannelEvent( scenarioReceiver: BehaviourContextAndTypeReceiver> ) = onEvent(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 BehaviourContext.onPrivateEvent( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: BehaviourContextAndTypeReceiver> +) = onEvent(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, @@ -157,6 +177,25 @@ suspend fun BehaviourContext.onMessageAutoDeleteTimerChangedEvent( scenarioReceiver: BehaviourContextAndTypeReceiver> ) = onEvent(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 BehaviourContext.onCommonGroupEvent( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: BehaviourContextAndTypeReceiver> +) = onEvent(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, @@ -403,3 +442,22 @@ suspend fun BehaviourContext.onSupergroupChatCreated( markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, scenarioReceiver: BehaviourContextAndTypeReceiver> ) = onEvent(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 BehaviourContext.onSuccessfulPayment( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: BehaviourContextAndTypeReceiver> +) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt index c56c3c44f3..61e18f89c6 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -1092,6 +1092,15 @@ inline fun Message.asGroupEventMessage(): GroupEventMessage? = this @PreviewFeature inline fun Message.requireGroupEventMessage(): GroupEventMessage = this as GroupEventMessage +@PreviewFeature +inline fun Message.whenPrivateEventMessage(block: (PrivateEventMessage) -> T) = asPrivateEventMessage() ?.let(block) + +@PreviewFeature +inline fun Message.asPrivateEventMessage(): PrivateEventMessage? = this as? PrivateEventMessage + +@PreviewFeature +inline fun Message.requirePrivateEventMessage(): PrivateEventMessage = this as PrivateEventMessage + @PreviewFeature inline fun Message.whenGroupContentMessage(block: (GroupContentMessage) -> T) = asGroupContentMessage() ?.let(block) @@ -3034,13 +3043,13 @@ inline fun ChatEvent.asChannelEvent(): ChannelEvent? = this as? ChannelEvent inline fun ChatEvent.requireChannelEvent(): ChannelEvent = this as ChannelEvent @PreviewFeature -inline fun ChatEvent.whenCommonEvent(block: (CommonEvent) -> T) = asCommonEvent() ?.let(block) +inline fun ChatEvent.whenCommonEvent(block: (CommonGroupEvent) -> T) = asCommonEvent() ?.let(block) @PreviewFeature -inline fun ChatEvent.asCommonEvent(): CommonEvent? = this as? CommonEvent +inline fun ChatEvent.asCommonEvent(): CommonGroupEvent? = this as? CommonGroupEvent @PreviewFeature -inline fun ChatEvent.requireCommonEvent(): CommonEvent = this as CommonEvent +inline fun ChatEvent.requireCommonEvent(): CommonGroupEvent = this as CommonGroupEvent @PreviewFeature inline fun ChatEvent.whenGroupEvent(block: (GroupEvent) -> T) = asGroupEvent() ?.let(block) diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt index e51288d803..6746cb2e15 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt @@ -6,7 +6,10 @@ import dev.inmo.micro_utils.coroutines.plus import dev.inmo.tgbotapi.types.message.ChannelEventMessage import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* +import dev.inmo.tgbotapi.types.message.PrivateEventMessage import dev.inmo.tgbotapi.types.message.abstracts.* +import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent +import dev.inmo.tgbotapi.types.payments.SuccessfulPayment import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.coroutines.flow.Flow @@ -32,6 +35,11 @@ inline fun FlowsUpdatesFilter.supergroupEvents(): Flow it.data as? SupergroupEventMessage<*> } +@RiskFeature("Use with caution") +inline fun FlowsUpdatesFilter.privateEvents(): Flow> = messagesFlow.mapNotNull { + it.data as? PrivateEventMessage<*> +} + @RiskFeature("Use with caution") inline fun > Flow>.filterByChatEvent(): Flow = mapNotNull { if (it.chatEvent is T) it as? O else null @@ -51,6 +59,8 @@ inline fun Flow>.newChannelTitleEvents() = filterChannelEven inline fun FlowsUpdatesFilter.newChannelTitleEvents() = filterChannelEvents() inline fun Flow>.newChannelPinnedMessageEvents() = filterChannelEvents() inline fun FlowsUpdatesFilter.newChannelPinnedMessageEvents() = filterChannelEvents() +inline fun Flow>.successfulPaymentInChannelEvents() = filterChannelEvents() +inline fun FlowsUpdatesFilter.successfulPaymentInChannelEvents() = filterChannelEvents() inline fun Flow>.channelEvents() = filterChannelEvents() @RiskFeature("Use with caution") @@ -73,6 +83,8 @@ inline fun Flow>.newGroupPinnedMessageEvents() = filterGroup inline fun FlowsUpdatesFilter.newGroupPinnedMessageEvents() = filterGroupEvents() inline fun Flow>.proximityAlertTriggeredInGroupEvents() = filterGroupEvents() inline fun FlowsUpdatesFilter.proximityAlertTriggeredInGroupEvents() = filterGroupEvents() +inline fun Flow>.successfulPaymentInGroupEvents() = filterGroupEvents() +inline fun FlowsUpdatesFilter.successfulPaymentInGroupEvents() = filterGroupEvents() inline fun Flow>.groupEvents() = filterGroupEvents() @@ -96,4 +108,16 @@ inline fun Flow>.newSupergroupPinnedMessageEvents() = filter inline fun FlowsUpdatesFilter.newSupergroupPinnedMessageEvents() = filterSupergroupEvents() inline fun Flow>.proximityAlertTriggeredInSupergroupEvents() = filterSupergroupEvents() inline fun FlowsUpdatesFilter.proximityAlertTriggeredInSupergroupEvents() = filterSupergroupEvents() +inline fun Flow>.successfulPaymentInSupergroupEvents() = filterSupergroupEvents() +inline fun FlowsUpdatesFilter.successfulPaymentInSupergroupEvents() = filterSupergroupEvents() inline fun Flow>.supergroupEvents() = filterSupergroupEvents() + +@RiskFeature("Use with caution") +inline fun Flow>.filterPrivateEvents() = filterByChatEvent>() +@RiskFeature("Use with caution") +inline fun FlowsUpdatesFilter.filterPrivateEvents() = privateEvents().filterByChatEvent>() +inline fun Flow>.successfulPaymentInPrivateEvents() = filterPrivateEvents() +inline fun FlowsUpdatesFilter.successfulPaymentInPrivateEvents() = filterPrivateEvents() +inline fun Flow>.newPrivatePinnedMessageEvents() = filterPrivateEvents() +inline fun FlowsUpdatesFilter.newPrivatePinnedMessageEvents() = filterPrivateEvents() +inline fun Flow>.privateEvents() = filterPrivateEvents() From 3919359f79166400a8a431a7b123183ef08ebefd Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 3 Oct 2021 18:44:29 +0600 Subject: [PATCH 10/40] CommonGroupEvent -> PublicChatEvent --- CHANGELOG.md | 2 +- .../types/message/ChatEvents/DeleteChatPhoto.kt | 4 ++-- .../types/message/ChatEvents/LeftChatMember.kt | 4 ++-- .../types/message/ChatEvents/NewChatPhoto.kt | 4 ++-- .../types/message/ChatEvents/NewChatTitle.kt | 4 ++-- .../message/ChatEvents/ProximityAlertTriggered.kt | 4 ++-- .../message/ChatEvents/abstracts/CommonEvent.kt | 2 +- .../ChatEvents/abstracts/CommonGroupEvent.kt | 3 --- .../ChatEvents/abstracts/PublicChatEvent.kt | 3 +++ .../ChatEvents/abstracts/VoiceChatEvent.kt | 2 +- .../expectations/WaitEventAction.kt | 6 +++--- .../triggers_handling/EventTriggers.kt | 10 +++++----- .../inmo/tgbotapi/extensions/utils/ClassCasts.kt | 15 ++++++++++++--- 13 files changed, 36 insertions(+), 27 deletions(-) delete mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonGroupEvent.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/PublicChatEvent.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 4781e0e399..848faa2b00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ * `RowBuilder` and `MatrixBuilder` now are open and available for extending * `MatrixBuilder#matrix` will return read-only new list instead of original internal `mutMatrix` * Introduced new type of events `SuccessfulPaymentEvent` instead of putting of payment inside of message - * New type of events union: `CommonGroupEvent` + * New type of events union: `PublicChatEvent` * `Utils`: * Two new dsl: * `inlineKeyboard` for creating `InlineKeyboardMarkup` diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/DeleteChatPhoto.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/DeleteChatPhoto.kt index 88401cc144..5af2d1d718 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/DeleteChatPhoto.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/DeleteChatPhoto.kt @@ -1,5 +1,5 @@ package dev.inmo.tgbotapi.types.message.ChatEvents -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonGroupEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent -class DeleteChatPhoto: CommonGroupEvent +class DeleteChatPhoto: PublicChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt index 682ff86a91..a8b3bf1668 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt @@ -1,8 +1,8 @@ package dev.inmo.tgbotapi.types.message.ChatEvents import dev.inmo.tgbotapi.types.User -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonGroupEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent data class LeftChatMember( val user: User -) : CommonGroupEvent +) : PublicChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatPhoto.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatPhoto.kt index 34640e408c..9b89ff7702 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatPhoto.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatPhoto.kt @@ -1,8 +1,8 @@ package dev.inmo.tgbotapi.types.message.ChatEvents import dev.inmo.tgbotapi.types.files.Photo -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonGroupEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent data class NewChatPhoto( val photo: Photo -): CommonGroupEvent +): PublicChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatTitle.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatTitle.kt index 6ed5a469f6..0fbf9001b6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatTitle.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/NewChatTitle.kt @@ -1,7 +1,7 @@ package dev.inmo.tgbotapi.types.message.ChatEvents -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonGroupEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent data class NewChatTitle( val title: String -): CommonGroupEvent +): PublicChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/ProximityAlertTriggered.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/ProximityAlertTriggered.kt index 25604f2238..326385a38a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/ProximityAlertTriggered.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/ProximityAlertTriggered.kt @@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.message.ChatEvents import dev.inmo.tgbotapi.types.Meters import dev.inmo.tgbotapi.types.User -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonGroupEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent import kotlinx.serialization.Serializable /** @@ -14,4 +14,4 @@ data class ProximityAlertTriggered( val traveler: User, val watcher: User, val distance: Meters -) : CommonGroupEvent +) : PublicChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonEvent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonEvent.kt index 0228be76e6..d40884f22e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonEvent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonEvent.kt @@ -1,3 +1,3 @@ package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts -interface CommonEvent : CommonGroupEvent, PrivateEvent +interface CommonEvent : PublicChatEvent, PrivateEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonGroupEvent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonGroupEvent.kt deleted file mode 100644 index 6432af9b0e..0000000000 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonGroupEvent.kt +++ /dev/null @@ -1,3 +0,0 @@ -package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts - -interface CommonGroupEvent : ChannelEvent, GroupEvent, SupergroupEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/PublicChatEvent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/PublicChatEvent.kt new file mode 100644 index 0000000000..04aa21ffd0 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/PublicChatEvent.kt @@ -0,0 +1,3 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts + +interface PublicChatEvent : ChannelEvent, GroupEvent, SupergroupEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt index 33cf8c7a99..f06f52d765 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt @@ -1,3 +1,3 @@ package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts -interface VoiceChatEvent : CommonGroupEvent +interface VoiceChatEvent : PublicChatEvent diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt index 96b5de3c83..81672cc796 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt @@ -127,12 +127,12 @@ suspend fun BehaviourContext.waitMessageAutoDeleteTimerChangedEvents( ) = waitEvents(count, initRequest, errorFactory, filter, mapper) -suspend fun BehaviourContext.waitCommonGroupEvents( +suspend fun BehaviourContext.waitPublicChatEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, - filter: SimpleFilter>? = null, - mapper: EventMessageToEventMapper? = null + filter: SimpleFilter>? = null, + mapper: EventMessageToEventMapper? = null ) = waitEvents(count, initRequest, errorFactory, filter, mapper) suspend fun BehaviourContext.waitCommonEvents( initRequest: Request<*>? = null, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt index 1ee51b3c6c..00d4f6e447 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt @@ -189,11 +189,11 @@ suspend fun BehaviourContext.onMessageAutoDeleteTimerChangedEvent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onCommonGroupEvent( - initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> +suspend fun BehaviourContext.onPublicChatEvent( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: BehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt index 61e18f89c6..ad0e69f1f3 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -3043,13 +3043,22 @@ inline fun ChatEvent.asChannelEvent(): ChannelEvent? = this as? ChannelEvent inline fun ChatEvent.requireChannelEvent(): ChannelEvent = this as ChannelEvent @PreviewFeature -inline fun ChatEvent.whenCommonEvent(block: (CommonGroupEvent) -> T) = asCommonEvent() ?.let(block) +inline fun ChatEvent.whenPublicChatEvent(block: (PublicChatEvent) -> T) = asPublicChatEvent() ?.let(block) @PreviewFeature -inline fun ChatEvent.asCommonEvent(): CommonGroupEvent? = this as? CommonGroupEvent +inline fun ChatEvent.asPublicChatEvent(): PublicChatEvent? = this as? PublicChatEvent @PreviewFeature -inline fun ChatEvent.requireCommonEvent(): CommonGroupEvent = this as CommonGroupEvent +inline fun ChatEvent.requirePublicChatEvent(): PublicChatEvent = this as PublicChatEvent + +@PreviewFeature +inline fun ChatEvent.whenCommonEvent(block: (CommonEvent) -> T) = asCommonEvent() ?.let(block) + +@PreviewFeature +inline fun ChatEvent.asCommonEvent(): CommonEvent? = this as? CommonEvent + +@PreviewFeature +inline fun ChatEvent.requireCommonEvent(): CommonEvent = this as CommonEvent @PreviewFeature inline fun ChatEvent.whenGroupEvent(block: (GroupEvent) -> T) = asGroupEvent() ?.let(block) From 0cce72de8d1850ece870c521b8db7f08ddc46c0b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 3 Oct 2021 20:37:14 +0600 Subject: [PATCH 11/40] cover all updates in behaviour builder --- CHANGELOG.md | 5 + .../expectations/WaitChosenInlineResult.kt | 82 ++++++++++++++++ .../expectations/WaitEditedContent.kt | 3 + .../expectations/WaitPollAnswers.kt | 68 ++++++++++++++ .../expectations/WaitPollUpdates.kt | 90 ++++++++++++++++++ .../expectations/WaitPreCheckoutQuery.kt | 51 ++++++++++ .../expectations/WaitShippingQuery.kt | 49 ++++++++++ .../filters/MessageFilterByChat.kt | 14 +++ .../CallbackQueryTriggers.kt | 8 +- .../ChosenInlineResultTriggers.kt | 93 +++++++++++++++++++ .../triggers_handling/PollAnswersTriggers.kt | 44 +++++++++ .../triggers_handling/PollUpdatesTriggers.kt | 91 ++++++++++++++++++ .../PreCheckoutQueryTriggers.kt | 36 +++++++ .../ShippingQueryTriggers.kt | 35 +++++++ .../ChosenInlineResultsMarkerFactories.kt | 8 ++ .../marker_factories/PollMarkerFactories.kt | 12 +++ ...erFactories.kt => QueryMarkerFactories.kt} | 10 ++ 17 files changed, 695 insertions(+), 4 deletions(-) create mode 100644 tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt create mode 100644 tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt create mode 100644 tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt create mode 100644 tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt create mode 100644 tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt create mode 100644 tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChosenInlineResultTriggers.kt create mode 100644 tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollAnswersTriggers.kt create mode 100644 tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt create mode 100644 tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PreCheckoutQueryTriggers.kt create mode 100644 tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ShippingQueryTriggers.kt create mode 100644 tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChosenInlineResultsMarkerFactories.kt create mode 100644 tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/PollMarkerFactories.kt rename tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/{CallbackQueryMarkerFactories.kt => QueryMarkerFactories.kt} (58%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 848faa2b00..9f81ed47f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,11 @@ * Two new dsl: * `inlineKeyboard` for creating `InlineKeyboardMarkup` * `replyKeyboard` for creating `ReplyKeyboardMarkup` +* `Behaviour Builder`: + * New expecters and waiters: + * `waitShippingQueries`/`onShippingQuery` + * `waitPreCheckoutQueries`/`onPreCheckoutQuery` + * `waitChosenInlineResult`/`onChosenInlineResult` ## 0.35.9 diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt new file mode 100644 index 0000000000..3b277f24f6 --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt @@ -0,0 +1,82 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations + +import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter +import dev.inmo.tgbotapi.extensions.utils.* +import dev.inmo.tgbotapi.requests.abstracts.Request +import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.* +import dev.inmo.tgbotapi.types.polls.* +import kotlinx.coroutines.flow.toList + +typealias ChosenInlineResultMapper = suspend T.() -> T? + +private suspend fun BehaviourContext.waitChosenInlineResultsUpdates( + count: Int = 1, + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + filter: SimpleFilter? = null, + mapper: suspend ChosenInlineResult.() -> O? +): List = expectFlow( + initRequest, + count, + errorFactory +) { + val data = it.asChosenInlineResultUpdate() ?.data + if (data != null && (filter == null || filter(data))) { + data.mapper().let(::listOfNotNull) + } else { + emptyList() + } +}.toList().toList() + + +private suspend inline fun BehaviourContext.waitChosenInlineResults( + count: Int = 1, + initRequest: Request<*>? = null, + noinline errorFactory: NullableRequestBuilder<*> = { null }, + noinline filter: SimpleFilter? = null, + noinline mapper: ChosenInlineResultMapper? = null +) : List = this@waitChosenInlineResults.waitChosenInlineResultsUpdates( + count, + initRequest, + errorFactory, + filter ?.let { + { + (it as? T) ?.let { filter(it) } == true + } + } +) { + if (this is T) { + if (mapper == null) { + this + } else { + mapper(this) + } + } else { + null + } +} + +suspend fun BehaviourContext.waitChosenInlineResult( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: SimpleFilter? = null, + mapper: ChosenInlineResultMapper? = null +) = waitChosenInlineResults(count, initRequest, errorFactory, filter, mapper) + +suspend fun BehaviourContext.waitLocationChosenInlineResult( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: SimpleFilter? = null, + mapper: PollMapper? = null +) = waitChosenInlineResults(count, initRequest, errorFactory, filter, mapper) + +suspend fun BehaviourContext.waitBaseChosenInlineResult( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: SimpleFilter? = null, + mapper: PollMapper? = null +) = waitChosenInlineResults(count, initRequest, errorFactory, filter, mapper) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt index e00e832c0d..fa5e162a68 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt @@ -119,6 +119,9 @@ suspend fun BehaviourContext.waitEditedStaticLocation( filter: SimpleFilter>? = null, mapper: CommonMessageToContentMapper? = null ) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper) +/** + * This + */ suspend fun BehaviourContext.waitEditedPoll( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt new file mode 100644 index 0000000000..718bdd4c89 --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt @@ -0,0 +1,68 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations + +import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter +import dev.inmo.tgbotapi.extensions.utils.* +import dev.inmo.tgbotapi.requests.abstracts.Request +import dev.inmo.tgbotapi.types.polls.* +import kotlinx.coroutines.flow.toList + +typealias PollAnswerMapper = suspend PollAnswer.() -> PollAnswer? + +private suspend fun BehaviourContext.waitPollsAnswers( + count: Int = 1, + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + filter: SimpleFilter? = null, + mapper: suspend PollAnswer.() -> O? +): List = expectFlow( + initRequest, + count, + errorFactory +) { + val data = it.asPollAnswerUpdate() ?.data + if (data != null && (filter == null || filter(data))) { + data.mapper().let(::listOfNotNull) + } else { + emptyList() + } +}.toList().toList() + + +private suspend inline fun BehaviourContext.waitPollAnswers( + count: Int = 1, + initRequest: Request<*>? = null, + noinline errorFactory: NullableRequestBuilder<*> = { null }, + noinline filter: SimpleFilter? = null, + noinline mapper: PollAnswerMapper? = null +) : List = this@waitPollAnswers.waitPollsAnswers( + count, + initRequest, + errorFactory, + filter ?.let { + { + (it as? PollAnswer) ?.let { filter(it) } == true + } + } +) { + if (this is PollAnswer) { + if (mapper == null) { + this + } else { + mapper(this) + } + } else { + null + } +} + +/** + * This wait will be triggered only for stopped polls and polls, which are sent by the bot + */ +suspend fun BehaviourContext.waitPollAnswers( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: SimpleFilter? = null, + mapper: PollAnswerMapper? = null +) = waitPollAnswers(count, initRequest, errorFactory, filter, mapper) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt new file mode 100644 index 0000000000..fd1632107c --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt @@ -0,0 +1,90 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations + +import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter +import dev.inmo.tgbotapi.extensions.utils.* +import dev.inmo.tgbotapi.requests.abstracts.Request +import dev.inmo.tgbotapi.types.polls.* +import kotlinx.coroutines.flow.toList + +typealias PollMapper = suspend T.() -> T? + +private suspend fun BehaviourContext.waitPollsUpdates( + count: Int = 1, + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + filter: SimpleFilter? = null, + mapper: suspend Poll.() -> O? +): List = expectFlow( + initRequest, + count, + errorFactory +) { + val data = it.asPollUpdate() ?.data + if (data != null && (filter == null || filter(data))) { + data.mapper().let(::listOfNotNull) + } else { + emptyList() + } +}.toList().toList() + + +private suspend inline fun BehaviourContext.waitPolls( + count: Int = 1, + initRequest: Request<*>? = null, + noinline errorFactory: NullableRequestBuilder<*> = { null }, + noinline filter: SimpleFilter? = null, + noinline mapper: PollMapper? = null +) : List = this@waitPolls.waitPollsUpdates( + count, + initRequest, + errorFactory, + filter ?.let { + { + (it as? T) ?.let { filter(it) } == true + } + } +) { + if (this is T) { + if (mapper == null) { + this + } else { + mapper(this) + } + } else { + null + } +} + +/** + * This wait will be triggered only for stopped polls and polls, which are sent by the bot + */ +suspend fun BehaviourContext.waitPollsUpdates( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: SimpleFilter? = null, + mapper: PollMapper? = null +) = waitPolls(count, initRequest, errorFactory, filter, mapper) + +/** + * This wait will be triggered only for stopped polls and polls, which are sent by the bot + */ +suspend fun BehaviourContext.waitQuizPollsUpdates( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: SimpleFilter? = null, + mapper: PollMapper? = null +) = waitPolls(count, initRequest, errorFactory, filter, mapper) + +/** + * This wait will be triggered only for stopped polls and polls, which are sent by the bot + */ +suspend fun BehaviourContext.waitRegularPollsUpdates( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: SimpleFilter? = null, + mapper: PollMapper? = null +) = waitPolls(count, initRequest, errorFactory, filter, mapper) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt new file mode 100644 index 0000000000..d2c8cf9612 --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt @@ -0,0 +1,51 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations + +import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter +import dev.inmo.tgbotapi.extensions.utils.asPreCheckoutQueryUpdate +import dev.inmo.tgbotapi.extensions.utils.asShippingQueryUpdate +import dev.inmo.tgbotapi.requests.abstracts.Request +import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery +import dev.inmo.tgbotapi.types.payments.ShippingQuery +import kotlinx.coroutines.flow.toList + +typealias PreCheckoutQueryMapper = suspend PreCheckoutQuery.() -> PreCheckoutQuery? + +private suspend fun BehaviourContext.waitPreCheckoutQueries( + count: Int = 1, + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + filter: SimpleFilter? = null, + mapper: suspend PreCheckoutQuery.() -> O? +): List = expectFlow( + initRequest, + count, + errorFactory +) { + val data = it.asPreCheckoutQueryUpdate() ?.data + if (data != null && (filter == null || filter(data))) { + data.mapper().let(::listOfNotNull) + } else { + emptyList() + } +}.toList().toList() + + +suspend fun BehaviourContext.waitPreCheckoutQueries( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: SimpleFilter? = null, + mapper: PreCheckoutQueryMapper? = null +) : List = waitPreCheckoutQueries( + count, + initRequest, + errorFactory, + filter +) { + if (mapper == null) { + this + } else { + mapper(this) + } +} diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt new file mode 100644 index 0000000000..3ec4382a00 --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt @@ -0,0 +1,49 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations + +import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter +import dev.inmo.tgbotapi.extensions.utils.asShippingQueryUpdate +import dev.inmo.tgbotapi.requests.abstracts.Request +import dev.inmo.tgbotapi.types.payments.ShippingQuery +import kotlinx.coroutines.flow.toList + +typealias ShippingQueryMapper = suspend ShippingQuery.() -> ShippingQuery? + +private suspend fun BehaviourContext.waitShippingQueries( + count: Int = 1, + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + filter: SimpleFilter? = null, + mapper: suspend ShippingQuery.() -> O? +): List = expectFlow( + initRequest, + count, + errorFactory +) { + val data = it.asShippingQueryUpdate() ?.data + if (data != null && (filter == null || filter(data))) { + data.mapper().let(::listOfNotNull) + } else { + emptyList() + } +}.toList().toList() + + +suspend fun BehaviourContext.waitShippingQueries( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: SimpleFilter? = null, + mapper: ShippingQueryMapper? = null +) : List = waitShippingQueries( + count, + initRequest, + errorFactory, + filter +) { + if (mapper == null) { + this + } else { + mapper(this) + } +} diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChat.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChat.kt index 67c2a187d3..370db3c006 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChat.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChat.kt @@ -6,6 +6,8 @@ import dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery import dev.inmo.tgbotapi.types.ChatMemberUpdated import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery +import dev.inmo.tgbotapi.types.payments.ShippingQuery import dev.inmo.tgbotapi.types.update.abstracts.Update /** @@ -28,6 +30,18 @@ val MessagesFilterByChat: BehaviourContextAndTwoTypesReceiver = { query, update -> update.sourceChat() ?.id == query.user.id } +/** + * Allow only updates from the same user as base [ShippingQuery.user] + */ +val ShippingQueryFilterByUser: BehaviourContextAndTwoTypesReceiver = { query, update -> + update.sourceChat() ?.id == query.user.id +} +/** + * Allow only updates from the same user as base [ShippingQuery.user] + */ +val PreCheckoutQueryFilterByUser: BehaviourContextAndTwoTypesReceiver = { query, update -> + update.sourceChat() ?.id == query.user.id +} /** * Allow only updates from the same user as base [InlineQuery.from] */ diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt index dd972014fd..d35f1e27da 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt @@ -37,7 +37,7 @@ suspend fun BehaviourContext.onDataCallbackQuery( subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, scenarioReceiver: BehaviourContextAndTypeReceiver -) = onCallbackQuery( +) = onPollAnswered( initialFilter, subcontextUpdatesFilter, markerFactory, @@ -61,7 +61,7 @@ suspend fun BehaviourContext.onGameShortNameCallbackQuery( subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, scenarioReceiver: BehaviourContextAndTypeReceiver -) = onCallbackQuery( +) = onPollAnswered( initialFilter, subcontextUpdatesFilter, markerFactory, @@ -85,7 +85,7 @@ suspend fun BehaviourContext.onInlineMessageIdCallbackQuery( subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, scenarioReceiver: BehaviourContextAndTypeReceiver -) = onCallbackQuery( +) = onPollAnswered( initialFilter, subcontextUpdatesFilter, markerFactory, @@ -157,7 +157,7 @@ suspend fun BehaviourContext.onMessageCallbackQuery( subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, scenarioReceiver: BehaviourContextAndTypeReceiver -) = onCallbackQuery( +) = onPollAnswered( initialFilter, subcontextUpdatesFilter, markerFactory, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChosenInlineResultTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChosenInlineResultTriggers.kt new file mode 100644 index 0000000000..5102f9c356 --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChosenInlineResultTriggers.kt @@ -0,0 +1,93 @@ +@file:Suppress("unused") + +package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling + +import dev.inmo.tgbotapi.extensions.behaviour_builder.* +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.* +import dev.inmo.tgbotapi.extensions.utils.asChosenInlineResultUpdate +import dev.inmo.tgbotapi.extensions.utils.asPollUpdate +import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.* +import dev.inmo.tgbotapi.types.polls.* +import dev.inmo.tgbotapi.types.update.abstracts.Update + +internal suspend inline fun BehaviourContext.onChosenInlineResultBase( + noinline initialFilter: SimpleFilter? = null, + noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByUserIdChosenInlineResultMarkerFactory, + noinline scenarioReceiver: BehaviourContextAndTypeReceiver +) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { + (it.asChosenInlineResultUpdate() ?.data as? T) ?.let(::listOfNotNull) +} + +/** + * @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 BehaviourContext.onChosenInlineResult( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByUserIdChosenInlineResultMarkerFactory, + scenarioReceiver: BehaviourContextAndTypeReceiver +) = onChosenInlineResultBase( + 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 BehaviourContext.onLocationChosenInlineResult( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByUserIdChosenInlineResultMarkerFactory, + scenarioReceiver: BehaviourContextAndTypeReceiver +) = onChosenInlineResultBase( + 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 BehaviourContext.onBaseChosenInlineResult( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByUserIdChosenInlineResultMarkerFactory, + scenarioReceiver: BehaviourContextAndTypeReceiver +) = onChosenInlineResultBase( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollAnswersTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollAnswersTriggers.kt new file mode 100644 index 0000000000..c8bfa9d6b3 --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollAnswersTriggers.kt @@ -0,0 +1,44 @@ +@file:Suppress("unused") + +package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling + +import dev.inmo.tgbotapi.extensions.behaviour_builder.* +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.* +import dev.inmo.tgbotapi.extensions.utils.asPollAnswerUpdate +import dev.inmo.tgbotapi.extensions.utils.asPollUpdate +import dev.inmo.tgbotapi.types.polls.* +import dev.inmo.tgbotapi.types.update.abstracts.Update + +internal suspend inline fun BehaviourContext.onPollAnswered( + noinline initialFilter: SimpleFilter? = null, + noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByIdPollAnswerMarkerFactory, + noinline scenarioReceiver: BehaviourContextAndTypeReceiver +) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { + (it.asPollAnswerUpdate() ?.data) ?.let(::listOfNotNull) +} + +/** + * @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 BehaviourContext.onPollAnswer( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByIdPollAnswerMarkerFactory, + scenarioReceiver: BehaviourContextAndTypeReceiver +) = onPollAnswered( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt new file mode 100644 index 0000000000..816848f547 --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt @@ -0,0 +1,91 @@ +@file:Suppress("unused") + +package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling + +import dev.inmo.tgbotapi.extensions.behaviour_builder.* +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.* +import dev.inmo.tgbotapi.extensions.utils.asPollUpdate +import dev.inmo.tgbotapi.types.polls.* +import dev.inmo.tgbotapi.types.update.abstracts.Update + +internal suspend inline fun BehaviourContext.onPollBase( + noinline initialFilter: SimpleFilter? = null, + noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByIdPollMarkerFactory, + noinline scenarioReceiver: BehaviourContextAndTypeReceiver +) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { + (it.asPollUpdate() ?.data as? T) ?.let(::listOfNotNull) +} + +/** + * @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 BehaviourContext.onPoll( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByIdPollMarkerFactory, + scenarioReceiver: BehaviourContextAndTypeReceiver +) = onPollBase( + 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 BehaviourContext.onRegularPoll( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByIdPollMarkerFactory, + scenarioReceiver: BehaviourContextAndTypeReceiver +) = onPollBase( + 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 BehaviourContext.onQuizPoll( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByIdPollMarkerFactory, + scenarioReceiver: BehaviourContextAndTypeReceiver +) = onPollBase( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PreCheckoutQueryTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PreCheckoutQueryTriggers.kt new file mode 100644 index 0000000000..e0a6be1a2f --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PreCheckoutQueryTriggers.kt @@ -0,0 +1,36 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling + +import dev.inmo.tgbotapi.extensions.behaviour_builder.* +import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.* +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.* +import dev.inmo.tgbotapi.extensions.utils.asPreCheckoutQueryUpdate +import dev.inmo.tgbotapi.extensions.utils.asShippingQueryUpdate +import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery +import dev.inmo.tgbotapi.types.payments.ShippingQuery +import dev.inmo.tgbotapi.types.update.abstracts.Update + +/** + * Please, remember that you must answer to this type of queries using something like + * [dev.inmo.tgbotapi.extensions.api.answers.payments.answerPreCheckoutQueryOk] or + * [dev.inmo.tgbotapi.extensions.api.answers.payments.answerPreCheckoutQueryError] + * + * @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 BehaviourContext.onPreCheckoutQuery( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = PreCheckoutQueryFilterByUser, + markerFactory: MarkerFactory = ByUserPreCheckoutQueryMarkerFactory, + scenarioReceiver: BehaviourContextAndTypeReceiver +) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { + (it.asPreCheckoutQueryUpdate() ?.data) ?.let(::listOfNotNull) +} diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ShippingQueryTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ShippingQueryTriggers.kt new file mode 100644 index 0000000000..559be79250 --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ShippingQueryTriggers.kt @@ -0,0 +1,35 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling + +import dev.inmo.tgbotapi.extensions.behaviour_builder.* +import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CallbackQueryFilterByUser +import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.ShippingQueryFilterByUser +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.* +import dev.inmo.tgbotapi.extensions.utils.asShippingQueryUpdate +import dev.inmo.tgbotapi.types.payments.ShippingQuery +import dev.inmo.tgbotapi.types.update.abstracts.Update + +/** + * Please, remember that you must answer to this type of queries using something like + * [dev.inmo.tgbotapi.extensions.api.answers.payments.answerShippingQueryOk] or + * [dev.inmo.tgbotapi.extensions.api.answers.payments.answerShippingQueryError] + * + * @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 BehaviourContext.onShippingQuery( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = ShippingQueryFilterByUser, + markerFactory: MarkerFactory = ByUserShippingQueryMarkerFactory, + scenarioReceiver: BehaviourContextAndTypeReceiver +) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { + (it.asShippingQueryUpdate() ?.data) ?.let(::listOfNotNull) +} diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChosenInlineResultsMarkerFactories.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChosenInlineResultsMarkerFactories.kt new file mode 100644 index 0000000000..f96c321ee7 --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChosenInlineResultsMarkerFactories.kt @@ -0,0 +1,8 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories + +import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.ChosenInlineResult + + +object ByUserIdChosenInlineResultMarkerFactory : MarkerFactory { + override suspend fun invoke(data: ChosenInlineResult) = data.user.id +} diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/PollMarkerFactories.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/PollMarkerFactories.kt new file mode 100644 index 0000000000..d9ada9782d --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/PollMarkerFactories.kt @@ -0,0 +1,12 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories + +import dev.inmo.tgbotapi.types.polls.Poll +import dev.inmo.tgbotapi.types.polls.PollAnswer + +object ByIdPollMarkerFactory : MarkerFactory { + override suspend fun invoke(data: Poll) = data.id +} + +object ByIdPollAnswerMarkerFactory : MarkerFactory { + override suspend fun invoke(data: PollAnswer) = data.pollId +} diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/CallbackQueryMarkerFactories.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/QueryMarkerFactories.kt similarity index 58% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/CallbackQueryMarkerFactories.kt rename to tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/QueryMarkerFactories.kt index 64041bb198..ccb7cd7734 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/CallbackQueryMarkerFactories.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/QueryMarkerFactories.kt @@ -1,11 +1,21 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories import dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery +import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery +import dev.inmo.tgbotapi.types.payments.ShippingQuery object ByUserCallbackQueryMarkerFactory : MarkerFactory { override suspend fun invoke(data: CallbackQuery) = data.user } +object ByUserShippingQueryMarkerFactory : MarkerFactory { + override suspend fun invoke(data: ShippingQuery) = data.user +} + +object ByUserPreCheckoutQueryMarkerFactory : MarkerFactory { + override suspend fun invoke(data: PreCheckoutQuery) = data.user +} + object ByIdCallbackQueryMarkerFactory : MarkerFactory { override suspend fun invoke(data: CallbackQuery) = data.id } From 5831cc6d37819f5fe2ae42c9d2cf9a3706edf6ca Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 3 Oct 2021 20:40:42 +0600 Subject: [PATCH 12/40] hotfix for autorenames -.- --- .../triggers_handling/CallbackQueryTriggers.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt index d35f1e27da..dd972014fd 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt @@ -37,7 +37,7 @@ suspend fun BehaviourContext.onDataCallbackQuery( subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, scenarioReceiver: BehaviourContextAndTypeReceiver -) = onPollAnswered( +) = onCallbackQuery( initialFilter, subcontextUpdatesFilter, markerFactory, @@ -61,7 +61,7 @@ suspend fun BehaviourContext.onGameShortNameCallbackQuery( subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, scenarioReceiver: BehaviourContextAndTypeReceiver -) = onPollAnswered( +) = onCallbackQuery( initialFilter, subcontextUpdatesFilter, markerFactory, @@ -85,7 +85,7 @@ suspend fun BehaviourContext.onInlineMessageIdCallbackQuery( subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, scenarioReceiver: BehaviourContextAndTypeReceiver -) = onPollAnswered( +) = onCallbackQuery( initialFilter, subcontextUpdatesFilter, markerFactory, @@ -157,7 +157,7 @@ suspend fun BehaviourContext.onMessageCallbackQuery( subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, scenarioReceiver: BehaviourContextAndTypeReceiver -) = onPollAnswered( +) = onCallbackQuery( initialFilter, subcontextUpdatesFilter, markerFactory, From 834e31906a4661a823c78cde77434444b5164be0 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 3 Oct 2021 21:12:17 +0600 Subject: [PATCH 13/40] deprecate onEditPoll and rename poll updates triggers --- .../triggers_handling/EditedContentTriggers.kt | 13 +------------ .../triggers_handling/PollUpdatesTriggers.kt | 14 +++++++------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt index c5ebda5b65..dbbb7bd43b 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt @@ -166,18 +166,7 @@ suspend fun BehaviourContext.onEditedLocation( 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 - */ +@Deprecated("Potentially, this trigger will never be used. Use `onPollUpdated` instead") suspend fun BehaviourContext.onEditedPoll( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt index 816848f547..f2a3782636 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt @@ -9,7 +9,7 @@ import dev.inmo.tgbotapi.extensions.utils.asPollUpdate import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.types.update.abstracts.Update -internal suspend inline fun BehaviourContext.onPollBase( +internal suspend inline fun BehaviourContext.onPollUpdatedBase( noinline initialFilter: SimpleFilter? = null, noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, markerFactory: MarkerFactory = ByIdPollMarkerFactory, @@ -30,12 +30,12 @@ internal suspend inline fun BehaviourContext.onPollBase( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onPoll( +suspend fun BehaviourContext.onPollUpdated( initialFilter: SimpleFilter? = null, subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, markerFactory: MarkerFactory = ByIdPollMarkerFactory, scenarioReceiver: BehaviourContextAndTypeReceiver -) = onPollBase( +) = onPollUpdatedBase( initialFilter, subcontextUpdatesFilter, markerFactory, @@ -54,12 +54,12 @@ suspend fun BehaviourContext.onPoll( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onRegularPoll( +suspend fun BehaviourContext.onRegularPollUpdated( initialFilter: SimpleFilter? = null, subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, markerFactory: MarkerFactory = ByIdPollMarkerFactory, scenarioReceiver: BehaviourContextAndTypeReceiver -) = onPollBase( +) = onPollUpdatedBase( initialFilter, subcontextUpdatesFilter, markerFactory, @@ -78,12 +78,12 @@ suspend fun BehaviourContext.onRegularPoll( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onQuizPoll( +suspend fun BehaviourContext.onQuizPollUpdated( initialFilter: SimpleFilter? = null, subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, markerFactory: MarkerFactory = ByIdPollMarkerFactory, scenarioReceiver: BehaviourContextAndTypeReceiver -) = onPollBase( +) = onPollUpdatedBase( initialFilter, subcontextUpdatesFilter, markerFactory, From e1e2b93269c496ccd8a7f40a92575628afeaf231 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 3 Oct 2021 21:14:28 +0600 Subject: [PATCH 14/40] deprecate waitEditedPoll and rename poll updates waiters --- .../behaviour_builder/expectations/WaitEditedContent.kt | 4 +--- .../behaviour_builder/expectations/WaitPollUpdates.kt | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt index fa5e162a68..8489961012 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt @@ -119,9 +119,7 @@ suspend fun BehaviourContext.waitEditedStaticLocation( filter: SimpleFilter>? = null, mapper: CommonMessageToContentMapper? = null ) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper) -/** - * This - */ +@Deprecated("Potentially, this trigger will never be used. Use `waitPollUpdates` instead") suspend fun BehaviourContext.waitEditedPoll( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt index fd1632107c..0aebcb4acd 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt @@ -59,7 +59,7 @@ private suspend inline fun BehaviourContext.waitPolls( /** * This wait will be triggered only for stopped polls and polls, which are sent by the bot */ -suspend fun BehaviourContext.waitPollsUpdates( +suspend fun BehaviourContext.waitPollUpdates( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, @@ -70,7 +70,7 @@ suspend fun BehaviourContext.waitPollsUpdates( /** * This wait will be triggered only for stopped polls and polls, which are sent by the bot */ -suspend fun BehaviourContext.waitQuizPollsUpdates( +suspend fun BehaviourContext.waitQuizPollUpdates( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, @@ -81,7 +81,7 @@ suspend fun BehaviourContext.waitQuizPollsUpdates( /** * This wait will be triggered only for stopped polls and polls, which are sent by the bot */ -suspend fun BehaviourContext.waitRegularPollsUpdates( +suspend fun BehaviourContext.waitRegularPollUpdates( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, count: Int = 1, From b6e72c2399b26650bf75c3b74218ed6924858ad1 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 3 Oct 2021 21:16:31 +0600 Subject: [PATCH 15/40] rename poll updates triggers and fill changelog --- CHANGELOG.md | 1 + .../triggers_handling/PollUpdatesTriggers.kt | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f81ed47f8..da5422ccdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ * `waitShippingQueries`/`onShippingQuery` * `waitPreCheckoutQueries`/`onPreCheckoutQuery` * `waitChosenInlineResult`/`onChosenInlineResult` + * `waitPollUpdates`/`onPollUpdates` ## 0.35.9 diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt index f2a3782636..570d05d175 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt @@ -30,7 +30,7 @@ internal suspend inline fun BehaviourContext.onPollUpdatedBas * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onPollUpdated( +suspend fun BehaviourContext.onPollUpdates( initialFilter: SimpleFilter? = null, subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, markerFactory: MarkerFactory = ByIdPollMarkerFactory, @@ -54,7 +54,7 @@ suspend fun BehaviourContext.onPollUpdated( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onRegularPollUpdated( +suspend fun BehaviourContext.onRegularPollUpdates( initialFilter: SimpleFilter? = null, subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, markerFactory: MarkerFactory = ByIdPollMarkerFactory, @@ -78,7 +78,7 @@ suspend fun BehaviourContext.onRegularPollUpdated( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onQuizPollUpdated( +suspend fun BehaviourContext.onQuizPollUpdates( initialFilter: SimpleFilter? = null, subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, markerFactory: MarkerFactory = ByIdPollMarkerFactory, From 016fc81b7174a7ea2403d9573c49ecee7b1f20fb Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 4 Oct 2021 15:56:19 +0600 Subject: [PATCH 16/40] update microutils --- CHANGELOG.md | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da5422ccdc..94817d3e08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ * `Version`: * `Serialization`: `1.2.2` -> `1.3.0` * `Ktor`: `1.6.3` -> `1.6.4` - * `MicroUtils`: `0.5.28` -> `0.5.31` + * `MicroUtils`: `0.5.28` -> `0.6.0` * `Core`: * `PayInlineKeyboardButton#pay` now is deprecated * `RowBuilder` and `MatrixBuilder` now are open and available for extending diff --git a/gradle.properties b/gradle.properties index 7b05ee0f74..d1b55215d2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ klock_version=2.4.3 uuid_version=0.3.1 ktor_version=1.6.4 -micro_utils_version=0.5.31 +micro_utils_version=0.6.0 javax_activation_version=1.1.1 From 2e560db865a2fc5ef5a44a4231646315b3d2f088 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 5 Oct 2021 17:08:19 +0600 Subject: [PATCH 17/40] update microutils --- CHANGELOG.md | 3 +-- gradle.properties | 2 +- tgbotapi.core/build.gradle | 3 --- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94817d3e08..833bb37b17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,7 @@ * `Common`: * `Version`: * `Serialization`: `1.2.2` -> `1.3.0` - * `Ktor`: `1.6.3` -> `1.6.4` - * `MicroUtils`: `0.5.28` -> `0.6.0` + * `MicroUtils`: `0.5.28` -> `0.7.0` * `Core`: * `PayInlineKeyboardButton#pay` now is deprecated * `RowBuilder` and `MatrixBuilder` now are open and available for extending diff --git a/gradle.properties b/gradle.properties index d1b55215d2..ea3a8362c9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ klock_version=2.4.3 uuid_version=0.3.1 ktor_version=1.6.4 -micro_utils_version=0.6.0 +micro_utils_version=0.7.0 javax_activation_version=1.1.1 diff --git a/tgbotapi.core/build.gradle b/tgbotapi.core/build.gradle index c8e8861075..01ba2f9b9d 100644 --- a/tgbotapi.core/build.gradle +++ b/tgbotapi.core/build.gradle @@ -1,7 +1,6 @@ buildscript { repositories { mavenLocal() - jcenter() mavenCentral() } @@ -23,9 +22,7 @@ apply from: "publish.gradle" repositories { mavenLocal() - jcenter() mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } } kotlin { From 22e71354dd279b6d2bc6ad400059f80bd9f79c5e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 5 Oct 2021 17:27:50 +0600 Subject: [PATCH 18/40] update dokka --- docs/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/gradle.properties b/docs/gradle.properties index f0f52e73e4..22e7f6a0f9 100644 --- a/docs/gradle.properties +++ b/docs/gradle.properties @@ -1,3 +1,3 @@ -dokka_version=1.5.30 +dokka_version=1.5.31 org.gradle.jvmargs=-Xmx1024m From 2a33b22afb3253e98157b1f8a8844602602c8189 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 13 Oct 2021 14:22:01 +0600 Subject: [PATCH 19/40] BehaviourBuilder FSM extension --- CHANGELOG.md | 3 + TelegramBotAPI.drawio | 2 +- build.gradle | 1 - docs/build.gradle | 2 - gradle.properties | 4 +- .../TelegramBotAPI-libraries-hierarchy.svg | 4 +- settings.gradle | 2 +- tgbotapi.core/README.md | 2 +- .../updateshandlers/FlowsUpdatesFilter.kt | 77 ++++++---- tgbotapi.extensions.api/README.md | 2 +- tgbotapi.extensions.api/build.gradle | 3 - .../README.md | 3 + .../build.gradle | 50 ++++++ .../mpp_publish_template.kpsb | 1 + .../publish.gradle | 69 +++++++++ .../BehaviourContextWithFSM.kt | 100 ++++++++++++ .../BehaviourContextWithFSMBuilder.kt | 107 +++++++++++++ .../BehaviourWithFSMStateHandler.kt | 7 + .../BehaviourWithFSMStateHandlerHolder.kt | 52 +++++++ .../build.gradle | 3 - .../behaviour_builder/BehaviourContext.kt | 125 ++++++++++----- .../behaviour_builder/expectations/Base.kt | 9 +- .../expectations/WaitContent.kt | 7 +- .../CallbackQueryTriggers.kt | 60 ++++---- .../ChatMemberUpdatedTriggers.kt | 30 ++-- .../ChosenInlineResultTriggers.kt | 24 +-- .../triggers_handling/CommandHandling.kt | 48 +++--- .../triggers_handling/ContentTriggers.kt | 144 +++++++++--------- .../EditedContentTriggers.kt | 132 ++++++++-------- .../triggers_handling/EventTriggers.kt | 144 +++++++++--------- .../triggers_handling/InlineQueryTriggers.kt | 24 +-- .../triggers_handling/MainTrigger.kt | 9 +- .../triggers_handling/MediaGroupTriggers.kt | 48 +++--- .../triggers_handling/PassportTriggers.kt | 14 +- .../triggers_handling/PollAnswersTriggers.kt | 12 +- .../triggers_handling/PollUpdatesTriggers.kt | 24 +-- .../PreCheckoutQueryTriggers.kt | 6 +- .../ShippingQueryTriggers.kt | 6 +- tgbotapi.extensions.utils/README.md | 2 +- tgbotapi.extensions.utils/build.gradle | 3 - tgbotapi/build.gradle | 4 +- 41 files changed, 905 insertions(+), 464 deletions(-) create mode 100644 tgbotapi.extensions.behaviour_builder.fsm/README.md create mode 100644 tgbotapi.extensions.behaviour_builder.fsm/build.gradle create mode 100644 tgbotapi.extensions.behaviour_builder.fsm/mpp_publish_template.kpsb create mode 100644 tgbotapi.extensions.behaviour_builder.fsm/publish.gradle create mode 100644 tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt create mode 100644 tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt create mode 100644 tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandler.kt create mode 100644 tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 833bb37b17..aef340cdc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * `Version`: * `Serialization`: `1.2.2` -> `1.3.0` * `MicroUtils`: `0.5.28` -> `0.7.0` + * `Klock`: `2.4.3` -> `2.4.5` * `Core`: * `PayInlineKeyboardButton#pay` now is deprecated * `RowBuilder` and `MatrixBuilder` now are open and available for extending @@ -24,6 +25,8 @@ * `waitPreCheckoutQueries`/`onPreCheckoutQuery` * `waitChosenInlineResult`/`onChosenInlineResult` * `waitPollUpdates`/`onPollUpdates` +* `Behaviour Builder FSM extension`: + * Has been created :) ## 0.35.9 diff --git a/TelegramBotAPI.drawio b/TelegramBotAPI.drawio index 0bc0fa2013..f0839eea47 100644 --- a/TelegramBotAPI.drawio +++ b/TelegramBotAPI.drawio @@ -1 +1 @@ - \ No newline at end of file +7Vptc+I2EP41TD/BgI0J+Zi33t302t5cOr3mU0fYwtZFtnyyHKC/vruy/G4TAglkchlmgrUSq9Vq93m0cgb2Vbj+IEkc/C48ygfW2FsP7OuBZU0mYwu+ULLJJPPJWSbwJfPMoFJwy/6jRjg20pR5NKkNVEJwxeK60BVRRF1VkxEpxao+bCl4fdaY+LQluHUJb0u/MU8FZhXOuJR/pMwPVLFg0xOSfLARJAHxxKqi1b4Z2FdSCJU9hesrytF5uV+y3/3a01sYJmmkdvmBMzN2qE2+OOrBWk1TSBUIX0SE35TSy1L6WYgYhk1A+J0qtTFbRVIlQBSokJteMEdu/oHGOG/cYWPk5M3rdbXzemNa7fWYJSYila6xeGqiRxHpUzPMcTIZrqbpXohLKkIK88AASTlR7KG+s8QEiF+MK30ID8aN3S7NrXkgPDVaB9aMK3QIqJ/5Sq8rkyQxiWrun/1Ice8vFV2rIeHMjwb2BYzgdKnK3p3VcBbRYWBiEfVY89E8XvdrWnSqWYpIDRO9uVrJtEuF8hdCkZiNwHQaJUxEyQiauWbw26I5G8gy03cVtz0YP7NLbwrjMfCk+I4Aghghdf7eUx0zP1KaKBwRCokSLsQ9fjHdz9AAFeDjX5RTX5IQHi8FKrr48gkDLPIQxzDurLGIY0ipNGJqo5EM/qSJ1qN+wTkoSRiVjzun4opGTuPS6wlp/HDtQmKBbvvygUrFAOIuTEfIPE9newFRmI8+J0linsEKl0U+tDCLVwFT9BZEOOUKcB/DhnF+JTi4Dq2wLYIfE04V+c0MP9uyHY2j6615bKjEyqF2VQKznaNtUAXlXHhIrueIfzz4LBHzrgaYh8DnvA2fOYgdHz6dyVt16fnJXDp9CyTf4VLHOhnJz3tJPt6NiCdTwA6nn4jreP7k88NOjF0h/QaFu5rW9iHuQxi6YfTEQqOzCBnrvlXFgZGQIeHtRX0VmmdL6l4xIAJNvCP4+oQilmgFSoeGK8KQRh71muSb1KneYzBW8U1B3wvIBuTl6q+I0icLkuD34yeix5m8x4c/O92bXmtqGNjQ/7TN/sWJ4PnZ3z46VVkvwFXnrwlYx1/FN8df3Q3//vP+Plj8MSS/XQ1n+xyzpEh1Umeu2Mfta6YKNoPnCplBq3Q5NjZV/+99qmi4e7+tcw7cKf3TCynJpjIgFixCECw0f0FBmYe2Xc9DazZu7HqmsYyBwrTd+Pb8vaguKCRVjCfHKqt76mFDqsYUKHaBGvABeMENdL/eP1Mw5xUscOhySXVMY9lLJYSk1mz8JN9prpPm7FkjvY5a5XZisnN+UkwucPiu0tONyftha06BVWztdsT8pNRovR5qPNuZG/c5xjzHBh5MjjsfDa2tfPVy3HRg3VdhmQUNyAMDh/67SBn3aheQr7EenCIm9t7mDtqXuXpZCPXwqEvBYsW4cYygSTF1GRaZ4+vbz+8XsPtQVdGuUNX07MVKMqc3797CvcwzpuDeEPSRyuwdh8vT7NKE6C0gD4RxsuDVtx6XQmXvOzhbSCIZvrS9OOCeI5OlvCnh7IAF9V16odKXmKb3MugIEzZLhyNMuY1HTjH9aJmEW00AYTvCdgrM91u6bk6YnNc5YTbvuKabd3HC7KXKl9k+r5lOUr4Ux+biKvApb1WeemreUuKc6Ci91aK3dL5uANP7Gfstn7Fb4NmRmf1n7MZbD8dq46kzeaYzNjTL/0fLrm7L/+qzb/4H \ No newline at end of file diff --git a/build.gradle b/build.gradle index 1e47f88a68..42562e8321 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,6 @@ buildscript { repositories { mavenLocal() - jcenter() mavenCentral() maven { url "https://plugins.gradle.org/m2/" } } diff --git a/docs/build.gradle b/docs/build.gradle index babb90dfde..0f06812393 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -1,7 +1,6 @@ buildscript { repositories { mavenLocal() - jcenter() mavenCentral() } @@ -20,7 +19,6 @@ plugins { repositories { mavenLocal() - jcenter() mavenCentral() } diff --git a/gradle.properties b/gradle.properties index ea3a8362c9..a9ad63c307 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,11 +8,11 @@ kotlin.incremental.js=true kotlin_version=1.5.31 kotlin_coroutines_version=1.5.2 kotlin_serialisation_runtime_version=1.3.0 -klock_version=2.4.3 +klock_version=2.4.5 uuid_version=0.3.1 ktor_version=1.6.4 -micro_utils_version=0.7.0 +micro_utils_version=0.7.1 javax_activation_version=1.1.1 diff --git a/resources/TelegramBotAPI-libraries-hierarchy.svg b/resources/TelegramBotAPI-libraries-hierarchy.svg index 774ed45810..6b39a9717b 100644 --- a/resources/TelegramBotAPI-libraries-hierarchy.svg +++ b/resources/TelegramBotAPI-libraries-hierarchy.svg @@ -1 +1,3 @@ -

tgbotapi.extensions.api

Extensions project for make requests more look like in the Telegram Bot API and give opportunity to use it's easier

tgbotapi.extensions.api...

tgbotapi.core

Root project with API. It is not recommended to use its requests directly and better to use at least tgbotapi.extensions.api

tgbotapi.core...

tgbotapi.extensions.utils

Extensions project with utils things which will make easier different operations

tgbotapi.extensions.utils...

tgbotapi.extensions.behaviour_builder

Extension project for building bot behaviour via special DSL

tgbotapi.extensions.behaviour_builder...

tgbotapi

Here included all available TelegramBotAPI libraries:

  • tgbotapi.core
  • tgbotapi.extensions.api
  • tgbotapi.extensions.utils
  • tgbotapi.extensions.behaviour_builder

tgbotapi...
Viewer does not support full SVG 1.1
+ + +

tgbotapi.extensions.api

Extensions project for make requests more look like in the Telegram Bot API and give opportunity to use it's easier

tgbotapi.extensions.api...

tgbotapi.core

Root project with API. It is not recommended to use its requests directly and better to use at least tgbotapi.extensions.api

tgbotapi.core...

tgbotapi.extensions.utils

Extensions project with utils things which will make easier different operations

tgbotapi.extensions.utils...

tgbotapi.extensions.behaviour_builder

Extension project for building bot behaviour via special DSL

tgbotapi.extensions.behaviour_builder...

tgbotapi

Here included all available TelegramBotAPI libraries:

  • tgbotapi.core
  • tgbotapi.extensions.api
  • tgbotapi.extensions.utils
  • tgbotapi.extensions.behaviour_builder
  • tgbotapi.extensions.behaviour_builder.fsm

tgbotapi...

tgbotapi.extensions.behaviour_builder.fsm

Extension project for building bot behaviour via special DSL

tgbotapi.extensions.behaviour_builder.fsm...
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 33e593255e..70c3b4c77a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,7 +8,6 @@ pluginManagement { } repositories { gradlePluginPortal() - jcenter() } } @@ -16,5 +15,6 @@ include ":tgbotapi.core" include ":tgbotapi.extensions.api" include ":tgbotapi.extensions.utils" include ":tgbotapi.extensions.behaviour_builder" +include ":tgbotapi.extensions.behaviour_builder.fsm" include ":tgbotapi" include ":docs" diff --git a/tgbotapi.core/README.md b/tgbotapi.core/README.md index 4f888a0d23..428c1a191a 100644 --- a/tgbotapi.core/README.md +++ b/tgbotapi.core/README.md @@ -57,7 +57,7 @@ Dependency config presented here: To use last versions you will need to add one line in repositories block of your `build.gradle`: -`jcenter()` or `mavenCentral()` +`mavenCentral()` And add next line to your dependencies block: diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt index afc186883d..b37ceacb1c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt @@ -1,11 +1,12 @@ package dev.inmo.tgbotapi.updateshandlers +import dev.inmo.micro_utils.coroutines.plus import dev.inmo.tgbotapi.types.ALL_UPDATES_LIST import dev.inmo.tgbotapi.types.update.* import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.* import dev.inmo.tgbotapi.types.update.abstracts.UnknownUpdate import dev.inmo.tgbotapi.types.update.abstracts.Update -import kotlinx.coroutines.channels.BufferOverflow +import kotlinx.coroutines.channels.* import kotlinx.coroutines.flow.* interface FlowsUpdatesFilter : UpdatesFilter { @@ -34,22 +35,61 @@ interface FlowsUpdatesFilter : UpdatesFilter { val unknownUpdatesFlow: Flow } +abstract class AbstractFlowsUpdatesFilter : FlowsUpdatesFilter { + override val allUpdatesWithoutMediaGroupsGroupingFlow: Flow + get() = allUpdatesFlow.flatMapConcat { + when (it) { + is SentMediaGroupUpdate -> it.origins.asFlow() + is EditMediaGroupUpdate -> flowOf(it.origin) + else -> flowOf(it) + } + } + + override val messagesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val messageMediaGroupsFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val editedMessagesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val editedMessageMediaGroupsFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val channelPostsFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val channelPostMediaGroupsFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val editedChannelPostsFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val editedChannelPostMediaGroupsFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val chosenInlineResultsFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val inlineQueriesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val callbackQueriesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val shippingQueriesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val preCheckoutQueriesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val pollsFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val pollAnswersFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val chatMemberUpdatesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val myChatMemberUpdatesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } + override val unknownUpdatesFlow: Flow by lazy { allUpdatesFlow.filterIsInstance() } +} + /** * Creates [DefaultFlowsUpdatesFilter] */ @Suppress("FunctionName") fun FlowsUpdatesFilter( - broadcastChannelsSize: Int = 100 -) = DefaultFlowsUpdatesFilter(broadcastChannelsSize) + broadcastChannelsSize: Int = 100, + onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND, + upstreamUpdatesFlow: Flow? = null +) = DefaultFlowsUpdatesFilter(broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow) @Suppress("unused") class DefaultFlowsUpdatesFilter( broadcastChannelsSize: Int = 100, - onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND -): FlowsUpdatesFilter { - private val updatesSharedFlow = MutableSharedFlow(extraBufferCapacity = broadcastChannelsSize, onBufferOverflow = onBufferOverflow) + onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND, + upstreamUpdatesFlow: Flow? = null +): AbstractFlowsUpdatesFilter() { + private val additionalUpdatesSharedFlow = MutableSharedFlow(0, broadcastChannelsSize, onBufferOverflow) @Suppress("MemberVisibilityCanBePrivate") - override val allUpdatesFlow: Flow = updatesSharedFlow.asSharedFlow() + override val allUpdatesFlow: Flow = (additionalUpdatesSharedFlow.asSharedFlow()).let { + if (upstreamUpdatesFlow != null) { + (it + upstreamUpdatesFlow).distinctUntilChanged { old, new -> old.updateId == new.updateId } + } else { + it + } + } @Suppress("MemberVisibilityCanBePrivate") override val allUpdatesWithoutMediaGroupsGroupingFlow: Flow = allUpdatesFlow.flatMapConcat { when (it) { @@ -59,26 +99,5 @@ class DefaultFlowsUpdatesFilter( } } - override val asUpdateReceiver: UpdateReceiver = { - updatesSharedFlow.emit(it) - } - - override val messagesFlow: Flow = allUpdatesFlow.filterIsInstance() - override val messageMediaGroupsFlow: Flow = allUpdatesFlow.filterIsInstance() - override val editedMessagesFlow: Flow = allUpdatesFlow.filterIsInstance() - override val editedMessageMediaGroupsFlow: Flow = allUpdatesFlow.filterIsInstance() - override val channelPostsFlow: Flow = allUpdatesFlow.filterIsInstance() - override val channelPostMediaGroupsFlow: Flow = allUpdatesFlow.filterIsInstance() - override val editedChannelPostsFlow: Flow = allUpdatesFlow.filterIsInstance() - override val editedChannelPostMediaGroupsFlow: Flow = allUpdatesFlow.filterIsInstance() - override val chosenInlineResultsFlow: Flow = allUpdatesFlow.filterIsInstance() - override val inlineQueriesFlow: Flow = allUpdatesFlow.filterIsInstance() - override val callbackQueriesFlow: Flow = allUpdatesFlow.filterIsInstance() - override val shippingQueriesFlow: Flow = allUpdatesFlow.filterIsInstance() - override val preCheckoutQueriesFlow: Flow = allUpdatesFlow.filterIsInstance() - override val pollsFlow: Flow = allUpdatesFlow.filterIsInstance() - override val pollAnswersFlow: Flow = allUpdatesFlow.filterIsInstance() - override val chatMemberUpdatesFlow: Flow = allUpdatesFlow.filterIsInstance() - override val myChatMemberUpdatesFlow: Flow = allUpdatesFlow.filterIsInstance() - override val unknownUpdatesFlow: Flow = allUpdatesFlow.filterIsInstance() + override val asUpdateReceiver: UpdateReceiver = additionalUpdatesSharedFlow::emit } diff --git a/tgbotapi.extensions.api/README.md b/tgbotapi.extensions.api/README.md index bbe8b0bc77..a686fbf6f4 100644 --- a/tgbotapi.extensions.api/README.md +++ b/tgbotapi.extensions.api/README.md @@ -49,7 +49,7 @@ Dependency config presented here: To use last versions you will need to add one line in repositories block of your `build.gradle`: -`jcenter()` or `mavenCentral()` +`mavenCentral()` And add next line to your dependencies block: diff --git a/tgbotapi.extensions.api/build.gradle b/tgbotapi.extensions.api/build.gradle index 8dcc226dda..54888411ac 100644 --- a/tgbotapi.extensions.api/build.gradle +++ b/tgbotapi.extensions.api/build.gradle @@ -1,7 +1,6 @@ buildscript { repositories { mavenLocal() - jcenter() mavenCentral() } @@ -23,9 +22,7 @@ apply from: "publish.gradle" repositories { mavenLocal() - jcenter() mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } } kotlin { diff --git a/tgbotapi.extensions.behaviour_builder.fsm/README.md b/tgbotapi.extensions.behaviour_builder.fsm/README.md new file mode 100644 index 0000000000..15817d3d3e --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder.fsm/README.md @@ -0,0 +1,3 @@ +# TelegramBotAPI Behaviour Builder FSM Extensions + +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.behaviour_builder.fsm/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.behaviour_builder.fsm) diff --git a/tgbotapi.extensions.behaviour_builder.fsm/build.gradle b/tgbotapi.extensions.behaviour_builder.fsm/build.gradle new file mode 100644 index 0000000000..9183791d96 --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder.fsm/build.gradle @@ -0,0 +1,50 @@ +buildscript { + repositories { + mavenLocal() + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" + } +} + +plugins { + id "org.jetbrains.kotlin.multiplatform" + id "org.jetbrains.kotlin.plugin.serialization" +} + +project.version = "$library_version" +project.group = "$library_group" + +apply from: "publish.gradle" + +repositories { + mavenLocal() + mavenCentral() +} + +kotlin { + jvm() + js(IR) { + browser() + nodejs() + } + + sourceSets { + commonMain { + dependencies { + implementation kotlin('stdlib') + api project(":tgbotapi.extensions.behaviour_builder") + api "dev.inmo:micro_utils.fsm.common:$micro_utils_version" + } + } + } +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} diff --git a/tgbotapi.extensions.behaviour_builder.fsm/mpp_publish_template.kpsb b/tgbotapi.extensions.behaviour_builder.fsm/mpp_publish_template.kpsb new file mode 100644 index 0000000000..be7b82e6ec --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder.fsm/mpp_publish_template.kpsb @@ -0,0 +1 @@ +{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot Behaviour Builder FSM Extensions","description":"FSM extension for dev.inmo:tgbotapi.extensions.behaviour_builder.fsm","url":"https://insanusmokrassar.github.io/TelegramBotAPI/tgbotapi.extensions.behaviour_builder","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}]}} diff --git a/tgbotapi.extensions.behaviour_builder.fsm/publish.gradle b/tgbotapi.extensions.behaviour_builder.fsm/publish.gradle new file mode 100644 index 0000000000..562185a08c --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder.fsm/publish.gradle @@ -0,0 +1,69 @@ +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task javadocsJar(type: Jar) { + classifier = 'javadoc' +} + +publishing { + publications.all { + artifact javadocsJar + + pom { + description = "FSM extension for dev.inmo:tgbotapi.extensions.behaviour_builder.fsm" + name = "Telegram Bot Behaviour Builder FSM Extensions" + url = "https://insanusmokrassar.github.io/TelegramBotAPI/tgbotapi.extensions.behaviour_builder" + + scm { + developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git" + url = "https://github.com/insanusmokrassar/TelegramBotAPI.git" + } + + developers { + + developer { + id = "InsanusMokrassar" + name = "Ovsiannikov Aleksei" + email = "ovsyannikov.alexey95@gmail.com" + } + + } + + licenses { + + license { + name = "Apache Software License 2.0" + url = "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE" + } + + } + } + repositories { + if ((project.hasProperty('GITHUBPACKAGES_USER') || System.getenv('GITHUBPACKAGES_USER') != null) && (project.hasProperty('GITHUBPACKAGES_PASSWORD') || System.getenv('GITHUBPACKAGES_PASSWORD') != null)) { + maven { + name = "GithubPackages" + url = uri("https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI") + credentials { + username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER') + password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD') + } + } + } + if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) { + maven { + name = "sonatype" + url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") + credentials { + username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER') + password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD') + } + } + } + } + } +} + +signing { + useGpgCmd() + sign publishing.publications +} diff --git a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt new file mode 100644 index 0000000000..26fc50ea66 --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt @@ -0,0 +1,100 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder + +import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions +import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions +import dev.inmo.micro_utils.fsm.common.* +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.types.update.abstracts.Update +import dev.inmo.micro_utils.coroutines.accumulatorFlow +import kotlinx.coroutines.* +import kotlinx.coroutines.channels.BufferOverflow +import kotlinx.coroutines.flow.* + +private suspend fun BehaviourContextWithFSM.launchStateHandling( + state: State, + contextUpdatesFlow: Flow, + handlers: List> +): State? { + return handlers.firstOrNull { it.checkHandleable(state) } ?.run { + handleState(contextUpdatesFlow, state) + } +} + +interface BehaviourContextWithFSM : BehaviourContext, StatesMachine { + override fun copy( + bot: TelegramBot, + scope: CoroutineScope, + broadcastChannelsSize: Int, + onBufferOverflow: BufferOverflow, + upstreamUpdatesFlow: Flow?, + updatesFilter: BehaviourContextAndTypeReceiver? + ): BehaviourContextWithFSM + + companion object { + operator fun invoke( + behaviourContext: BehaviourContext, + handlers: List>, + statesManager: StatesManager + ) = DefaultBehaviourContextWithFSM(behaviourContext, statesManager, handlers) + } +} + +class DefaultBehaviourContextWithFSM( + private val behaviourContext: BehaviourContext, + private val statesManager: StatesManager, + private val handlers: List> +) : BehaviourContext by behaviourContext, BehaviourContextWithFSM { + private val updatesFlows = mutableMapOf>() + private fun getContextUpdatesFlow(context: Any) = updatesFlows.getOrPut(context) { + allUpdatesFlow.accumulatorFlow(scope) + } + override suspend fun StatesMachine.handleState(state: State): State? = launchStateHandling( + state, + allUpdatesFlow, + handlers + ) + + override fun start(scope: CoroutineScope): Job = scope.launchSafelyWithoutExceptions { + val statePerformer: suspend (State) -> Unit = { state: State -> + val newState = launchStateHandling(state, getContextUpdatesFlow(state.context), handlers) + if (newState != null) { + statesManager.update(state, newState) + } else { + statesManager.endChain(state) + } + } + statesManager.onStartChain.subscribeSafelyWithoutExceptions(this) { + launch { statePerformer(it) } + } + statesManager.onChainStateUpdated.subscribeSafelyWithoutExceptions(this) { (old, new) -> + if (old.context != new.context) { + updatesFlows.remove(old.context) + } + launch { statePerformer(new) } + } + statesManager.onEndChain.subscribeSafelyWithoutExceptions(this) { + updatesFlows.remove(it.context) + } + + statesManager.getActiveStates().forEach { + launch { statePerformer(it) } + } + } + + override suspend fun startChain(state: State) { + statesManager.startChain(state) + } + + override fun copy( + bot: TelegramBot, + scope: CoroutineScope, + broadcastChannelsSize: Int, + onBufferOverflow: BufferOverflow, + upstreamUpdatesFlow: Flow?, + updatesFilter: BehaviourContextAndTypeReceiver? + ): BehaviourContextWithFSM = BehaviourContextWithFSM( + behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, updatesFilter), + handlers, + statesManager + ) +} diff --git a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt new file mode 100644 index 0000000000..cdcd5d2e86 --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt @@ -0,0 +1,107 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder + +import dev.inmo.micro_utils.fsm.common.* +import dev.inmo.micro_utils.fsm.common.managers.DefaultStatesManager +import dev.inmo.micro_utils.fsm.common.managers.InMemoryDefaultStatesManagerRepo +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling +import dev.inmo.tgbotapi.types.update.abstracts.Update +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.launch +import kotlin.reflect.KClass + +class BehaviourContextWithFSMBuilder internal constructor( + private val resultBehaviourContext: BehaviourContextWithFSM, + private val handlers: MutableList> +) : BehaviourContextWithFSM by resultBehaviourContext { + internal constructor( + baseBehaviourContext: BehaviourContext, + statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), + handlers: MutableList> = mutableListOf() + ) : this(DefaultBehaviourContextWithFSM(baseBehaviourContext, statesManager, handlers), handlers) + + /** + * Add NON STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Non strict means that + * for input [State] will be used [KClass.isInstance] and any inheritor of [kClass] will pass this requirement + * + * @see BehaviourWithFSMStateHandlerHolder + * @see onStateOrSubstate + */ + fun add(kClass: KClass, handler: BehaviourWithFSMStateHandler) { + handlers.add(BehaviourWithFSMStateHandlerHolder(kClass, false, handler)) + } + + /** + * Add STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Strict means that + * for input [State] will be used [State]::class == [kClass] and any [State] with exactly the same type will pass + * requirements + * + * @see BehaviourWithFSMStateHandlerHolder + * @see strictlyOn + */ + fun addStrict(kClass: KClass, handler: BehaviourWithFSMStateHandler) { + handlers.add(BehaviourWithFSMStateHandlerHolder(kClass, true, handler)) + } + + /** + * Returns completed [resultBehaviourContext], [handlers] and [statesManager] + */ + internal fun build() = resultBehaviourContext +} + +/** + * Add NON STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Non strict means that + * for input [State] will be used [KClass.isInstance] and any inheritor of [kClass] will pass this requirement + * + * @see BehaviourWithFSMStateHandlerHolder + * @see BehaviourContextWithFSMBuilder.add + */ +inline fun BehaviourContextWithFSMBuilder.onStateOrSubstate(handler: BehaviourWithFSMStateHandler) { + add(I::class, handler) +} + +/** + * Add STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Strict means that + * for input [State] will be used [State]::class == [kClass] and any [State] with exactly the same type will pass + * requirements + * + * @see BehaviourWithFSMStateHandlerHolder + * @see BehaviourContextWithFSMBuilder.addStrict + */ +inline fun BehaviourContextWithFSMBuilder.strictlyOn(handler: BehaviourWithFSMStateHandler) { + addStrict(I::class, handler) +} + +/** + * Use this factory to create and organize behaviour of your bot with attention to FSM logic. This factory WILL NOT + * start any incoming updates handling of FSM handling, you must start it by yourself + * + * @param upstreamUpdatesFlow Will be used in [BehaviourContextWithFSMBuilder.build] to put it in new [BehaviourContextWithFSM] + * @param scope This [CoroutineScope] will be used in [BehaviourContextWithFSMBuilder.build] to put it in new [BehaviourContextWithFSM] + */ +suspend fun TelegramBot.buildBehaviourWithFSM( + upstreamUpdatesFlow: Flow? = null, + scope: CoroutineScope = defaultCoroutineScopeProvider(), + block: suspend BehaviourContextWithFSMBuilder.() -> Unit +) = BehaviourContextWithFSMBuilder( + DefaultBehaviourContext(this, scope, upstreamUpdatesFlow = upstreamUpdatesFlow) +).apply { block() }.build() + +/** + * Use this factory to create and organize behaviour of your bot with attention to FSM logic. This factory will start + * listening of updates by [longPolling] + * + * @param upstreamUpdatesFlow Will be used in [BehaviourContextWithFSMBuilder.build] to put it in new [BehaviourContextWithFSM] + * @param scope This [CoroutineScope] will be used in [BehaviourContextWithFSMBuilder.build] to put it in new [BehaviourContextWithFSM] + */ +suspend fun TelegramBot.buildBehaviourWithFSMAndLongPolling( + upstreamUpdatesFlow: Flow? = null, + scope: CoroutineScope = defaultCoroutineScopeProvider(), + block: suspend BehaviourContextWithFSMBuilder.() -> Unit +) = buildBehaviourWithFSM(upstreamUpdatesFlow, scope, block).run { + this to scope.launch { + longPolling(this@run, scope = this) + start(this) + } +} diff --git a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandler.kt b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandler.kt new file mode 100644 index 0000000000..c2e1b6f32f --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandler.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder + +import dev.inmo.micro_utils.fsm.common.* + +fun interface BehaviourWithFSMStateHandler { + suspend fun BehaviourContextWithFSM.handleState(state: T): State? +} diff --git a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder.kt b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder.kt new file mode 100644 index 0000000000..00a8d4a82a --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder.kt @@ -0,0 +1,52 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder + +import dev.inmo.micro_utils.coroutines.LinkedSupervisorScope +import dev.inmo.micro_utils.coroutines.weakLaunch +import dev.inmo.micro_utils.fsm.common.* +import dev.inmo.tgbotapi.types.update.abstracts.Update +import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.collect +import kotlin.reflect.KClass + +/** + * Special holder for [BehaviourContextWithFSM]. This holder helps [BehaviourContextWithFSM] to understand whether it + * can handle input [State] with [delegateTo] or not + * + * @param inputKlass This [KClass] will be used to compare input [State] type and declare ability of [delegateTo] to + * handle incoming [State]. See [checkHandleable] for more info + * @param strict This flag will be used in [checkHandleable] to choose strategy of checking incoming [State] + * @param delegateTo This handler will be called in case [checkHandleable] returns true with class caster incoming + * [State] in [handleState] + */ +class BehaviourWithFSMStateHandlerHolder( + private val inputKlass: KClass, + private val strict: Boolean = false, + private val delegateTo: BehaviourWithFSMStateHandler +) { + /** + * Check ability of [delegateTo] to handle this [state] + * + * @return When [state]::class exactly equals to [inputKlass] will always return true. Otherwise when [strict] + * mode is disabled, will be used [KClass.isInstance] of [inputKlass] for checking + */ + fun checkHandleable(state: State) = state::class == inputKlass || (!strict && inputKlass.isInstance(state)) + + /** + * Handling of state :) + * + * @param contextUpdatesFlow This [Flow] will be used as source of updates. By contract, this [Flow] must be common + * for all [State]s of incoming [state] [State.context] and for the whole chain inside of [BehaviourContextWithFSM] + */ + suspend fun BehaviourContextWithFSM.handleState( + contextUpdatesFlow: Flow, + state: State + ): State? { + val subscope = scope.LinkedSupervisorScope() + return with(copy(scope = subscope, upstreamUpdatesFlow = contextUpdatesFlow)) { + with(delegateTo) { + handleState(state as I) + } + } + } +} diff --git a/tgbotapi.extensions.behaviour_builder/build.gradle b/tgbotapi.extensions.behaviour_builder/build.gradle index fe275f7938..b85db355e2 100644 --- a/tgbotapi.extensions.behaviour_builder/build.gradle +++ b/tgbotapi.extensions.behaviour_builder/build.gradle @@ -1,7 +1,6 @@ buildscript { repositories { mavenLocal() - jcenter() mavenCentral() } @@ -23,9 +22,7 @@ apply from: "publish.gradle" repositories { mavenLocal() - jcenter() mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } } kotlin { diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt index 2fb4504b79..c81e7a5981 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt @@ -5,20 +5,25 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder import dev.inmo.micro_utils.coroutines.* import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.types.update.abstracts.Update -import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter +import dev.inmo.tgbotapi.updateshandlers.* import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.coroutines.* -import kotlinx.coroutines.flow.filter +import kotlinx.coroutines.channels.BufferOverflow +import kotlinx.coroutines.flow.* -typealias BehaviourContextReceiver = suspend BehaviourContext.() -> T -typealias BehaviourContextAndTypeReceiver = suspend BehaviourContext.(I) -> T -typealias BehaviourContextAndTwoTypesReceiver = suspend BehaviourContext.(I1, I2) -> T +typealias CustomBehaviourContextReceiver = suspend BC.() -> T +typealias BehaviourContextReceiver = CustomBehaviourContextReceiver +typealias CustomBehaviourContextAndTypeReceiver = suspend BC.(I) -> T +typealias BehaviourContextAndTypeReceiver = CustomBehaviourContextAndTypeReceiver +typealias CustomBehaviourContextAndTwoTypesReceiver = suspend BC.(I1, I2) -> T +typealias BehaviourContextAndTwoTypesReceiver = CustomBehaviourContextAndTwoTypesReceiver inline fun BehaviourContextReceiver(noinline block: BehaviourContextReceiver) = block +inline fun CustomBehaviourContextReceiver(noinline block: CustomBehaviourContextReceiver) = block inline fun BehaviourContextAndTypeReceiver(noinline block: BehaviourContextAndTypeReceiver) = block inline fun BehaviourContextAndTwoTypesReceiver(noinline block: BehaviourContextAndTwoTypesReceiver) = block -internal inline fun BehaviourContextAndTwoTypesReceiver.toOneType( +internal inline fun CustomBehaviourContextAndTwoTypesReceiver.toOneType( i1: I1, -): BehaviourContextAndTypeReceiver = { invoke(this, i1, it) } +): CustomBehaviourContextAndTypeReceiver = { invoke(this, i1, it) } /** * This class contains all necessary tools for work with bots and especially for [buildBehaviour] @@ -45,27 +50,68 @@ interface BehaviourContext : FlowsUpdatesFilter, TelegramBot, CoroutineScope { fun copy( bot: TelegramBot = this.bot, scope: CoroutineScope = this.scope, - flowsUpdatesFilter: FlowsUpdatesFilter = this.flowsUpdatesFilter + broadcastChannelsSize: Int = 100, + onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND, + upstreamUpdatesFlow: Flow? = null, + updatesFilter: BehaviourContextAndTypeReceiver? = null ): BehaviourContext + + @Deprecated("This method is not recommended to use and will be removed in near release") + fun copy( + bot: TelegramBot, + scope: CoroutineScope = this.scope, + flowsUpdatesFilter: FlowsUpdatesFilter = this.flowsUpdatesFilter + ): BehaviourContext = copy(upstreamUpdatesFlow = flowsUpdatesFilter.allUpdatesFlow) } class DefaultBehaviourContext( override val bot: TelegramBot, override val scope: CoroutineScope, - override val flowsUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter() -) : FlowsUpdatesFilter by flowsUpdatesFilter, TelegramBot by bot, CoroutineScope by scope, BehaviourContext { + private val broadcastChannelsSize: Int = 100, + private val onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND, + private val upstreamUpdatesFlow: Flow? = null, + private val updatesFilter: BehaviourContextAndTypeReceiver? = null +) : AbstractFlowsUpdatesFilter(), TelegramBot by bot, CoroutineScope by scope, BehaviourContext { + + private val additionalUpdatesSharedFlow = MutableSharedFlow(0, broadcastChannelsSize, onBufferOverflow) + override val allUpdatesFlow: Flow = (additionalUpdatesSharedFlow.asSharedFlow()).let { + if (upstreamUpdatesFlow != null) { + (it + upstreamUpdatesFlow).distinctUntilChanged { old, new -> old.updateId == new.updateId } + } else { + it + } + }.let { + val updatesFilter = updatesFilter + if (updatesFilter != null) { + it.filter { updatesFilter(it) } + } else { + it + } + } + override val asUpdateReceiver: UpdateReceiver = additionalUpdatesSharedFlow::emit + override fun copy( bot: TelegramBot, scope: CoroutineScope, - flowsUpdatesFilter: FlowsUpdatesFilter - ): DefaultBehaviourContext = DefaultBehaviourContext(bot, scope, flowsUpdatesFilter) + broadcastChannelsSize: Int, + onBufferOverflow: BufferOverflow, + upstreamUpdatesFlow: Flow?, + updatesFilter: BehaviourContextAndTypeReceiver? + ): BehaviourContext = DefaultBehaviourContext(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, updatesFilter) } fun BehaviourContext( bot: TelegramBot, scope: CoroutineScope, flowsUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter() -) = DefaultBehaviourContext(bot, scope, flowsUpdatesFilter) +) = DefaultBehaviourContext(bot, scope, upstreamUpdatesFlow = flowsUpdatesFilter.allUpdatesFlow) + +inline fun BehaviourContext( + bot: TelegramBot, + scope: CoroutineScope, + flowsUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter(), + crossinline block: BehaviourContext.() -> T +) = DefaultBehaviourContext(bot, scope, upstreamUpdatesFlow = flowsUpdatesFilter.allUpdatesFlow).run(block) /** * Creates new one [BehaviourContext], adding subsequent [FlowsUpdatesFilter] in case [newFlowsUpdatesFilterSetUp] is provided and @@ -75,21 +121,19 @@ fun BehaviourContext( */ @RiskFeature("It is recommended to use doInSubContextWithUpdatesFilter instead. " + "This method is low level and should not be used in case you are not pretty sure you need it.") -suspend fun BehaviourContext.doInSubContextWithFlowsUpdatesFilterSetup( - newFlowsUpdatesFilterSetUp: BehaviourContextAndTypeReceiver?, +@Deprecated("This method is useless and will not be used in future") +suspend fun BC.doInSubContextWithFlowsUpdatesFilterSetup( + newFlowsUpdatesFilterSetUp: CustomBehaviourContextAndTypeReceiver?, stopOnCompletion: Boolean = true, - behaviourContextReceiver: BehaviourContextReceiver -): T { - return copy( - flowsUpdatesFilter = FlowsUpdatesFilter(), - scope = LinkedSupervisorScope() - ).run { + behaviourContextReceiver: CustomBehaviourContextReceiver +): T = (copy( + scope = LinkedSupervisorScope(), +) as BC).run { + withContext(coroutineContext) { newFlowsUpdatesFilterSetUp ?.let { it.apply { invoke(this@run, this@doInSubContextWithFlowsUpdatesFilterSetup.flowsUpdatesFilter) } } - withContext(coroutineContext) { - behaviourContextReceiver().also { if (stopOnCompletion) stop() } - } + behaviourContextReceiver().also { if (stopOnCompletion) stop() } } } @@ -97,25 +141,24 @@ suspend fun BehaviourContext.doInSubContextWithFlowsUpdatesFilterSetup( * Creates new one [BehaviourContext], adding subsequent [FlowsUpdatesFilter] in case [updatesFilter] is provided and * [CoroutineScope] as new [BehaviourContext.scope] */ -suspend fun BehaviourContext.doInSubContextWithUpdatesFilter( - updatesFilter: BehaviourContextAndTypeReceiver?, +suspend fun BC.doInSubContextWithUpdatesFilter( + updatesFilter: CustomBehaviourContextAndTypeReceiver?, stopOnCompletion: Boolean = true, - behaviourContextReceiver: BehaviourContextReceiver -): T = doInSubContextWithFlowsUpdatesFilterSetup( - newFlowsUpdatesFilterSetUp = updatesFilter ?.let { - { oldOne -> - weakLaunch { - oldOne.allUpdatesFlow.filter { updatesFilter(it) }.subscribeSafelyWithoutExceptions(this, block = asUpdateReceiver) - } + behaviourContextReceiver: CustomBehaviourContextReceiver +): T = copy( + scope = LinkedSupervisorScope(), + updatesFilter = updatesFilter ?.let { _ -> + { + (this as? BC) ?.run { + updatesFilter(it) + } ?: true } - } ?: { oldOne -> - weakLaunch { - oldOne.allUpdatesFlow.subscribeSafelyWithoutExceptions(this, block = asUpdateReceiver) - } - }, - stopOnCompletion, - behaviourContextReceiver -) + } +).run { + withContext(coroutineContext) { + behaviourContextReceiver().also { if (stopOnCompletion) stop() } + } +} suspend fun BehaviourContext.doInSubContext( stopOnCompletion: Boolean = true, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt index 822785234a..c5f1364cbf 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt @@ -4,6 +4,7 @@ import dev.inmo.micro_utils.coroutines.safelyWithResult import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext +import dev.inmo.tgbotapi.extensions.utils.flatMap import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter @@ -38,9 +39,9 @@ suspend fun FlowsUpdatesFilter.expectFlow( cancelTrigger: suspend (Update) -> Boolean = { cancelRequestFactory(it) != null }, filter: suspend (Update) -> List ): Flow { - val flow = allUpdatesFlow.flatMapConcat { + val flow = allUpdatesFlow.map { val result = safelyWithResult { filter(it) } - (if (result.isFailure || result.getOrThrow().isEmpty()) { + if (result.isFailure || result.getOrThrow().isEmpty()) { if (cancelTrigger(it)) { cancelRequestFactory(it) ?.also { safelyWithResult { bot.execute(it) } @@ -53,8 +54,8 @@ suspend fun FlowsUpdatesFilter.expectFlow( emptyList() } else { result.getOrThrow() - }).asFlow() - } + } + }.flatMap() val result = if (count == null) { flow } else { diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt index d7abb32cee..08a60ddce1 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt @@ -14,6 +14,7 @@ import dev.inmo.tgbotapi.types.message.content.media.* import dev.inmo.tgbotapi.types.message.payments.InvoiceContent import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.toList typealias CommonMessageToContentMapper = suspend CommonMessage.() -> T? @@ -25,7 +26,7 @@ private suspend fun BehaviourContext.waitCommonMessage( errorFactory: NullableRequestBuilder<*> = { null }, filter: SimpleFilter>? = null, mapper: suspend CommonMessage.() -> O? -): List = expectFlow( +): Flow = expectFlow( initRequest, count, errorFactory @@ -49,7 +50,7 @@ private suspend fun BehaviourContext.waitCommonMessage( null } } -}.toList().toList() +} internal inline fun contentConverter( noinline mapper: CommonMessageToContentMapper? = null @@ -85,7 +86,7 @@ private suspend inline fun BehaviourContext.waitCon } }, contentConverter(mapper) -) +).toList() suspend fun BehaviourContext.waitContentMessage( initRequest: Request<*>? = null, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt index dd972014fd..9e7bdce543 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt @@ -11,11 +11,11 @@ import dev.inmo.tgbotapi.extensions.utils.asCallbackQueryUpdate import dev.inmo.tgbotapi.types.CallbackQuery.* import dev.inmo.tgbotapi.types.update.abstracts.Update -internal suspend inline fun BehaviourContext.onCallbackQuery( +internal suspend inline fun BC.onCallbackQuery( noinline initialFilter: SimpleFilter? = null, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTypeReceiver + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { (it.asCallbackQueryUpdate() ?.data as? T) ?.let(::listOfNotNull) } @@ -32,11 +32,11 @@ internal suspend inline fun BehaviourContext.onCallb * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onDataCallbackQuery( +suspend fun BC.onDataCallbackQuery( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onCallbackQuery( initialFilter, subcontextUpdatesFilter, @@ -56,11 +56,11 @@ suspend fun BehaviourContext.onDataCallbackQuery( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onGameShortNameCallbackQuery( +suspend fun BC.onGameShortNameCallbackQuery( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onCallbackQuery( initialFilter, subcontextUpdatesFilter, @@ -80,11 +80,11 @@ suspend fun BehaviourContext.onGameShortNameCallbackQuery( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onInlineMessageIdCallbackQuery( +suspend fun BC.onInlineMessageIdCallbackQuery( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onCallbackQuery( initialFilter, subcontextUpdatesFilter, @@ -104,11 +104,11 @@ suspend fun BehaviourContext.onInlineMessageIdCallbackQuery( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onInlineMessageIdDataCallbackQuery( +suspend fun BC.onInlineMessageIdDataCallbackQuery( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onCallbackQuery( initialFilter, subcontextUpdatesFilter, @@ -128,11 +128,11 @@ suspend fun BehaviourContext.onInlineMessageIdDataCallbackQuery( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onInlineMessageIdGameShortNameCallbackQuery( +suspend fun BC.onInlineMessageIdGameShortNameCallbackQuery( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onCallbackQuery( initialFilter, subcontextUpdatesFilter, @@ -152,11 +152,11 @@ suspend fun BehaviourContext.onInlineMessageIdGameShortNameCallbackQuery( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onMessageCallbackQuery( +suspend fun BC.onMessageCallbackQuery( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onCallbackQuery( initialFilter, subcontextUpdatesFilter, @@ -176,11 +176,11 @@ suspend fun BehaviourContext.onMessageCallbackQuery( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onMessageDataCallbackQuery( +suspend fun BC.onMessageDataCallbackQuery( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onCallbackQuery( initialFilter, subcontextUpdatesFilter, @@ -200,11 +200,11 @@ suspend fun BehaviourContext.onMessageDataCallbackQuery( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onMessageGameShortNameCallbackQuery( +suspend fun BC.onMessageGameShortNameCallbackQuery( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onCallbackQuery( initialFilter, subcontextUpdatesFilter, @@ -224,11 +224,11 @@ suspend fun BehaviourContext.onMessageGameShortNameCallbackQuery( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onUnknownCallbackQueryType( +suspend fun BC.onUnknownCallbackQueryType( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = CallbackQueryFilterByUser, markerFactory: MarkerFactory = ByUserCallbackQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onCallbackQuery( initialFilter, subcontextUpdatesFilter, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMemberUpdatedTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMemberUpdatedTriggers.kt index f39006f3a2..9f8cfa7193 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMemberUpdatedTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMemberUpdatedTriggers.kt @@ -13,11 +13,11 @@ import dev.inmo.tgbotapi.types.update.MyChatMemberUpdatedUpdate import dev.inmo.tgbotapi.types.update.abstracts.ChatMemberUpdatedUpdate import dev.inmo.tgbotapi.types.update.abstracts.Update -internal suspend inline fun BehaviourContext.onChatMemberUpdatedInternal( +internal suspend inline fun BC.onChatMemberUpdatedInternal( noinline initialFilter: SimpleFilter? = null, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = ChatMemberUpdatedFilterByChat, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = ChatMemberUpdatedFilterByChat, markerFactory: MarkerFactory = ByChatChatMemberUpdatedMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTypeReceiver + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { ((it as? U) ?.data) ?.let(::listOfNotNull) } @@ -35,12 +35,12 @@ internal suspend inline fun BehaviourConte * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onChatMemberUpdated( +suspend fun BC.onChatMemberUpdated( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = ChatMemberUpdatedFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = ChatMemberUpdatedFilterByChat, markerFactory: MarkerFactory = ByChatChatMemberUpdatedMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onChatMemberUpdatedInternal( + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = onChatMemberUpdatedInternal( initialFilter, subcontextUpdatesFilter, markerFactory, @@ -59,12 +59,12 @@ suspend fun BehaviourContext.onChatMemberUpdated( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onCommonChatMemberUpdated( +suspend fun BC.onCommonChatMemberUpdated( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = ChatMemberUpdatedFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = ChatMemberUpdatedFilterByChat, markerFactory: MarkerFactory = ByChatChatMemberUpdatedMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onChatMemberUpdatedInternal( + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = onChatMemberUpdatedInternal( initialFilter, subcontextUpdatesFilter, markerFactory, @@ -83,12 +83,12 @@ suspend fun BehaviourContext.onCommonChatMemberUpdated( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onMyChatMemberUpdated( +suspend fun BC.onMyChatMemberUpdated( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = ChatMemberUpdatedFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = ChatMemberUpdatedFilterByChat, markerFactory: MarkerFactory = ByChatChatMemberUpdatedMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onChatMemberUpdatedInternal( + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = onChatMemberUpdatedInternal( initialFilter, subcontextUpdatesFilter, markerFactory, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChosenInlineResultTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChosenInlineResultTriggers.kt index 5102f9c356..c2689cec06 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChosenInlineResultTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChosenInlineResultTriggers.kt @@ -11,11 +11,11 @@ import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.* import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.types.update.abstracts.Update -internal suspend inline fun BehaviourContext.onChosenInlineResultBase( +internal suspend inline fun BC.onChosenInlineResultBase( noinline initialFilter: SimpleFilter? = null, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, markerFactory: MarkerFactory = ByUserIdChosenInlineResultMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTypeReceiver + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { (it.asChosenInlineResultUpdate() ?.data as? T) ?.let(::listOfNotNull) } @@ -32,11 +32,11 @@ internal suspend inline fun BehaviourContext.on * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onChosenInlineResult( +suspend fun BC.onChosenInlineResult( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, markerFactory: MarkerFactory = ByUserIdChosenInlineResultMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onChosenInlineResultBase( initialFilter, subcontextUpdatesFilter, @@ -56,11 +56,11 @@ suspend fun BehaviourContext.onChosenInlineResult( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onLocationChosenInlineResult( +suspend fun BC.onLocationChosenInlineResult( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, markerFactory: MarkerFactory = ByUserIdChosenInlineResultMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onChosenInlineResultBase( initialFilter, subcontextUpdatesFilter, @@ -80,11 +80,11 @@ suspend fun BehaviourContext.onLocationChosenInlineResult( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onBaseChosenInlineResult( +suspend fun BC.onBaseChosenInlineResult( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, markerFactory: MarkerFactory = ByUserIdChosenInlineResultMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onChosenInlineResultBase( initialFilter, subcontextUpdatesFilter, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt index 5273249781..ad04efa0f2 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt @@ -16,13 +16,13 @@ import dev.inmo.tgbotapi.types.update.abstracts.Update import kotlinx.coroutines.Job -suspend fun BehaviourContext.command( +suspend fun BC.command( commandRegex: Regex, requireOnlyCommandInMessage: Boolean = true, initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ): Job = onText( CommonMessageFilter { message -> val content = message.content @@ -43,39 +43,39 @@ suspend fun BehaviourContext.command( scenarioReceiver ) -suspend fun BehaviourContext.command( +suspend fun BC.command( command: String, requireOnlyCommandInMessage: Boolean = true, initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = command(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) -suspend inline fun BehaviourContext.onCommand( +suspend inline fun BC.onCommand( commandRegex: Regex, requireOnlyCommandInMessage: Boolean = true, noinline initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTypeReceiver> + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ): Job = command(commandRegex, requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) -suspend inline fun BehaviourContext.onCommand( +suspend inline fun BC.onCommand( command: String, requireOnlyCommandInMessage: Boolean = true, noinline initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTypeReceiver> + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ): Job = onCommand(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) -suspend fun BehaviourContext.commandWithArgs( +suspend fun BC.commandWithArgs( commandRegex: Regex, initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTwoTypesReceiver, Array> + scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver, Array> ) = command( commandRegex, requireOnlyCommandInMessage = false, @@ -90,12 +90,12 @@ suspend fun BehaviourContext.commandWithArgs( scenarioReceiver(it, args) } -suspend fun BehaviourContext.commandWithArgs( +suspend fun BC.commandWithArgs( command: String, initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTwoTypesReceiver, Array> + scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver, Array> ) = commandWithArgs( command.toRegex(), initialFilter = initialFilter, @@ -104,18 +104,18 @@ suspend fun BehaviourContext.commandWithArgs( scenarioReceiver = scenarioReceiver ) -suspend inline fun BehaviourContext.onCommandWithArgs( +suspend inline fun BC.onCommandWithArgs( commandRegex: Regex, noinline initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTwoTypesReceiver, Array> + noinline scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver, Array> ): Job = commandWithArgs(commandRegex, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) -suspend inline fun BehaviourContext.onCommandWithArgs( +suspend inline fun BC.onCommandWithArgs( command: String, noinline initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTwoTypesReceiver, Array> + noinline scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver, Array> ): Job = onCommandWithArgs(command.toRegex(), initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt index 028a97d102..21a867bc4b 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt @@ -22,11 +22,11 @@ import dev.inmo.tgbotapi.types.update.abstracts.Update typealias CommonMessageFilter = SimpleFilter> inline fun CommonMessageFilter(noinline block: CommonMessageFilter) = block -internal suspend inline fun BehaviourContext.onContent( +internal suspend inline fun BC.onContent( noinline initialFilter: CommonMessageFilter? = null, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTypeReceiver> + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { when (it) { is BaseSentMessageUpdate -> it.data.whenCommonMessage(::listOfNotNull) @@ -50,11 +50,11 @@ internal suspend inline fun BehaviourContext.onCont * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onContentMessage( +suspend fun BC.onContentMessage( initialFilter: CommonMessageFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -74,11 +74,11 @@ suspend fun BehaviourContext.onContentMessage( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onContact( +suspend fun BC.onContact( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -98,11 +98,11 @@ suspend fun BehaviourContext.onContact( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onDice( +suspend fun BC.onDice( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -122,11 +122,11 @@ suspend fun BehaviourContext.onDice( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onGame( +suspend fun BC.onGame( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -146,11 +146,11 @@ suspend fun BehaviourContext.onGame( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onLocation( +suspend fun BC.onLocation( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -170,11 +170,11 @@ suspend fun BehaviourContext.onLocation( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onLiveLocation( +suspend fun BC.onLiveLocation( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -194,11 +194,11 @@ suspend fun BehaviourContext.onLiveLocation( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onStaticLocation( +suspend fun BC.onStaticLocation( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -218,11 +218,11 @@ suspend fun BehaviourContext.onStaticLocation( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onPoll( +suspend fun BC.onPoll( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -242,11 +242,11 @@ suspend fun BehaviourContext.onPoll( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onText( +suspend fun BC.onText( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -266,11 +266,11 @@ suspend fun BehaviourContext.onText( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onVenue( +suspend fun BC.onVenue( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -290,11 +290,11 @@ suspend fun BehaviourContext.onVenue( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onAudioMediaGroup( +suspend fun BC.onAudioMediaGroup( initialFilter: CommonMessageFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -314,11 +314,11 @@ suspend fun BehaviourContext.onAudioMediaGroup( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onDocumentMediaGroupContent( +suspend fun BC.onDocumentMediaGroupContent( initialFilter: CommonMessageFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -338,11 +338,11 @@ suspend fun BehaviourContext.onDocumentMediaGroupContent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onMediaCollection( +suspend fun BC.onMediaCollection( initialFilter: CommonMessageFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver>, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update> = MessageFilterByChat, markerFactory: MarkerFactory>, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver>> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -362,11 +362,11 @@ suspend fun BehaviourContext.onMediaCollection( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onMedia( +suspend fun BC.onMedia( initialFilter: CommonMessageFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -386,11 +386,11 @@ suspend fun BehaviourContext.onMedia( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onAnimation( +suspend fun BC.onAnimation( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -410,11 +410,11 @@ suspend fun BehaviourContext.onAnimation( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onAudio( +suspend fun BC.onAudio( initialFilter: CommonMessageFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -434,11 +434,11 @@ suspend fun BehaviourContext.onAudio( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onDocument( +suspend fun BC.onDocument( initialFilter: CommonMessageFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -458,11 +458,11 @@ suspend fun BehaviourContext.onDocument( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onPhoto( +suspend fun BC.onPhoto( initialFilter: CommonMessageFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -482,11 +482,11 @@ suspend fun BehaviourContext.onPhoto( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onSticker( +suspend fun BC.onSticker( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -506,11 +506,11 @@ suspend fun BehaviourContext.onSticker( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onVideo( +suspend fun BC.onVideo( initialFilter: CommonMessageFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -530,11 +530,11 @@ suspend fun BehaviourContext.onVideo( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onVideoNote( +suspend fun BC.onVideoNote( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -554,11 +554,11 @@ suspend fun BehaviourContext.onVideoNote( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onVoice( +suspend fun BC.onVoice( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, @@ -578,11 +578,11 @@ suspend fun BehaviourContext.onVoice( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onInvoice( +suspend fun BC.onInvoice( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onContent( initialFilter, subcontextUpdatesFilter, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt index dbbb7bd43b..a78aa2ca76 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt @@ -33,11 +33,11 @@ import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.utils.PreviewFeature @PreviewFeature -internal suspend inline fun BehaviourContext.onEditedContent( +internal suspend inline fun BC.onEditedContent( noinline initialFilter: CommonMessageFilter? = null, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTypeReceiver> + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { when (it) { is BaseEditMessageUpdate -> (it.asEditMessageUpdate() ?.data ?.withContent()) @@ -58,11 +58,11 @@ internal suspend inline fun BehaviourContext.onEdit * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedContentMessage( +suspend fun BC.onEditedContentMessage( initialFilter: CommonMessageFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -82,11 +82,11 @@ suspend fun BehaviourContext.onEditedContentMessage( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedContact( +suspend fun BC.onEditedContact( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -106,11 +106,11 @@ suspend fun BehaviourContext.onEditedContact( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedDice( +suspend fun BC.onEditedDice( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -130,11 +130,11 @@ suspend fun BehaviourContext.onEditedDice( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedGame( +suspend fun BC.onEditedGame( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -154,11 +154,11 @@ suspend fun BehaviourContext.onEditedGame( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedLocation( +suspend fun BC.onEditedLocation( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -167,11 +167,11 @@ suspend fun BehaviourContext.onEditedLocation( ) @Deprecated("Potentially, this trigger will never be used. Use `onPollUpdated` instead") -suspend fun BehaviourContext.onEditedPoll( +suspend fun BC.onEditedPoll( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -191,11 +191,11 @@ suspend fun BehaviourContext.onEditedPoll( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedText( +suspend fun BC.onEditedText( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -215,11 +215,11 @@ suspend fun BehaviourContext.onEditedText( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedVenue( +suspend fun BC.onEditedVenue( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -239,11 +239,11 @@ suspend fun BehaviourContext.onEditedVenue( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedAudioMediaGroup( +suspend fun BC.onEditedAudioMediaGroup( initialFilter: CommonMessageFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -263,11 +263,11 @@ suspend fun BehaviourContext.onEditedAudioMediaGroup( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedDocumentMediaGroupContent( +suspend fun BC.onEditedDocumentMediaGroupContent( initialFilter: CommonMessageFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -287,11 +287,11 @@ suspend fun BehaviourContext.onEditedDocumentMediaGroupContent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedMediaCollection( +suspend fun BC.onEditedMediaCollection( initialFilter: CommonMessageFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver>, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update> = MessageFilterByChat, markerFactory: MarkerFactory>, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver>> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -311,11 +311,11 @@ suspend fun BehaviourContext.onEditedMediaCollection( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedMedia( +suspend fun BC.onEditedMedia( initialFilter: CommonMessageFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -335,11 +335,11 @@ suspend fun BehaviourContext.onEditedMedia( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedAnimation( +suspend fun BC.onEditedAnimation( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -359,11 +359,11 @@ suspend fun BehaviourContext.onEditedAnimation( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedAudio( +suspend fun BC.onEditedAudio( initialFilter: CommonMessageFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -383,11 +383,11 @@ suspend fun BehaviourContext.onEditedAudio( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedDocument( +suspend fun BC.onEditedDocument( initialFilter: CommonMessageFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -407,11 +407,11 @@ suspend fun BehaviourContext.onEditedDocument( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedPhoto( +suspend fun BC.onEditedPhoto( initialFilter: CommonMessageFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -431,11 +431,11 @@ suspend fun BehaviourContext.onEditedPhoto( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedSticker( +suspend fun BC.onEditedSticker( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -455,11 +455,11 @@ suspend fun BehaviourContext.onEditedSticker( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedVideo( +suspend fun BC.onEditedVideo( initialFilter: CommonMessageFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -479,11 +479,11 @@ suspend fun BehaviourContext.onEditedVideo( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedVideoNote( +suspend fun BC.onEditedVideoNote( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -503,11 +503,11 @@ suspend fun BehaviourContext.onEditedVideoNote( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedVoice( +suspend fun BC.onEditedVoice( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, @@ -527,11 +527,11 @@ suspend fun BehaviourContext.onEditedVoice( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onEditedInvoice( +suspend fun BC.onEditedInvoice( initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> )= onEditedContent( initialFilter, subcontextUpdatesFilter, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt index 00d4f6e447..415e2e4f11 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt @@ -16,11 +16,11 @@ import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent import dev.inmo.tgbotapi.types.update.abstracts.Update -internal suspend inline fun BehaviourContext.onEvent( +internal suspend inline fun BC.onEvent( noinline initialFilter: SimpleFilter>? = null, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTypeReceiver> + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { (it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.takeIf { it.chatEvent is T } as? ChatEventMessage) ?.let(::listOfNotNull) } @@ -37,11 +37,11 @@ internal suspend inline fun BehaviourContext.onEvent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onChannelEvent( +suspend fun BC.onChannelEvent( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -56,11 +56,11 @@ suspend fun BehaviourContext.onChannelEvent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onPrivateEvent( +suspend fun BC.onPrivateEvent( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -75,11 +75,11 @@ suspend fun BehaviourContext.onPrivateEvent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onChatEvent( +suspend fun BC.onChatEvent( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -94,11 +94,11 @@ suspend fun BehaviourContext.onChatEvent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onVoiceChatEvent( +suspend fun BC.onVoiceChatEvent( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -113,11 +113,11 @@ suspend fun BehaviourContext.onVoiceChatEvent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onVoiceChatStartedEvent( +suspend fun BC.onVoiceChatStartedEvent( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -132,11 +132,11 @@ suspend fun BehaviourContext.onVoiceChatStartedEvent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onVoiceChatEndedEvent( +suspend fun BC.onVoiceChatEndedEvent( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -151,11 +151,11 @@ suspend fun BehaviourContext.onVoiceChatEndedEvent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onVoiceChatParticipantsInvitedEvent( +suspend fun BC.onVoiceChatParticipantsInvitedEvent( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -170,11 +170,11 @@ suspend fun BehaviourContext.onVoiceChatParticipantsInvitedEvent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onMessageAutoDeleteTimerChangedEvent( +suspend fun BC.onMessageAutoDeleteTimerChangedEvent( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -189,11 +189,11 @@ suspend fun BehaviourContext.onMessageAutoDeleteTimerChangedEvent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onPublicChatEvent( +suspend fun BC.onPublicChatEvent( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -208,11 +208,11 @@ suspend fun BehaviourContext.onPublicChatEvent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onCommonEvent( +suspend fun BC.onCommonEvent( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -227,11 +227,11 @@ suspend fun BehaviourContext.onCommonEvent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onGroupEvent( +suspend fun BC.onGroupEvent( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -246,11 +246,11 @@ suspend fun BehaviourContext.onGroupEvent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onSupergroupEvent( +suspend fun BC.onSupergroupEvent( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -265,11 +265,11 @@ suspend fun BehaviourContext.onSupergroupEvent( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onChannelChatCreated( +suspend fun BC.onChannelChatCreated( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -284,11 +284,11 @@ suspend fun BehaviourContext.onChannelChatCreated( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onDeleteChatPhoto( +suspend fun BC.onDeleteChatPhoto( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -303,11 +303,11 @@ suspend fun BehaviourContext.onDeleteChatPhoto( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onGroupChatCreated( +suspend fun BC.onGroupChatCreated( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -322,11 +322,11 @@ suspend fun BehaviourContext.onGroupChatCreated( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onLeftChatMember( +suspend fun BC.onLeftChatMember( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -341,11 +341,11 @@ suspend fun BehaviourContext.onLeftChatMember( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onNewChatMembers( +suspend fun BC.onNewChatMembers( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -360,11 +360,11 @@ suspend fun BehaviourContext.onNewChatMembers( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onNewChatPhoto( +suspend fun BC.onNewChatPhoto( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -379,11 +379,11 @@ suspend fun BehaviourContext.onNewChatPhoto( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onNewChatTitle( +suspend fun BC.onNewChatTitle( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -398,11 +398,11 @@ suspend fun BehaviourContext.onNewChatTitle( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onPinnedMessage( +suspend fun BC.onPinnedMessage( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -417,11 +417,11 @@ suspend fun BehaviourContext.onPinnedMessage( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onProximityAlertTriggered( +suspend fun BC.onProximityAlertTriggered( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -436,11 +436,11 @@ suspend fun BehaviourContext.onProximityAlertTriggered( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onSupergroupChatCreated( +suspend fun BC.onSupergroupChatCreated( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -455,9 +455,9 @@ suspend fun BehaviourContext.onSupergroupChatCreated( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onSuccessfulPayment( +suspend fun BC.onSuccessfulPayment( initialFilter: SimpleFilter>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt index be677995c9..fec661e30e 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt @@ -9,11 +9,11 @@ import dev.inmo.tgbotapi.extensions.utils.asInlineQueryUpdate import dev.inmo.tgbotapi.types.InlineQueries.query.* import dev.inmo.tgbotapi.types.update.abstracts.Update -internal suspend inline fun BehaviourContext.onInlineQuery( +internal suspend inline fun BC.onInlineQuery( noinline initialFilter: SimpleFilter? = null, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = InlineQueryFilterByUser, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = InlineQueryFilterByUser, markerFactory: MarkerFactory = ByUserInlineQueryMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTypeReceiver + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { (it.asInlineQueryUpdate() ?.data as? T) ?.let(::listOfNotNull) } @@ -30,11 +30,11 @@ internal suspend inline fun BehaviourContext.onInlineQ * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onAnyInlineQuery( +suspend fun BC.onAnyInlineQuery( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = InlineQueryFilterByUser, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = InlineQueryFilterByUser, markerFactory: MarkerFactory = ByUserInlineQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onInlineQuery(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) @@ -50,11 +50,11 @@ suspend fun BehaviourContext.onAnyInlineQuery( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onBaseInlineQuery( +suspend fun BC.onBaseInlineQuery( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = InlineQueryFilterByUser, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = InlineQueryFilterByUser, markerFactory: MarkerFactory = ByUserInlineQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onInlineQuery(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) @@ -70,9 +70,9 @@ suspend fun BehaviourContext.onBaseInlineQuery( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onLocationInlineQuery( +suspend fun BC.onLocationInlineQuery( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = InlineQueryFilterByUser, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = InlineQueryFilterByUser, markerFactory: MarkerFactory = ByUserInlineQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onInlineQuery(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt index 8556adc051..fc561aa605 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt @@ -7,14 +7,11 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory import dev.inmo.tgbotapi.types.update.abstracts.Update -internal const val OldAPITriggersDeprecationText = "This signature of method has been deprecated. Use signature with the" + - " same name and subcontextUpdatesFilter/initialFilter instead" - -internal suspend inline fun BehaviourContext.on( +internal suspend inline fun BC.on( markerFactory: MarkerFactory, noinline initialFilter: SimpleFilter? = null, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, - noinline scenarioReceiver: BehaviourContextAndTypeReceiver, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver, noinline updateToData: (Update) -> List? ) = flowsUpdatesFilter.expectFlow(bot) { updateToData(it) ?.mapNotNull { data -> diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt index 7ba44da28f..a308ecf3c0 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt @@ -16,11 +16,11 @@ import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.utils.PreviewFeature @PreviewFeature -internal suspend inline fun BehaviourContext.buildMediaGroupTrigger( +internal suspend inline fun BC.buildMediaGroupTrigger( noinline initialFilter: SimpleFilter>>? = null, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTypeReceiver>> + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> ) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { (it.asSentMediaGroupUpdate() ?.data ?.takeIf { it.all { it is T } } as? List>) ?.let(::listOfNotNull) } @@ -37,11 +37,11 @@ internal suspend inline fun BehaviourContext.bui * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onMediaGroup( +suspend fun BC.onMediaGroup( initialFilter: SimpleFilter>>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver>> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> ) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -56,11 +56,11 @@ suspend fun BehaviourContext.onMediaGroup( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onPlaylist( +suspend fun BC.onPlaylist( initialFilter: SimpleFilter>>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver>> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> ) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -75,11 +75,11 @@ suspend fun BehaviourContext.onPlaylist( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onDocumentsGroup( +suspend fun BC.onDocumentsGroup( initialFilter: SimpleFilter>>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver>> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> ) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -94,11 +94,11 @@ suspend fun BehaviourContext.onDocumentsGroup( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onVisualGallery( +suspend fun BC.onVisualGallery( initialFilter: SimpleFilter>>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver>> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> ) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -113,11 +113,11 @@ suspend fun BehaviourContext.onVisualGallery( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onVisualMediaGroup( +suspend fun BC.onVisualMediaGroup( initialFilter: SimpleFilter>>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver>> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> ) = onVisualGallery(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -132,11 +132,11 @@ suspend fun BehaviourContext.onVisualMediaGroup( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onPhotoGallery( +suspend fun BC.onPhotoGallery( initialFilter: SimpleFilter>>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver>> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> ) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** @@ -151,9 +151,9 @@ suspend fun BehaviourContext.onPhotoGallery( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onVideoGallery( +suspend fun BC.onVideoGallery( initialFilter: SimpleFilter>>? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver>, Update>? = MessagesFilterByChat, markerFactory: MarkerFactory>, Any> = ByChatMediaGroupMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver>> + scenarioReceiver: CustomBehaviourContextAndTypeReceiver>> ) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PassportTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PassportTriggers.kt index 84f1c177ec..e85c8bfe47 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PassportTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PassportTriggers.kt @@ -11,11 +11,11 @@ import dev.inmo.tgbotapi.types.message.PassportMessage import dev.inmo.tgbotapi.types.passport.encrypted.abstracts.EncryptedPassportElement import dev.inmo.tgbotapi.types.update.abstracts.Update -internal suspend inline fun BehaviourContext.onPassportMessageWith( +internal suspend inline fun BC.onPassportMessageWith( noinline initialFilter: SimpleFilter? = null, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = MessageFilterByChat, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = MessageFilterByChat, markerFactory: MarkerFactory = ByChatMessageMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTypeReceiver + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { (it.asMessageUpdate() ?.data ?.asPassportMessage() ?.takeIf { it.passportData.data.any { it is T } }) ?.let(::listOfNotNull) } @@ -33,12 +33,12 @@ internal suspend inline fun BehaviourCont * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onPassportMessage( +suspend fun BC.onPassportMessage( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = MessageFilterByChat, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = MessageFilterByChat, markerFactory: MarkerFactory = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver -) = onPassportMessageWith( + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = onPassportMessageWith( initialFilter, subcontextUpdatesFilter, markerFactory, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollAnswersTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollAnswersTriggers.kt index c8bfa9d6b3..15ebf39209 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollAnswersTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollAnswersTriggers.kt @@ -10,11 +10,11 @@ import dev.inmo.tgbotapi.extensions.utils.asPollUpdate import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.types.update.abstracts.Update -internal suspend inline fun BehaviourContext.onPollAnswered( +internal suspend inline fun BC.onPollAnswered( noinline initialFilter: SimpleFilter? = null, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, markerFactory: MarkerFactory = ByIdPollAnswerMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTypeReceiver + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { (it.asPollAnswerUpdate() ?.data) ?.let(::listOfNotNull) } @@ -31,11 +31,11 @@ internal suspend inline fun BehaviourContext.onPollAnswered( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onPollAnswer( +suspend fun BC.onPollAnswer( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, markerFactory: MarkerFactory = ByIdPollAnswerMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onPollAnswered( initialFilter, subcontextUpdatesFilter, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt index 570d05d175..92d0d652fa 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt @@ -9,11 +9,11 @@ import dev.inmo.tgbotapi.extensions.utils.asPollUpdate import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.types.update.abstracts.Update -internal suspend inline fun BehaviourContext.onPollUpdatedBase( +internal suspend inline fun BC.onPollUpdatedBase( noinline initialFilter: SimpleFilter? = null, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, markerFactory: MarkerFactory = ByIdPollMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTypeReceiver + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { (it.asPollUpdate() ?.data as? T) ?.let(::listOfNotNull) } @@ -30,11 +30,11 @@ internal suspend inline fun BehaviourContext.onPollUpdatedBas * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onPollUpdates( +suspend fun BC.onPollUpdates( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, markerFactory: MarkerFactory = ByIdPollMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onPollUpdatedBase( initialFilter, subcontextUpdatesFilter, @@ -54,11 +54,11 @@ suspend fun BehaviourContext.onPollUpdates( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onRegularPollUpdates( +suspend fun BC.onRegularPollUpdates( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, markerFactory: MarkerFactory = ByIdPollMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onPollUpdatedBase( initialFilter, subcontextUpdatesFilter, @@ -78,11 +78,11 @@ suspend fun BehaviourContext.onRegularPollUpdates( * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onQuizPollUpdates( +suspend fun BC.onQuizPollUpdates( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, markerFactory: MarkerFactory = ByIdPollMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = onPollUpdatedBase( initialFilter, subcontextUpdatesFilter, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PreCheckoutQueryTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PreCheckoutQueryTriggers.kt index e0a6be1a2f..bcd7b220c5 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PreCheckoutQueryTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PreCheckoutQueryTriggers.kt @@ -26,11 +26,11 @@ import dev.inmo.tgbotapi.types.update.abstracts.Update * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onPreCheckoutQuery( +suspend fun BC.onPreCheckoutQuery( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = PreCheckoutQueryFilterByUser, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = PreCheckoutQueryFilterByUser, markerFactory: MarkerFactory = ByUserPreCheckoutQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { (it.asPreCheckoutQueryUpdate() ?.data) ?.let(::listOfNotNull) } diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ShippingQueryTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ShippingQueryTriggers.kt index 559be79250..4fcbeab37e 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ShippingQueryTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ShippingQueryTriggers.kt @@ -25,11 +25,11 @@ import dev.inmo.tgbotapi.types.update.abstracts.Update * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that * data */ -suspend fun BehaviourContext.onShippingQuery( +suspend fun BC.onShippingQuery( initialFilter: SimpleFilter? = null, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver? = ShippingQueryFilterByUser, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = ShippingQueryFilterByUser, markerFactory: MarkerFactory = ByUserShippingQueryMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver + scenarioReceiver: CustomBehaviourContextAndTypeReceiver ) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { (it.asShippingQueryUpdate() ?.data) ?.let(::listOfNotNull) } diff --git a/tgbotapi.extensions.utils/README.md b/tgbotapi.extensions.utils/README.md index 3fef81edfe..d611fd6336 100644 --- a/tgbotapi.extensions.utils/README.md +++ b/tgbotapi.extensions.utils/README.md @@ -49,7 +49,7 @@ Dependency config presented here: To use last versions you will need to add one line in repositories block of your `build.gradle`: -`jcenter()` or `mavenCentral()` +`mavenCentral()` And add next line to your dependencies block: diff --git a/tgbotapi.extensions.utils/build.gradle b/tgbotapi.extensions.utils/build.gradle index 07aac2026e..eca97cef94 100644 --- a/tgbotapi.extensions.utils/build.gradle +++ b/tgbotapi.extensions.utils/build.gradle @@ -1,7 +1,6 @@ buildscript { repositories { mavenLocal() - jcenter() mavenCentral() } @@ -23,9 +22,7 @@ apply from: "publish.gradle" repositories { mavenLocal() - jcenter() mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } } kotlin { diff --git a/tgbotapi/build.gradle b/tgbotapi/build.gradle index fda252a629..6efa3efad7 100644 --- a/tgbotapi/build.gradle +++ b/tgbotapi/build.gradle @@ -1,7 +1,6 @@ buildscript { repositories { mavenLocal() - jcenter() mavenCentral() } @@ -23,9 +22,7 @@ apply from: "publish.gradle" repositories { mavenLocal() - jcenter() mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } } kotlin { @@ -43,6 +40,7 @@ kotlin { api project(":tgbotapi.extensions.api") api project(":tgbotapi.extensions.utils") api project(":tgbotapi.extensions.behaviour_builder") + api project(":tgbotapi.extensions.behaviour_builder.fsm") } } } From 5a192b00d4ede296fa65453a18c4c933aecf4ff0 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 14 Oct 2021 22:57:04 +0600 Subject: [PATCH 20/40] refactor of contentConverter --- CHANGELOG.md | 2 +- .../expectations/WaitContent.kt | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aef340cdc0..ff8199814e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ * `Common`: * `Version`: * `Serialization`: `1.2.2` -> `1.3.0` - * `MicroUtils`: `0.5.28` -> `0.7.0` + * `MicroUtils`: `0.5.28` -> `0.7.1` * `Klock`: `2.4.3` -> `2.4.5` * `Core`: * `PayInlineKeyboardButton#pay` now is deprecated diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt index 08a60ddce1..b93449737e 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt @@ -16,6 +16,7 @@ import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.toList +import kotlin.reflect.KClass typealias CommonMessageToContentMapper = suspend CommonMessage.() -> T? @@ -54,19 +55,17 @@ private suspend fun BehaviourContext.waitCommonMessage( internal inline fun contentConverter( noinline mapper: CommonMessageToContentMapper? = null -): suspend CommonMessage.() -> T? = { - if (content is T) { - @Suppress("UNCHECKED_CAST") - val message = (this as CommonMessage) - if (mapper == null) { - message.content - } else { +): suspend CommonMessage.() -> T? = mapper ?.let { + { + if (content is T) { + @Suppress("UNCHECKED_CAST") + val message = (this as CommonMessage) safelyWithoutExceptions { mapper(message) } + } else { + null } - } else { - null } -} +} ?: { content as? T } private suspend inline fun BehaviourContext.waitContent( count: Int = 1, From ad9bc36f8c7b8ec526535be4bcb928aeacc16622 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 14 Oct 2021 23:05:11 +0600 Subject: [PATCH 21/40] all triggers in behaviour builder now use accumulator flow --- .../extensions/behaviour_builder/BehaviourContext.kt | 11 ++++++++--- .../triggers_handling/MainTrigger.kt | 7 +++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt index c81e7a5981..11fdc2142b 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt @@ -144,16 +144,19 @@ suspend fun BC.doInSubContextWithFlowsUpdatesFilterSe suspend fun BC.doInSubContextWithUpdatesFilter( updatesFilter: CustomBehaviourContextAndTypeReceiver?, stopOnCompletion: Boolean = true, + updatesUpstreamFlow: Flow = allUpdatesFlow, + scope: CoroutineScope = LinkedSupervisorScope(), behaviourContextReceiver: CustomBehaviourContextReceiver ): T = copy( - scope = LinkedSupervisorScope(), + scope = scope, updatesFilter = updatesFilter ?.let { _ -> { (this as? BC) ?.run { updatesFilter(it) } ?: true } - } + }, + upstreamUpdatesFlow = updatesUpstreamFlow ).run { withContext(coroutineContext) { behaviourContextReceiver().also { if (stopOnCompletion) stop() } @@ -162,8 +165,10 @@ suspend fun BC.doInSubContextWithUpdatesFilter( suspend fun BehaviourContext.doInSubContext( stopOnCompletion: Boolean = true, + updatesUpstreamFlow: Flow = allUpdatesFlow, + scope: CoroutineScope = LinkedSupervisorScope(), behaviourContextReceiver: BehaviourContextReceiver -) = doInSubContextWithUpdatesFilter(updatesFilter = null, stopOnCompletion, behaviourContextReceiver) +) = doInSubContextWithUpdatesFilter(updatesFilter = null, stopOnCompletion, updatesUpstreamFlow, scope, behaviourContextReceiver) /** * This method will cancel ALL subsequent contexts, expectations and waiters diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt index fc561aa605..6618479bec 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt @@ -1,6 +1,6 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling -import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptionsAsync +import dev.inmo.micro_utils.coroutines.* import dev.inmo.tgbotapi.extensions.behaviour_builder.* import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.expectFlow import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter @@ -21,9 +21,12 @@ internal suspend inline fun BC.on( scope, markerFactory::invoke ) { triggerData -> + val scope = LinkedSupervisorScope() doInSubContextWithUpdatesFilter( updatesFilter = subcontextUpdatesFilter ?.toOneType(triggerData), - stopOnCompletion = false + stopOnCompletion = false, + updatesUpstreamFlow = allUpdatesFlow.accumulatorFlow(scope), + scope = scope ) { scenarioReceiver(triggerData) } From 179a724d20961a7bbe84641e652ccbadfa18abba Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 15 Oct 2021 16:28:17 +0600 Subject: [PATCH 22/40] several actualizations for behaviour builder with fsm --- .../BehaviourContextWithFSM.kt | 2 + .../BehaviourContextWithFSMBuilder.kt | 93 +++++++++++++++++-- .../behaviour_builder/TelegramBotWithFSM.kt | 93 +++++++++++++++++++ 3 files changed, 182 insertions(+), 6 deletions(-) create mode 100644 tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt diff --git a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt index 26fc50ea66..98f79aa270 100644 --- a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt +++ b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt @@ -21,6 +21,8 @@ private suspend fun BehaviourContextWithFSM.launchStateHandling( } interface BehaviourContextWithFSM : BehaviourContext, StatesMachine { + suspend fun start() = start(this) + override fun copy( bot: TelegramBot, scope: CoroutineScope, diff --git a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt index cdcd5d2e86..96ca461801 100644 --- a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt +++ b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt @@ -1,14 +1,18 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder +import dev.inmo.micro_utils.coroutines.ContextSafelyExceptionHandler +import dev.inmo.micro_utils.coroutines.ExceptionHandler import dev.inmo.micro_utils.fsm.common.* import dev.inmo.micro_utils.fsm.common.managers.DefaultStatesManager import dev.inmo.micro_utils.fsm.common.managers.InMemoryDefaultStatesManagerRepo import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling +import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling import dev.inmo.tgbotapi.types.update.abstracts.Update -import kotlinx.coroutines.CoroutineScope +import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter +import dev.inmo.tgbotapi.utils.PreviewFeature +import kotlinx.coroutines.* import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.launch import kotlin.reflect.KClass class BehaviourContextWithFSMBuilder internal constructor( @@ -83,9 +87,13 @@ inline fun BehaviourContextWithFSMBuilder.strictlyOn(handler suspend fun TelegramBot.buildBehaviourWithFSM( upstreamUpdatesFlow: Flow? = null, scope: CoroutineScope = defaultCoroutineScopeProvider(), + statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), + handlersPreset: MutableList> = mutableListOf(), block: suspend BehaviourContextWithFSMBuilder.() -> Unit ) = BehaviourContextWithFSMBuilder( - DefaultBehaviourContext(this, scope, upstreamUpdatesFlow = upstreamUpdatesFlow) + DefaultBehaviourContext(this, scope, upstreamUpdatesFlow = upstreamUpdatesFlow), + statesManager, + handlersPreset ).apply { block() }.build() /** @@ -98,10 +106,83 @@ suspend fun TelegramBot.buildBehaviourWithFSM( suspend fun TelegramBot.buildBehaviourWithFSMAndLongPolling( upstreamUpdatesFlow: Flow? = null, scope: CoroutineScope = defaultCoroutineScopeProvider(), + statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), + presetHandlers: MutableList> = mutableListOf(), block: suspend BehaviourContextWithFSMBuilder.() -> Unit -) = buildBehaviourWithFSM(upstreamUpdatesFlow, scope, block).run { +) = buildBehaviourWithFSM(upstreamUpdatesFlow, scope, statesManager, presetHandlers, block).run { this to scope.launch { - longPolling(this@run, scope = this) - start(this) + start() + longPolling(flowsUpdatesFilter, scope = scope) + } +} + +/** + * Use this method in case you wish to make some additional actions with [flowUpdatesFilter]. + * + * **WARNING** This method WILL NOT launch any listening of updates. Use something like + * [startGettingOfUpdatesByLongPolling] (or just [longPolling]) or tools for work with webhooks + * + * @see BehaviourContext + * @see BehaviourContextWithFSM + * @see longPolling + * @see strictlyOn + * @see onStateOrSubstate + */ +@PreviewFeature +suspend fun TelegramBot.buildBehaviourWithFSM( + flowUpdatesFilter: FlowsUpdatesFilter, + scope: CoroutineScope = defaultCoroutineScopeProvider(), + defaultExceptionsHandler: ExceptionHandler? = null, + statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), + presetHandlers: MutableList> = mutableListOf(), + block: CustomBehaviourContextReceiver +): BehaviourContextWithFSM = BehaviourContextWithFSMBuilder( + BehaviourContext( + this, + scope.let { + if (defaultExceptionsHandler == null) { + it + } else { + it + ContextSafelyExceptionHandler(defaultExceptionsHandler) + } + }, + flowUpdatesFilter + ), + statesManager, + presetHandlers +).apply { block() }.build() + +/** + * Use this method to build bot behaviour with FSM and run it via long polling. In case you wish to use + * [FlowsUpdatesFilter] of result [BehaviourContextWithFSM] for additional manipulations, you must provide external + * [FlowsUpdatesFilter] in other [buildBehaviourWithFSM] function. + * + * @see buildBehaviourWithFSM + * @see BehaviourContext + * @see longPolling + * @see strictlyOn + * @see onStateOrSubstate + */ +@PreviewFeature +suspend fun TelegramBot.buildBehaviourWithFSM( + scope: CoroutineScope = defaultCoroutineScopeProvider(), + defaultExceptionsHandler: ExceptionHandler? = null, + statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), + presetHandlers: MutableList> = mutableListOf(), + block: BehaviourContextReceiver +) = FlowsUpdatesFilter().let { + buildBehaviourWithFSM( + it, + scope, + defaultExceptionsHandler, + statesManager, + presetHandlers, + block + ).run { + start() + longPolling( + flowsUpdatesFilter, + scope = scope + ) } } diff --git a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt new file mode 100644 index 0000000000..23eb0fe7bc --- /dev/null +++ b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt @@ -0,0 +1,93 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder + +import dev.inmo.micro_utils.coroutines.ExceptionHandler +import dev.inmo.micro_utils.fsm.common.StatesManager +import dev.inmo.micro_utils.fsm.common.managers.DefaultStatesManager +import dev.inmo.micro_utils.fsm.common.managers.InMemoryDefaultStatesManagerRepo +import dev.inmo.tgbotapi.bot.Ktor.KtorRequestsExecutorBuilder +import dev.inmo.tgbotapi.bot.Ktor.telegramBot +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling +import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter +import dev.inmo.tgbotapi.utils.telegramBotAPIDefaultUrl +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Job +import kotlin.coroutines.coroutineContext + + +/** + * Create bot using [telegramBot] and start listening for updates using [buildBehaviour]. + * Use this method in case you wish to make some additional actions with [flowsUpdatesFilter]. + * + * **WARNING** This method WILL NOT launch any listening of updates. Use something like + * [startGettingOfUpdatesByLongPolling] or tools for work with webhooks + * + * @return Created bot which has been used to create [BehaviourContext] via [buildBehaviour] + * + * @see [BehaviourContext] + * @see [buildBehaviour] + * @see startGettingOfUpdatesByLongPolling + */ +suspend fun telegramBotWithBehaviourAndFSM( + token: String, + flowsUpdatesFilter: FlowsUpdatesFilter, + scope: CoroutineScope? = null, + apiUrl: String = telegramBotAPIDefaultUrl, + builder: KtorRequestsExecutorBuilder.() -> Unit = {}, + defaultExceptionsHandler: ExceptionHandler? = null, + statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), + presetHandlers: MutableList> = mutableListOf(), + block: BehaviourContextReceiver +): TelegramBot = telegramBot( + token, + apiUrl, + builder +).apply { + buildBehaviourWithFSM( + flowsUpdatesFilter, + scope ?: CoroutineScope(coroutineContext), + defaultExceptionsHandler, + statesManager, + presetHandlers, + block + ) +} + +/** + * Create bot using [telegramBot] and start listening for updates using [buildBehaviour]. + * Use this method in case you wish to make some additional actions with [flowsUpdatesFilter]. + * + * **WARNING** This method WILL NOT launch any listening of updates. Use something like + * [startGettingOfUpdatesByLongPolling] or tools for work with webhooks + * + * @return Pair of [TelegramBot] and [Job]. This [Job] can be used to stop listening updates in your [block] you passed + * here + * + * @see [BehaviourContext] + * @see [buildBehaviour] + * @see startGettingOfUpdatesByLongPolling + */ +suspend fun telegramBotWithBehaviourAndFSM( + token: String, + scope: CoroutineScope? = null, + apiUrl: String = telegramBotAPIDefaultUrl, + builder: KtorRequestsExecutorBuilder.() -> Unit = {}, + defaultExceptionsHandler: ExceptionHandler? = null, + statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), + presetHandlers: MutableList> = mutableListOf(), + block: BehaviourContextReceiver +): Pair { + return telegramBot( + token, + apiUrl, + builder + ).let { + it to it.buildBehaviourWithFSM ( + scope ?: CoroutineScope(coroutineContext), + defaultExceptionsHandler, + statesManager, + presetHandlers, + block + ) + } +} From 19d221fc294f7cd245fd9ed878325831a17e7323 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 15 Oct 2021 16:37:20 +0600 Subject: [PATCH 23/40] fixes --- .../behaviour_builder/BehaviourContextWithFSMBuilder.kt | 6 +++--- .../extensions/behaviour_builder/TelegramBotWithFSM.kt | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt index 96ca461801..17015fe5ee 100644 --- a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt +++ b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt @@ -89,7 +89,7 @@ suspend fun TelegramBot.buildBehaviourWithFSM( scope: CoroutineScope = defaultCoroutineScopeProvider(), statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), handlersPreset: MutableList> = mutableListOf(), - block: suspend BehaviourContextWithFSMBuilder.() -> Unit + block: CustomBehaviourContextReceiver ) = BehaviourContextWithFSMBuilder( DefaultBehaviourContext(this, scope, upstreamUpdatesFlow = upstreamUpdatesFlow), statesManager, @@ -108,7 +108,7 @@ suspend fun TelegramBot.buildBehaviourWithFSMAndLongPolling( scope: CoroutineScope = defaultCoroutineScopeProvider(), statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), presetHandlers: MutableList> = mutableListOf(), - block: suspend BehaviourContextWithFSMBuilder.() -> Unit + block: CustomBehaviourContextReceiver ) = buildBehaviourWithFSM(upstreamUpdatesFlow, scope, statesManager, presetHandlers, block).run { this to scope.launch { start() @@ -169,7 +169,7 @@ suspend fun TelegramBot.buildBehaviourWithFSM( defaultExceptionsHandler: ExceptionHandler? = null, statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), presetHandlers: MutableList> = mutableListOf(), - block: BehaviourContextReceiver + block: CustomBehaviourContextReceiver ) = FlowsUpdatesFilter().let { buildBehaviourWithFSM( it, diff --git a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt index 23eb0fe7bc..39f4ba3c69 100644 --- a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt +++ b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt @@ -37,7 +37,7 @@ suspend fun telegramBotWithBehaviourAndFSM( defaultExceptionsHandler: ExceptionHandler? = null, statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), presetHandlers: MutableList> = mutableListOf(), - block: BehaviourContextReceiver + block: CustomBehaviourContextReceiver ): TelegramBot = telegramBot( token, apiUrl, @@ -75,7 +75,7 @@ suspend fun telegramBotWithBehaviourAndFSM( defaultExceptionsHandler: ExceptionHandler? = null, statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), presetHandlers: MutableList> = mutableListOf(), - block: BehaviourContextReceiver + block: CustomBehaviourContextReceiver ): Pair { return telegramBot( token, From c5ff0dbc549d042d827603d42defc9a840d2b140 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 15 Oct 2021 17:13:03 +0600 Subject: [PATCH 24/40] fixes --- .../BehaviourContextWithFSMBuilder.kt | 154 ++++++++++-------- .../behaviour_builder/TelegramBotWithFSM.kt | 10 +- .../behaviour_builder/BehaviourContext.kt | 4 +- 3 files changed, 92 insertions(+), 76 deletions(-) diff --git a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt index 17015fe5ee..a7e41bad85 100644 --- a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt +++ b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt @@ -1,7 +1,6 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder -import dev.inmo.micro_utils.coroutines.ContextSafelyExceptionHandler -import dev.inmo.micro_utils.coroutines.ExceptionHandler +import dev.inmo.micro_utils.coroutines.* import dev.inmo.micro_utils.fsm.common.* import dev.inmo.micro_utils.fsm.common.managers.DefaultStatesManager import dev.inmo.micro_utils.fsm.common.managers.InMemoryDefaultStatesManagerRepo @@ -48,6 +47,32 @@ class BehaviourContextWithFSMBuilder internal constructor( handlers.add(BehaviourWithFSMStateHandlerHolder(kClass, true, handler)) } + + /** + * Add NON STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Non strict means that + * for input [State] will be used [KClass.isInstance] and any inheritor of [kClass] will pass this requirement + * + * @see BehaviourWithFSMStateHandlerHolder + * @see BehaviourContextWithFSMBuilder.add + */ + @Suppress("MemberVisibilityCanBePrivate") + inline fun onStateOrSubstate(handler: BehaviourWithFSMStateHandler) { + add(I::class, handler) + } + + /** + * Add STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Strict means that + * for input [State] will be used [State]::class == [kClass] and any [State] with exactly the same type will pass + * requirements + * + * @see BehaviourWithFSMStateHandlerHolder + * @see BehaviourContextWithFSMBuilder.addStrict + */ + @Suppress("MemberVisibilityCanBePrivate") + inline fun strictlyOn(handler: BehaviourWithFSMStateHandler) { + addStrict(I::class, handler) + } + /** * Returns completed [resultBehaviourContext], [handlers] and [statesManager] */ @@ -55,61 +80,52 @@ class BehaviourContextWithFSMBuilder internal constructor( } /** - * Add NON STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Non strict means that - * for input [State] will be used [KClass.isInstance] and any inheritor of [kClass] will pass this requirement + * Creates [BehaviourContextWithFSM] via creating of [DefaultBehaviourContext] with [this] as [TelegramBot], + * [scope] as target scope for that [DefaultBehaviourContext] and [upstreamUpdatesFlow]. Pass [statesManager] + * to customize some internal logic of states changes. Pass [presetHandlers] in case you have some list of + * [BehaviourWithFSMStateHandlerHolder] with presets. * - * @see BehaviourWithFSMStateHandlerHolder - * @see BehaviourContextWithFSMBuilder.add - */ -inline fun BehaviourContextWithFSMBuilder.onStateOrSubstate(handler: BehaviourWithFSMStateHandler) { - add(I::class, handler) -} - -/** - * Add STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Strict means that - * for input [State] will be used [State]::class == [kClass] and any [State] with exactly the same type will pass - * requirements - * - * @see BehaviourWithFSMStateHandlerHolder - * @see BehaviourContextWithFSMBuilder.addStrict - */ -inline fun BehaviourContextWithFSMBuilder.strictlyOn(handler: BehaviourWithFSMStateHandler) { - addStrict(I::class, handler) -} - -/** - * Use this factory to create and organize behaviour of your bot with attention to FSM logic. This factory WILL NOT - * start any incoming updates handling of FSM handling, you must start it by yourself - * - * @param upstreamUpdatesFlow Will be used in [BehaviourContextWithFSMBuilder.build] to put it in new [BehaviourContextWithFSM] - * @param scope This [CoroutineScope] will be used in [BehaviourContextWithFSMBuilder.build] to put it in new [BehaviourContextWithFSM] + * !!! WARNING !!! This method WILL NOT call [BehaviourContextWithFSM.start] of result object and WILL NOT + * start any updates retrieving. See [buildBehaviourWithFSMAndStartLongPolling] or + * [telegramBotWithBehaviourAndFSMAndStartLongPolling] in case you wish to start [longPolling] automatically */ suspend fun TelegramBot.buildBehaviourWithFSM( upstreamUpdatesFlow: Flow? = null, scope: CoroutineScope = defaultCoroutineScopeProvider(), - statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), - handlersPreset: MutableList> = mutableListOf(), - block: CustomBehaviourContextReceiver -) = BehaviourContextWithFSMBuilder( - DefaultBehaviourContext(this, scope, upstreamUpdatesFlow = upstreamUpdatesFlow), - statesManager, - handlersPreset -).apply { block() }.build() - -/** - * Use this factory to create and organize behaviour of your bot with attention to FSM logic. This factory will start - * listening of updates by [longPolling] - * - * @param upstreamUpdatesFlow Will be used in [BehaviourContextWithFSMBuilder.build] to put it in new [BehaviourContextWithFSM] - * @param scope This [CoroutineScope] will be used in [BehaviourContextWithFSMBuilder.build] to put it in new [BehaviourContextWithFSM] - */ -suspend fun TelegramBot.buildBehaviourWithFSMAndLongPolling( - upstreamUpdatesFlow: Flow? = null, - scope: CoroutineScope = defaultCoroutineScopeProvider(), + defaultExceptionsHandler: ExceptionHandler? = null, statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), presetHandlers: MutableList> = mutableListOf(), block: CustomBehaviourContextReceiver -) = buildBehaviourWithFSM(upstreamUpdatesFlow, scope, statesManager, presetHandlers, block).run { +): BehaviourContextWithFSM = BehaviourContextWithFSMBuilder( + DefaultBehaviourContext( + this, + defaultExceptionsHandler ?.let { scope + ContextSafelyExceptionHandler(it) } ?: scope, + upstreamUpdatesFlow = upstreamUpdatesFlow + ), + statesManager, + presetHandlers +).apply { block() }.build() + +/** + * Use [buildBehaviourWithFSM] to create [BehaviourContextWithFSM] and launch getting of updates + * using [longPolling]. For [longPolling] will be used result [BehaviourContextWithFSM] for both parameters + * flowsUpdatesFilter and scope + */ +suspend fun TelegramBot.buildBehaviourWithFSMAndStartLongPolling( + upstreamUpdatesFlow: Flow? = null, + scope: CoroutineScope = defaultCoroutineScopeProvider(), + defaultExceptionsHandler: ExceptionHandler? = null, + statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), + presetHandlers: MutableList> = mutableListOf(), + block: CustomBehaviourContextReceiver +): Pair = buildBehaviourWithFSM( + upstreamUpdatesFlow, + scope, + defaultExceptionsHandler, + statesManager, + presetHandlers, + block +).run { this to scope.launch { start() longPolling(flowsUpdatesFilter, scope = scope) @@ -117,16 +133,22 @@ suspend fun TelegramBot.buildBehaviourWithFSMAndLongPolling( } /** + * Creates [BehaviourContextWithFSM] via creating of [DefaultBehaviourContext] with [this] as [TelegramBot], + * [scope] as target scope for that [DefaultBehaviourContext] and [FlowsUpdatesFilter.allUpdatesFlow] of + * [flowUpdatesFilter] as [DefaultBehaviourContext.upstreamUpdatesFlow]. Pass [statesManager] + * to customize some internal logic of states changes. Pass [presetHandlers] in case you have some list of + * [BehaviourWithFSMStateHandlerHolder] with presets. * Use this method in case you wish to make some additional actions with [flowUpdatesFilter]. * - * **WARNING** This method WILL NOT launch any listening of updates. Use something like - * [startGettingOfUpdatesByLongPolling] (or just [longPolling]) or tools for work with webhooks + * !!! WARNING !!! This method WILL NOT call [BehaviourContextWithFSM.start] of result object and WILL NOT + * start any updates retrieving. See [buildBehaviourWithFSMAndStartLongPolling] or + * [telegramBotWithBehaviourAndFSMAndStartLongPolling] in case you wish to start [longPolling] automatically * * @see BehaviourContext * @see BehaviourContextWithFSM * @see longPolling - * @see strictlyOn - * @see onStateOrSubstate + * @see BehaviourContextWithFSMBuilder.strictlyOn + * @see BehaviourContextWithFSMBuilder.onStateOrSubstate */ @PreviewFeature suspend fun TelegramBot.buildBehaviourWithFSM( @@ -137,34 +159,28 @@ suspend fun TelegramBot.buildBehaviourWithFSM( presetHandlers: MutableList> = mutableListOf(), block: CustomBehaviourContextReceiver ): BehaviourContextWithFSM = BehaviourContextWithFSMBuilder( - BehaviourContext( + DefaultBehaviourContext( this, - scope.let { - if (defaultExceptionsHandler == null) { - it - } else { - it + ContextSafelyExceptionHandler(defaultExceptionsHandler) - } - }, - flowUpdatesFilter + defaultExceptionsHandler ?.let { scope + ContextSafelyExceptionHandler(it) } ?: scope, + upstreamUpdatesFlow = flowUpdatesFilter.allUpdatesFlow ), statesManager, presetHandlers ).apply { block() }.build() /** - * Use this method to build bot behaviour with FSM and run it via long polling. In case you wish to use - * [FlowsUpdatesFilter] of result [BehaviourContextWithFSM] for additional manipulations, you must provide external - * [FlowsUpdatesFilter] in other [buildBehaviourWithFSM] function. + * Use [buildBehaviourWithFSM] to create [BehaviourContextWithFSM] and launch getting of updates + * using [longPolling]. For [longPolling] will be used result [BehaviourContextWithFSM] for both parameters + * flowsUpdatesFilter and scope * - * @see buildBehaviourWithFSM + * @see buildBehaviourWithFSMAndStartLongPolling * @see BehaviourContext * @see longPolling - * @see strictlyOn - * @see onStateOrSubstate + * @see BehaviourContextWithFSMBuilder.strictlyOn + * @see BehaviourContextWithFSMBuilder.onStateOrSubstate */ @PreviewFeature -suspend fun TelegramBot.buildBehaviourWithFSM( +suspend fun TelegramBot.buildBehaviourWithFSMAndStartLongPolling( scope: CoroutineScope = defaultCoroutineScopeProvider(), defaultExceptionsHandler: ExceptionHandler? = null, statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), diff --git a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt index 39f4ba3c69..811039d473 100644 --- a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt +++ b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt @@ -16,7 +16,7 @@ import kotlin.coroutines.coroutineContext /** - * Create bot using [telegramBot] and start listening for updates using [buildBehaviour]. + * Create bot using [telegramBot] and start listening for updates using [buildBehaviourWithFSM]. * Use this method in case you wish to make some additional actions with [flowsUpdatesFilter]. * * **WARNING** This method WILL NOT launch any listening of updates. Use something like @@ -43,8 +43,8 @@ suspend fun telegramBotWithBehaviourAndFSM( apiUrl, builder ).apply { - buildBehaviourWithFSM( - flowsUpdatesFilter, + buildBehaviourWithFSMAndStartLongPolling( + flowsUpdatesFilter.allUpdatesFlow, scope ?: CoroutineScope(coroutineContext), defaultExceptionsHandler, statesManager, @@ -67,7 +67,7 @@ suspend fun telegramBotWithBehaviourAndFSM( * @see [buildBehaviour] * @see startGettingOfUpdatesByLongPolling */ -suspend fun telegramBotWithBehaviourAndFSM( +suspend fun telegramBotWithBehaviourAndFSMAndStartLongPolling( token: String, scope: CoroutineScope? = null, apiUrl: String = telegramBotAPIDefaultUrl, @@ -82,7 +82,7 @@ suspend fun telegramBotWithBehaviourAndFSM( apiUrl, builder ).let { - it to it.buildBehaviourWithFSM ( + it to it.buildBehaviourWithFSMAndStartLongPolling ( scope ?: CoroutineScope(coroutineContext), defaultExceptionsHandler, statesManager, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt index 11fdc2142b..0b62483ba6 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt @@ -67,8 +67,8 @@ interface BehaviourContext : FlowsUpdatesFilter, TelegramBot, CoroutineScope { class DefaultBehaviourContext( override val bot: TelegramBot, override val scope: CoroutineScope, - private val broadcastChannelsSize: Int = 100, - private val onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND, + broadcastChannelsSize: Int = 100, + onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND, private val upstreamUpdatesFlow: Flow? = null, private val updatesFilter: BehaviourContextAndTypeReceiver? = null ) : AbstractFlowsUpdatesFilter(), TelegramBot by bot, CoroutineScope by scope, BehaviourContext { From 9c15410c4eda616c855b081c196a092e69b512ed Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 15 Oct 2021 17:37:14 +0600 Subject: [PATCH 25/40] update kdoc of telegramBotWithBehaviourAndFSMAndStartLongPolling --- .../extensions/behaviour_builder/TelegramBotWithFSM.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt index 811039d473..23ead91b93 100644 --- a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt +++ b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt @@ -54,11 +54,8 @@ suspend fun telegramBotWithBehaviourAndFSM( } /** - * Create bot using [telegramBot] and start listening for updates using [buildBehaviour]. - * Use this method in case you wish to make some additional actions with [flowsUpdatesFilter]. - * - * **WARNING** This method WILL NOT launch any listening of updates. Use something like - * [startGettingOfUpdatesByLongPolling] or tools for work with webhooks + * Create bot using [telegramBot] and start listening for updates using [buildBehaviourWithFSMAndStartLongPolling]. This + * method will launch updates retrieving via long polling inside of [buildBehaviourWithFSMAndStartLongPolling] * * @return Pair of [TelegramBot] and [Job]. This [Job] can be used to stop listening updates in your [block] you passed * here From 4ac01d010491d9e9f222a5e3e8e5c4b58340c67f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 15 Oct 2021 17:40:23 +0600 Subject: [PATCH 26/40] update onSuccessPayment kdocs --- .../behaviour_builder/triggers_handling/EventTriggers.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt index 415e2e4f11..4fe6b2c3a3 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt @@ -444,13 +444,16 @@ suspend fun BC.onSupergroupChatCreated( ) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) /** + * Please, remember that [SuccessfulPaymentEvent] will be retrieved only in case you will correctly handle + * [dev.inmo.tgbotapi.types.payments.PreCheckoutQuery] (via [onPreCheckoutQuery], for example) + * * @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 + * @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 From 21c0e375f52a9cada63a242383e09be30dda5138 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 15 Oct 2021 17:55:13 +0600 Subject: [PATCH 27/40] update kdocs of BehaviourContextWithFSM --- CHANGELOG.md | 7 ++++++- .../behaviour_builder/BehaviourContextWithFSM.kt | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff8199814e..52675de8bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,12 +9,17 @@ * `Serialization`: `1.2.2` -> `1.3.0` * `MicroUtils`: `0.5.28` -> `0.7.1` * `Klock`: `2.4.3` -> `2.4.5` + * `Ktor`: `1.6.3` -> `1.6.4` * `Core`: + * `PrivateContentMessageImpl#paymentInfo` now is deprecated and will always be null * `PayInlineKeyboardButton#pay` now is deprecated * `RowBuilder` and `MatrixBuilder` now are open and available for extending * `MatrixBuilder#matrix` will return read-only new list instead of original internal `mutMatrix` * Introduced new type of events `SuccessfulPaymentEvent` instead of putting of payment inside of message - * New type of events union: `PublicChatEvent` + * New type of events union: `PublicChatEvent`. `CommonEvent` is still union of any `ChatEvent` + * New `AbstractFlowsUpdatesFilter` with default `lazy` realization for all typed flows + * `FlowsUpdatesFilter` fun now have `onBufferOverflow` and `upstreamUpdatesFlow` as incoming params + * `DefaultFlowsUpdatesFilter` now use additional `upstreamUpdatesFlow` as source of updates * `Utils`: * Two new dsl: * `inlineKeyboard` for creating `InlineKeyboardMarkup` diff --git a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt index 98f79aa270..69e4529dbb 100644 --- a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt +++ b/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt @@ -20,6 +20,13 @@ private suspend fun BehaviourContextWithFSM.launchStateHandling( } } +/** + * Interface which combine [BehaviourContext] and [StatesMachine]. Subcontext of triggers and states contexts must have + * one common flow of updates and must not lose updates between updates + * + * @see DefaultBehaviourContextWithFSM + * @see buildBehaviourWithFSM + */ interface BehaviourContextWithFSM : BehaviourContext, StatesMachine { suspend fun start() = start(this) @@ -41,6 +48,10 @@ interface BehaviourContextWithFSM : BehaviourContext, StatesMachine { } } +/** + * Default realization of [BehaviourContextWithFSM]. It uses [behaviourContext] as a base for this object as + * [BehaviourContext], but managing substates contexts updates for avoiding of updates lost between states + */ class DefaultBehaviourContextWithFSM( private val behaviourContext: BehaviourContext, private val statesManager: StatesManager, From 5e2df1cb4a2e113665c52a2836470f1a779d80e4 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 15 Oct 2021 18:24:06 +0600 Subject: [PATCH 28/40] a little fill of Readme for fsm behaviour builder --- tgbotapi.extensions.behaviour_builder.fsm/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tgbotapi.extensions.behaviour_builder.fsm/README.md b/tgbotapi.extensions.behaviour_builder.fsm/README.md index 15817d3d3e..50375a9607 100644 --- a/tgbotapi.extensions.behaviour_builder.fsm/README.md +++ b/tgbotapi.extensions.behaviour_builder.fsm/README.md @@ -1,3 +1,8 @@ # TelegramBotAPI Behaviour Builder FSM Extensions [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.behaviour_builder.fsm/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.behaviour_builder.fsm) + +This extension has been created to integrate finite state machine in [BehaviourBuilder](../tgbotapi.extensions.behaviour_builder/README.md). +In case you wish to use some custom store for steps (states), you may extend `StatesManager` or use `DefaultStatesManager` +with custom `DefaultStatesManagerRepo`. See [Examples repo](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/tree/master/FSMBot) +to get more info and see how it works on base level From db7a42fa9b1c2263f3b305f73d822acdfd270b4a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 16 Oct 2021 08:54:36 +0600 Subject: [PATCH 29/40] Update gradle.properties --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index a9ad63c307..ba241db3d4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ kotlin.incremental.js=true kotlin_version=1.5.31 kotlin_coroutines_version=1.5.2 kotlin_serialisation_runtime_version=1.3.0 -klock_version=2.4.5 +klock_version=2.4.6 uuid_version=0.3.1 ktor_version=1.6.4 From ddd32a81c0e94d75ec5648f1e05996768bfa6acf Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 16 Oct 2021 08:54:53 +0600 Subject: [PATCH 30/40] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52675de8bd..0752fa9ff0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ * `Version`: * `Serialization`: `1.2.2` -> `1.3.0` * `MicroUtils`: `0.5.28` -> `0.7.1` - * `Klock`: `2.4.3` -> `2.4.5` + * `Klock`: `2.4.3` -> `2.4.6` * `Ktor`: `1.6.3` -> `1.6.4` * `Core`: * `PrivateContentMessageImpl#paymentInfo` now is deprecated and will always be null From 4203a0fdfe3399c4d9d7067f19c5d66f71724893 Mon Sep 17 00:00:00 2001 From: Siarhei Date: Sat, 16 Oct 2021 23:01:10 +0300 Subject: [PATCH 31/40] PossiblyReplyMessage casts Add asPossiblyReplyMessage / requirePossiblyReplyMessage / whenPossiblyReplyMessage --- CHANGELOG.md | 4 ++++ .../dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0752fa9ff0..1fea5b810f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,10 @@ * Two new dsl: * `inlineKeyboard` for creating `InlineKeyboardMarkup` * `replyKeyboard` for creating `ReplyKeyboardMarkup` + * Cast helpers for `Message`: + * `asPossiblyReplyMessage`: tries to cast a `Message` to `PossiblyReplyMessage`, returns `null` if the message is not of that type + * `requirePossiblyReplyMessage`: casts a `Message` to `PossiblyReplyMessage`, fails if the message is not of that type + * `whenPossiblyReplyMessage`: tries to cast a `Message` to `PossiblyReplyMessage` and runs the given block of code with it, if the cast is successful * `Behaviour Builder`: * New expecters and waiters: * `waitShippingQueries`/`onShippingQuery` diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt index ad0e69f1f3..c89200d275 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -1132,6 +1132,15 @@ inline fun Message.asPossiblyEditedMessage(): PossiblyEditedMessage? = this as? @PreviewFeature inline fun Message.requirePossiblyEditedMessage(): PossiblyEditedMessage = this as PossiblyEditedMessage +@PreviewFeature +inline fun Message.whenPossiblyReplyMessage(block: (PossiblyReplyMessage) -> T) = asPossiblyReplyMessage() ?.let(block) + +@PreviewFeature +inline fun Message.asPossiblyReplyMessage(): PossiblyReplyMessage? = this as? PossiblyReplyMessage + +@PreviewFeature +inline fun Message.requirePossiblyReplyMessage(): PossiblyReplyMessage = this as PossiblyReplyMessage + @PreviewFeature inline fun Message.whenPossiblyForwardedMessage(block: (PossiblyForwardedMessage) -> T) = asPossiblyForwardedMessage() ?.let(block) From 2447d3e51fd2851637032714c5dea83f714cb1fa Mon Sep 17 00:00:00 2001 From: madhead Date: Sun, 17 Oct 2021 14:42:24 +0200 Subject: [PATCH 32/40] Don't run the labeler if the actor is not repo owner --- .github/workflows/label.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index be1ee465e3..604a6cd13a 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -12,6 +12,7 @@ on: jobs: triage: runs-on: ubuntu-latest + if: ${{ github.actor == github.repository_owner }} steps: - uses: actions/labeler@v2 with: From 65c1f018ac04b5fa60903dee0c2eadf0bb8bb239 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 18 Oct 2021 14:13:22 +0600 Subject: [PATCH 33/40] update microutils --- CHANGELOG.md | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fea5b810f..aaa9f86432 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ * `Common`: * `Version`: * `Serialization`: `1.2.2` -> `1.3.0` - * `MicroUtils`: `0.5.28` -> `0.7.1` + * `MicroUtils`: `0.5.28` -> `0.7.2` * `Klock`: `2.4.3` -> `2.4.6` * `Ktor`: `1.6.3` -> `1.6.4` * `Core`: diff --git a/gradle.properties b/gradle.properties index ba241db3d4..cb7b61b406 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ klock_version=2.4.6 uuid_version=0.3.1 ktor_version=1.6.4 -micro_utils_version=0.7.1 +micro_utils_version=0.7.2 javax_activation_version=1.1.1 From 91212eaa3a6924f874fa00afba9c1615a99a72fb Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 18 Oct 2021 14:45:57 +0600 Subject: [PATCH 34/40] resolution of #484 --- CHANGELOG.md | 5 +++- .../inmo/tgbotapi/CommonAbstracts/FromUser.kt | 15 ++++++++-- .../inmo/tgbotapi/CommonAbstracts/WithUser.kt | 12 ++++++++ .../types/CallbackQuery/CallbackQuery.kt | 2 +- .../InlineMessageIdDataCallbackQuery.kt | 2 +- ...lineMessageIdGameShortNameCallbackQuery.kt | 2 +- .../CallbackQuery/MessageDataCallbackQuery.kt | 2 +- .../MessageGameShortNameCallbackQuery.kt | 2 +- .../types/ChatMember/abstracts/ChatMember.kt | 5 ++-- .../BaseChosenInlineResult.kt | 2 +- .../LocationChosenInlineResult.kt | 2 +- .../types/InlineQueries/query/InlineQuery.kt | 5 ++-- .../message/ChatEvents/LeftChatMember.kt | 5 ++-- .../types/message/CommonGroupEventMessage.kt | 2 +- .../types/message/CommonMediaGroupMessage.kt | 2 +- .../message/CommonSupergroupEventMessage.kt | 2 +- .../tgbotapi/types/message/ForwardInfo.kt | 5 ++-- .../tgbotapi/types/message/GroupMessages.kt | 2 +- .../tgbotapi/types/message/PassportMessage.kt | 2 +- .../types/message/PrivateMessageImpl.kt | 2 +- .../types/payments/PreCheckoutQuery.kt | 2 +- .../tgbotapi/types/payments/ShippingQuery.kt | 2 +- .../inmo/tgbotapi/types/polls/PollAnswer.kt | 9 ++++-- .../tgbotapi/extensions/utils/ClassCasts.kt | 12 ++++++-- .../utils/extensions/UpdateChatRetriever.kt | 28 +++++++++++-------- 25 files changed, 86 insertions(+), 45 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/WithUser.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index aaa9f86432..527eeb9b62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,10 +24,13 @@ * Two new dsl: * `inlineKeyboard` for creating `InlineKeyboardMarkup` * `replyKeyboard` for creating `ReplyKeyboardMarkup` - * Cast helpers for `Message`: + * Cast helpers for `Message` (thanks to [madhead](https://github.com/madhead)): * `asPossiblyReplyMessage`: tries to cast a `Message` to `PossiblyReplyMessage`, returns `null` if the message is not of that type * `requirePossiblyReplyMessage`: casts a `Message` to `PossiblyReplyMessage`, fails if the message is not of that type * `whenPossiblyReplyMessage`: tries to cast a `Message` to `PossiblyReplyMessage` and runs the given block of code with it, if the cast is successful + * New type `WithUser` for unioning of all types with `user` + * `FromUser` now extends `WithUser` + * Cast helpers for type `WithUser`: `asWithUser`, `whenWithUser`, `requireWithUser` * `Behaviour Builder`: * New expecters and waiters: * `waitShippingQueries`/`onShippingQuery` diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/FromUser.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/FromUser.kt index d45e65b52f..698f36c45a 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/FromUser.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/FromUser.kt @@ -2,6 +2,15 @@ package dev.inmo.tgbotapi.CommonAbstracts import dev.inmo.tgbotapi.types.User -interface FromUser { - val user: User -} \ No newline at end of file +/** + * Inheritors of this interface have some [User] as a source of data. For example, any [dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery] + * have [User] as the source of that query + */ +interface FromUser : WithUser { + /** + * The source [User] of this type + */ + val from: User + override val user: User + get() = from +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/WithUser.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/WithUser.kt new file mode 100644 index 0000000000..765a8d1e13 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/CommonAbstracts/WithUser.kt @@ -0,0 +1,12 @@ +package dev.inmo.tgbotapi.CommonAbstracts + +import dev.inmo.tgbotapi.types.User + +/** + * All inheritors of this type have [User] in their data as one of the main data + * + * @see FromUser + */ +interface WithUser { + val user: User +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/CallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/CallbackQuery.kt index 3ab043ed28..dbbd8a2699 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/CallbackQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/CallbackQuery.kt @@ -11,7 +11,7 @@ sealed interface CallbackQuery : FromUser { data class UnknownCallbackQueryType( override val id: CallbackQueryIdentifier, - override val user: User, + override val from: User, override val chatInstance: String, val raw: String ) : CallbackQuery diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdDataCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdDataCallbackQuery.kt index aa4ecf9f70..bdb013340e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdDataCallbackQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdDataCallbackQuery.kt @@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.types.* data class InlineMessageIdDataCallbackQuery( override val id: CallbackQueryIdentifier, - override val user: User, + override val from: User, override val chatInstance: String, override val inlineMessageId: InlineMessageIdentifier, override val data: String diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdGameShortNameCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdGameShortNameCallbackQuery.kt index f54793fcd4..8369e71332 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdGameShortNameCallbackQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/InlineMessageIdGameShortNameCallbackQuery.kt @@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.types.* data class InlineMessageIdGameShortNameCallbackQuery( override val id: CallbackQueryIdentifier, - override val user: User, + override val from: User, override val chatInstance: String, override val inlineMessageId: InlineMessageIdentifier, override val gameShortName: String diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageDataCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageDataCallbackQuery.kt index 9f6047197f..e276bd219e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageDataCallbackQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageDataCallbackQuery.kt @@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.Message data class MessageDataCallbackQuery( override val id: CallbackQueryIdentifier, - override val user: User, + override val from: User, override val chatInstance: String, override val message: Message, override val data: String diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageGameShortNameCallbackQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageGameShortNameCallbackQuery.kt index f026675b13..208f820179 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageGameShortNameCallbackQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/CallbackQuery/MessageGameShortNameCallbackQuery.kt @@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.Message data class MessageGameShortNameCallbackQuery( override val id: CallbackQueryIdentifier, - override val user: User, + override val from: User, override val chatInstance: String, override val message: Message, override val gameShortName: String diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatMember.kt index 2551a7d017..8b6de401ab 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatMember.kt @@ -1,5 +1,6 @@ package dev.inmo.tgbotapi.types.ChatMember.abstracts +import dev.inmo.tgbotapi.CommonAbstracts.WithUser import dev.inmo.tgbotapi.types.ChatMember.* import dev.inmo.tgbotapi.types.User import dev.inmo.tgbotapi.types.statusField @@ -14,9 +15,7 @@ import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.jsonPrimitive @Serializable(ChatMemberSerializer::class) -sealed interface ChatMember { - val user: User -} +sealed interface ChatMember : WithUser @RiskFeature object ChatMemberSerializer : KSerializer { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/BaseChosenInlineResult.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/BaseChosenInlineResult.kt index bf85756e09..a19a61d7a0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/BaseChosenInlineResult.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/BaseChosenInlineResult.kt @@ -8,7 +8,7 @@ import kotlinx.serialization.Serializable data class BaseChosenInlineResult( override val resultId: InlineQueryIdentifier, @SerialName(fromField) - override val user: User, + override val from: User, override val inlineMessageId: InlineMessageIdentifier?, override val query: String ) : ChosenInlineResult diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/LocationChosenInlineResult.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/LocationChosenInlineResult.kt index 30388e7e6f..c56bc5e520 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/LocationChosenInlineResult.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/ChosenInlineResult/LocationChosenInlineResult.kt @@ -9,7 +9,7 @@ import kotlinx.serialization.Serializable data class LocationChosenInlineResult( override val resultId: InlineQueryIdentifier, @SerialName(fromField) - override val user: User, + override val from: User, val location: StaticLocation, override val inlineMessageId: InlineMessageIdentifier?, override val query: String diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/InlineQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/InlineQuery.kt index 2e7c093d8d..f94e97b18e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/InlineQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/InlineQueries/query/InlineQuery.kt @@ -1,12 +1,11 @@ package dev.inmo.tgbotapi.types.InlineQueries.query +import dev.inmo.tgbotapi.CommonAbstracts.FromUser import dev.inmo.tgbotapi.types.InlineQueryIdentifier -import dev.inmo.tgbotapi.types.User import dev.inmo.tgbotapi.types.chat.ChatType -sealed interface InlineQuery { +sealed interface InlineQuery : FromUser { val id: InlineQueryIdentifier - val from: User val query: String val offset: String val chatType: ChatType? diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt index a8b3bf1668..925cfb35bb 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/LeftChatMember.kt @@ -1,8 +1,9 @@ package dev.inmo.tgbotapi.types.message.ChatEvents +import dev.inmo.tgbotapi.CommonAbstracts.WithUser import dev.inmo.tgbotapi.types.User import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent data class LeftChatMember( - val user: User -) : PublicChatEvent + override val user: User +) : PublicChatEvent, WithUser diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonGroupEventMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonGroupEventMessage.kt index 03e228f693..2e9b602668 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonGroupEventMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonGroupEventMessage.kt @@ -9,7 +9,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.GroupEventMessage data class CommonGroupEventMessage( override val messageId: MessageIdentifier, - override val user: User, + override val from: User, override val chat: GroupChat, override val chatEvent: T, override val date: DateTime diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonMediaGroupMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonMediaGroupMessage.kt index 49d1118e57..28bbacf8bc 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonMediaGroupMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonMediaGroupMessage.kt @@ -9,7 +9,7 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent data class CommonMediaGroupMessage( override val messageId: MessageIdentifier, - override val user: User, + override val from: User, override val chat: Chat, override val date: DateTime, override val mediaGroupId: MediaGroupIdentifier, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonSupergroupEventMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonSupergroupEventMessage.kt index b63a7dbf1b..124fe0cac6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonSupergroupEventMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/CommonSupergroupEventMessage.kt @@ -9,7 +9,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.SupergroupEventMessage data class CommonSupergroupEventMessage( override val messageId: MessageIdentifier, - override val user: User, + override val from: User, override val chat: SupergroupChat, override val chatEvent: T, override val date: DateTime diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt index 7ca6f21d87..f239b9d235 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ForwardInfo.kt @@ -1,5 +1,6 @@ package dev.inmo.tgbotapi.types.message +import dev.inmo.tgbotapi.CommonAbstracts.FromUser import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.chat.abstracts.ChannelChat import dev.inmo.tgbotapi.types.chat.abstracts.SupergroupChat @@ -15,8 +16,8 @@ data class AnonymousForwardInfo( data class UserForwardInfo( override val dateOfOriginal: TelegramDate, - val from: User -) : ForwardInfo() + override val from: User +) : ForwardInfo(), FromUser data class ForwardFromChannelInfo( override val dateOfOriginal: TelegramDate, 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 e24405ba79..0fee420bf2 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 @@ -38,7 +38,7 @@ data class AnonymousGroupContentMessageImpl( data class CommonGroupContentMessageImpl( override val chat: GroupChat, override val messageId: MessageIdentifier, - override val user: User, + override val from: User, override val date: DateTime, override val forwardInfo: ForwardInfo?, override val editDate: DateTime?, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PassportMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PassportMessage.kt index 55153e159f..b249d704e2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PassportMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PassportMessage.kt @@ -11,7 +11,7 @@ import dev.inmo.tgbotapi.types.passport.PassportData data class PassportMessage( override val messageId: MessageIdentifier, override val chat: Chat, - override val user: User, + override val from: User, override val date: DateTime, val passportData: PassportData ) : Message, FromUserMessage diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateMessageImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateMessageImpl.kt index 599fce4c76..e08dd2d4ba 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateMessageImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateMessageImpl.kt @@ -11,7 +11,7 @@ import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent data class PrivateContentMessageImpl( override val messageId: MessageIdentifier, - override val user: User, + override val from: User, override val chat: Chat, override val content: T, override val date: DateTime, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/PreCheckoutQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/PreCheckoutQuery.kt index dfdfe4a1a7..d221e408b2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/PreCheckoutQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/PreCheckoutQuery.kt @@ -12,7 +12,7 @@ data class PreCheckoutQuery( @SerialName(idField) val id: PreCheckoutQueryId, @SerialName(fromField) - override val user: User, + override val from: User, @SerialName(currencyField) override val currency: Currency, @SerialName(totalAmountField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/ShippingQuery.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/ShippingQuery.kt index 7821211bf6..d72e2fef65 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/ShippingQuery.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/payments/ShippingQuery.kt @@ -10,7 +10,7 @@ data class ShippingQuery( @SerialName(idField) val id: ShippingQueryIdentifier, @SerialName(fromField) - override val user: User, + override val from: User, @SerialName(invoicePayloadField) val invoicePayload: InvoicePayload, @SerialName(shippingAddressField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/PollAnswer.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/PollAnswer.kt index c4ea74bfa0..0411d5e8ec 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/PollAnswer.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/polls/PollAnswer.kt @@ -2,8 +2,7 @@ package dev.inmo.tgbotapi.types.polls import dev.inmo.tgbotapi.CommonAbstracts.FromUser import dev.inmo.tgbotapi.types.* -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable +import kotlinx.serialization.* @Serializable data class PollAnswer( @@ -13,4 +12,8 @@ data class PollAnswer( override val user: User, @SerialName(optionIdsField) val chosen: List -) : FromUser +) : FromUser { + @Transient + override val from: User + get() = user +} diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt index c89200d275..ae3d35a63c 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -2,8 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils -import dev.inmo.tgbotapi.CommonAbstracts.CommonSendInvoiceData -import dev.inmo.tgbotapi.CommonAbstracts.FromUser +import dev.inmo.tgbotapi.CommonAbstracts.* import dev.inmo.tgbotapi.requests.send.payments.SendInvoice import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.CallbackQuery.* @@ -3154,6 +3153,15 @@ inline fun Any.asFromUser(): FromUser? = this as? FromUser @PreviewFeature inline fun Any.requireFromUser(): FromUser = this as FromUser +@PreviewFeature +inline fun Any.whenWithUser(block: (WithUser) -> T) = asWithUser() ?.let(block) + +@PreviewFeature +inline fun Any.asWithUser(): WithUser? = this as? WithUser + +@PreviewFeature +inline fun Any.requireWithUser(): WithUser = this as WithUser + @PreviewFeature inline fun Any.whenWithOptionalLanguageCode(block: (WithOptionalLanguageCode) -> T) = asWithOptionalLanguageCode() ?.let(block) diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt index a1f341c16b..9507f7052b 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt @@ -1,5 +1,7 @@ package dev.inmo.tgbotapi.extensions.utils.extensions +import dev.inmo.tgbotapi.CommonAbstracts.FromUser +import dev.inmo.tgbotapi.CommonAbstracts.WithUser import dev.inmo.tgbotapi.extensions.utils.asFromUser import dev.inmo.tgbotapi.extensions.utils.asUser import dev.inmo.tgbotapi.extensions.utils.shortcuts.chat @@ -12,20 +14,24 @@ import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.utils.PreviewFeature @PreviewFeature -fun Update.sourceChat(): Chat? = when (this) { - is MediaGroupUpdate -> when (this) { +fun Update.sourceChat(): Chat? = when { + this is MediaGroupUpdate -> when (this) { is SentMediaGroupUpdate -> data.chat is EditMediaGroupUpdate -> data.chat } - is BaseMessageUpdate -> data.chat - is InlineQueryUpdate -> data.from - is ChosenInlineResultUpdate -> data.user - is CallbackQueryUpdate -> data.user - is PreCheckoutQueryUpdate -> data.user - is PollAnswerUpdate -> data.user - is ShippingQueryUpdate -> data.user - else -> null + this is BaseMessageUpdate -> data.chat + else -> { + when (val data = data) { + is FromUser -> data.from + is WithUser -> data.user + else -> null + } + } } @PreviewFeature -fun Update.sourceUser(): User? = data.asFromUser()?.user ?: sourceChat()?.asUser() +fun Update.sourceUser(): User? = when (val data = data) { + is FromUser -> data.from + is WithUser -> data.user + else -> sourceChat()?.asUser() +} From e60eb68b67c2f8d6dfda4ef63c0d66efc51efe6e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 18 Oct 2021 15:20:25 +0600 Subject: [PATCH 35/40] packages update --- .github/labeler.yml | 8 +- CHANGELOG.md | 5 + README.md | 2 +- TelegramBotAPI.drawio | 2 +- badges/chat.svg | 20 --- badges/kdocs.svg | 20 --- badges/template.svg | 20 --- .../TelegramBotAPI-libraries-hierarchy.svg | 147 +++++++++++++++++- settings.gradle | 4 + .../README.md | 0 tgbotapi.api/build.gradle | 50 ++++++ tgbotapi.api/mpp_publish_template.kpsb | 1 + tgbotapi.api/publish.gradle | 69 ++++++++ .../tgbotapi/extensions/api/BotBuilder.kt | 0 .../tgbotapi/extensions/api/BotExtensions.kt | 0 .../dev/inmo/tgbotapi/extensions/api/Close.kt | 0 .../tgbotapi/extensions/api/DeleteMessage.kt | 0 .../tgbotapi/extensions/api/ForwardMessage.kt | 0 .../tgbotapi/extensions/api/GetUpdates.kt | 0 .../api/InternalUtils/UpdatesUtils.kt | 0 .../inmo/tgbotapi/extensions/api/JsonUtils.kt | 0 .../extensions/api/LiveLocationProvider.kt | 0 .../inmo/tgbotapi/extensions/api/LogOut.kt | 0 .../inmo/tgbotapi/extensions/api/StopPoll.kt | 0 .../api/answers/AnswerCallbackQuery.kt | 0 .../api/answers/AnswerInlineQuery.kt | 0 .../payments/AnswerPreCheckoutQuery.kt | 0 .../answers/payments/AnswerShippingQuery.kt | 0 .../extensions/api/bot/DeleteMyCommands.kt | 0 .../inmo/tgbotapi/extensions/api/bot/GetMe.kt | 0 .../extensions/api/bot/GetMyCommands.kt | 0 .../extensions/api/bot/SetMyCommands.kt | 0 .../api/chat/ExportChatInviteLink.kt | 0 .../tgbotapi/extensions/api/chat/LeaveChat.kt | 0 .../extensions/api/chat/get/GetChat.kt | 0 .../api/chat/get/GetChatAdministrators.kt | 0 .../api/chat/get/GetChatMemberCount.kt | 0 .../chat/invite_links/CreateChatInviteLink.kt | 0 .../chat/invite_links/EditChatInviteLink.kt | 0 .../chat/invite_links/RevokeChatInviteLink.kt | 0 .../api/chat/members/BanChatMember.kt | 0 .../api/chat/members/GetChatMember.kt | 0 .../api/chat/members/PromoteChatMember.kt | 0 .../api/chat/members/RestrictChatMember.kt | 0 .../SetChatAdministratorCustomTitle.kt | 0 .../api/chat/members/UnbanChatMember.kt | 0 .../api/chat/modify/DeleteChatPhoto.kt | 0 .../api/chat/modify/PinChatMessage.kt | 0 .../api/chat/modify/SetChatDescription.kt | 0 .../api/chat/modify/SetChatPermissions.kt | 0 .../api/chat/modify/SetChatPhoto.kt | 0 .../api/chat/modify/SetChatTitle.kt | 0 .../api/chat/modify/UnpinAllChatMessages.kt | 0 .../api/chat/modify/UnpinChatMessage.kt | 0 .../api/chat/stickers/DeleteChatStickerSet.kt | 0 .../api/chat/stickers/SetChatStickerSet.kt | 0 .../EditChatMessageLiveLocation.kt | 0 .../EditInlineMessageLiveLocation.kt | 0 .../StopChatMessageLiveLocation.kt | 0 .../StopInlineMessageLiveLocation.kt | 0 .../ReplyMarkup/EditChatMessageReplyMarkup.kt | 0 .../EditInlineMessageReplyMarkup.kt | 0 .../edit/caption/EditChatMessageCaption.kt | 0 .../edit/caption/EditInlineMessageCaption.kt | 0 .../api/edit/media/EditChatMessageMedia.kt | 0 .../api/edit/media/EditInlineMessageMedia.kt | 0 .../api/edit/text/EditChatMessageText.kt | 0 .../api/edit/text/EditInlineMessageText.kt | 0 .../extensions/api/files/DownloadFile.kt | 0 .../api/files/DownloadFileStream.kt | 0 .../api/files/DownloadFileStreamAllocator.kt | 0 .../api/games/GetGameHighScoresByChat.kt | 0 .../GetGameHighScoresByInlineMessageId.kt | 0 .../api/games/SetGameScoreByChatId.kt | 0 .../games/SetGameScoreByInlineMessageId.kt | 0 .../tgbotapi/extensions/api/get/GetFile.kt | 0 .../extensions/api/get/GetStickerSet.kt | 0 .../api/get/GetUserProfilePhotos.kt | 0 .../api/passport/SetPassportDataErrors.kt | 0 .../extensions/api/send/CopyMessage.kt | 0 .../tgbotapi/extensions/api/send/Replies.kt | 0 .../extensions/api/send/SendAction.kt | 0 .../extensions/api/send/SendActionDSL.kt | 0 .../extensions/api/send/SendContact.kt | 0 .../tgbotapi/extensions/api/send/SendDice.kt | 0 .../extensions/api/send/SendLocation.kt | 0 .../extensions/api/send/SendMessage.kt | 0 .../tgbotapi/extensions/api/send/SendVenue.kt | 0 .../extensions/api/send/games/SendGame.kt | 0 .../api/send/media/SendAnimation.kt | 0 .../extensions/api/send/media/SendAudio.kt | 0 .../extensions/api/send/media/SendDocument.kt | 0 .../api/send/media/SendMediaGroup.kt | 0 .../extensions/api/send/media/SendPhoto.kt | 0 .../extensions/api/send/media/SendSticker.kt | 0 .../extensions/api/send/media/SendVideo.kt | 0 .../api/send/media/SendVideoNote.kt | 0 .../extensions/api/send/media/SendVoice.kt | 0 .../api/send/payments/SendInvoice.kt | 0 .../extensions/api/send/polls/SendPoll.kt | 0 .../api/stickers/AddAnimatedStickerToSet.kt | 0 .../api/stickers/AddStaticStickerToSet.kt | 0 .../stickers/CreateNewAnimatedStickerSet.kt | 0 .../api/stickers/CreateNewStaticStickerSet.kt | 0 .../api/stickers/DeleteStickerFromSet.kt | 0 .../api/stickers/SetStickerPositionInSet.kt | 0 .../api/stickers/SetStickerSetThumb.kt | 0 .../api/stickers/UploadStickerFile.kt | 0 .../extensions/api/utils/UpdatesHandling.kt | 0 .../extensions/api/webhook/DeleteWebhook.kt | 0 .../extensions/api/webhook/GetWebhookInfo.kt | 0 .../extensions/api/webhook/SetWebhookInfo.kt | 0 .../api/files/DownloadFileToFile.kt | 0 .../README.md | 0 tgbotapi.behaviour_builder.fsm/build.gradle | 50 ++++++ .../mpp_publish_template.kpsb | 1 + tgbotapi.behaviour_builder.fsm/publish.gradle | 69 ++++++++ .../BehaviourContextWithFSM.kt | 0 .../BehaviourContextWithFSMBuilder.kt | 0 .../BehaviourWithFSMStateHandler.kt | 0 .../BehaviourWithFSMStateHandlerHolder.kt | 0 .../behaviour_builder/TelegramBotWithFSM.kt | 0 .../README.md | 0 tgbotapi.behaviour_builder/build.gradle | 49 ++++++ .../mpp_publish_template.kpsb | 1 + tgbotapi.behaviour_builder/publish.gradle | 69 ++++++++ .../behaviour_builder/BehaviourBuilders.kt | 0 .../behaviour_builder/BehaviourContext.kt | 0 .../behaviour_builder/TelegramBot.kt | 0 .../extensions/behaviour_builder/Variants.kt | 0 .../behaviour_builder/expectations/Base.kt | 0 .../expectations/WaitCallbackQuery.kt | 0 .../expectations/WaitChatMemberUpdated.kt | 0 .../expectations/WaitChosenInlineResult.kt | 0 .../expectations/WaitContent.kt | 0 .../expectations/WaitEditedContent.kt | 0 .../expectations/WaitEventAction.kt | 0 .../expectations/WaitInlineQuery.kt | 0 .../expectations/WaitMediaGroup.kt | 0 .../expectations/WaitPassportData.kt | 0 .../expectations/WaitPollAnswers.kt | 0 .../expectations/WaitPollUpdates.kt | 0 .../expectations/WaitPreCheckoutQuery.kt | 0 .../expectations/WaitShippingQuery.kt | 0 .../filters/MessageFilterByChat.kt | 0 .../MessageFilterExcludingMediaGroups.kt | 0 .../CallbackQueryTriggers.kt | 0 .../ChatMemberUpdatedTriggers.kt | 0 .../ChosenInlineResultTriggers.kt | 0 .../triggers_handling/CommandHandling.kt | 0 .../triggers_handling/ContentTriggers.kt | 0 .../EditedContentTriggers.kt | 0 .../triggers_handling/EventTriggers.kt | 0 .../triggers_handling/InlineQueryTriggers.kt | 0 .../triggers_handling/MainTrigger.kt | 0 .../triggers_handling/MediaGroupTriggers.kt | 0 .../triggers_handling/PassportTriggers.kt | 0 .../triggers_handling/PollAnswersTriggers.kt | 0 .../triggers_handling/PollUpdatesTriggers.kt | 0 .../PreCheckoutQueryTriggers.kt | 0 .../ShippingQueryTriggers.kt | 0 .../behaviour_builder/utils/LiveLocation.kt | 0 .../behaviour_builder/utils/SimpleFilter.kt | 0 .../SubcontextUpdatesFilterOperations.kt | 0 .../ChatMemberUpdatedMarkerFactories.kt | 0 .../ChosenInlineResultsMarkerFactories.kt | 0 .../InlineQueryMarkerFactories.kt | 0 .../utils/marker_factories/MarkerFactory.kt | 0 .../MediaGroupMarkerFactories.kt | 0 .../MessageMarkerFactories.kt | 0 .../marker_factories/PollMarkerFactories.kt | 0 .../marker_factories/QueryMarkerFactories.kt | 0 .../DefaultCoroutineScopeProvider.kt | 0 .../DefaultCoroutineScopeProvider.kt | 0 tgbotapi.core/README.md | 2 +- tgbotapi.extensions.api/build.gradle | 2 +- .../mpp_publish_template.kpsb | 2 +- .../build.gradle | 4 +- .../mpp_publish_template.kpsb | 2 +- .../publish.gradle | 6 +- .../build.gradle | 3 +- .../mpp_publish_template.kpsb | 2 +- .../publish.gradle | 6 +- tgbotapi.extensions.utils/build.gradle | 21 +-- .../mpp_publish_template.kpsb | 2 +- tgbotapi.extensions.utils/publish.gradle | 6 +- .../README.md | 0 tgbotapi.utils/build.gradle | 67 ++++++++ tgbotapi.utils/mpp_publish_template.kpsb | 1 + tgbotapi.utils/publish.gradle | 69 ++++++++ .../utils/CallbackQueryConversations.kt | 0 .../tgbotapi/extensions/utils/ClassCasts.kt | 0 .../utils/CommonMessageConversations.kt | 0 .../utils/ContentMessageConversations.kt | 0 .../extensions/utils/FlowsAggregation.kt | 0 .../tgbotapi/extensions/utils/JsonFormat.kt | 0 .../extensions/utils/SlotMachineUtils.kt | 0 .../tgbotapi/extensions/utils/WithContent.kt | 0 .../utils/extensions/FilesDownloading.kt | 0 .../utils/extensions/FlowsUpdatesFilter.kt | 0 .../TextCaptionBotCommandsParser.kt | 0 .../utils/extensions/UpdateChatRetriever.kt | 0 .../utils/extensions/venue/Foursquare.kt | 0 .../utils/extensions/venue/Google.kt | 0 .../utils/formatting/EntitiesBuilder.kt | 0 .../utils/formatting/LinksFormatting.kt | 0 .../formatting/ResendingTextFormatting.kt | 0 .../utils/formatting/StringFormatting.kt | 0 .../utils/internal_utils/UpdatesFiltering.kt | 0 .../utils/shortcuts/CommandsShortcuts.kt | 0 .../utils/shortcuts/EventsShortcuts.kt | 0 .../utils/shortcuts/FlowsUpdatesFilter.kt | 0 .../utils/shortcuts/MediaGroupsShortcuts.kt | 0 .../utils/shortcuts/PollCloseShortcuts.kt | 0 .../utils/shortcuts/RequestsExecutor.kt | 0 .../types/buttons/InlineKeyboardBuilder.kt | 0 .../types/buttons/InlineKeyboardMarkup.kt | 0 .../types/buttons/ReplyKeyboardBuilder.kt | 0 .../types/buttons/ReplyKeyboardMarkup.kt | 0 .../utils/types/files/ContentAsStorageFile.kt | 0 .../BaseMessagesUpdatesConversations.kt | 0 .../CallbackQueryUpdatesConversations.kt | 0 .../ChosenInlineResultUpdatesConversations.kt | 0 .../utils/updates/CommandsFilters.kt | 0 .../utils/updates/FlowsUpdatesFactory.kt | 0 .../InlineQueryUpdatesConversations.kt | 0 .../SentMessageUpdatesConversations.kt | 0 .../utils/updates/UpdateDeserialization.kt | 0 .../utils/updates/UpdatesChatFilters.kt | 0 .../extensions/utils/updates/UpdatesUtils.kt | 0 .../utils/updates/retrieving/LongPolling.kt | 0 .../updates/retrieving/MediaGroupsIncluder.kt | 0 .../utils/updates/retrieving/Webhook.kt | 0 .../inmo/tgbotapi/types/files/PathedFile.kt | 0 tgbotapi/build.gradle | 8 +- 235 files changed, 681 insertions(+), 109 deletions(-) delete mode 100644 badges/chat.svg delete mode 100644 badges/kdocs.svg delete mode 100644 badges/template.svg rename {tgbotapi.extensions.api => tgbotapi.api}/README.md (100%) create mode 100644 tgbotapi.api/build.gradle create mode 100644 tgbotapi.api/mpp_publish_template.kpsb create mode 100644 tgbotapi.api/publish.gradle rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotBuilder.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotExtensions.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/Close.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessage.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessage.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/GetUpdates.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/InternalUtils/UpdatesUtils.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/JsonUtils.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LogOut.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/StopPoll.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerCallbackQuery.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerInlineQuery.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/payments/AnswerPreCheckoutQuery.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/payments/AnswerShippingQuery.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/DeleteMyCommands.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMe.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyCommands.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyCommands.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/ExportChatInviteLink.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/LeaveChat.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChat.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatAdministrators.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatMemberCount.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/CreateChatInviteLink.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/EditChatInviteLink.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/RevokeChatInviteLink.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatMember.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/GetChatMember.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/RestrictChatMember.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/SetChatAdministratorCustomTitle.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/UnbanChatMember.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/DeleteChatPhoto.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/PinChatMessage.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatDescription.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatPermissions.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatPhoto.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatTitle.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/UnpinAllChatMessages.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/UnpinChatMessage.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/stickers/DeleteChatStickerSet.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/stickers/SetChatStickerSet.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditChatMessageLiveLocation.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditInlineMessageLiveLocation.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopChatMessageLiveLocation.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopInlineMessageLiveLocation.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditInlineMessageCaption.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditChatMessageMedia.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditInlineMessageMedia.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFile.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileStream.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileStreamAllocator.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/GetGameHighScoresByChat.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/GetGameHighScoresByInlineMessageId.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/SetGameScoreByChatId.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/SetGameScoreByInlineMessageId.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetFile.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetStickerSet.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetUserProfilePhotos.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/passport/SetPassportDataErrors.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendContact.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendDice.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLocation.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendVenue.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/games/SendGame.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddAnimatedStickerToSet.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStaticStickerToSet.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewAnimatedStickerSet.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewStaticStickerSet.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/DeleteStickerFromSet.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerPositionInSet.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerSetThumb.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/UploadStickerFile.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/utils/UpdatesHandling.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/DeleteWebhook.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/GetWebhookInfo.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/SetWebhookInfo.kt (100%) rename {tgbotapi.extensions.api => tgbotapi.api}/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileToFile.kt (100%) rename {tgbotapi.extensions.behaviour_builder.fsm => tgbotapi.behaviour_builder.fsm}/README.md (100%) create mode 100644 tgbotapi.behaviour_builder.fsm/build.gradle create mode 100644 tgbotapi.behaviour_builder.fsm/mpp_publish_template.kpsb create mode 100644 tgbotapi.behaviour_builder.fsm/publish.gradle rename {tgbotapi.extensions.behaviour_builder.fsm => tgbotapi.behaviour_builder.fsm}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt (100%) rename {tgbotapi.extensions.behaviour_builder.fsm => tgbotapi.behaviour_builder.fsm}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt (100%) rename {tgbotapi.extensions.behaviour_builder.fsm => tgbotapi.behaviour_builder.fsm}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandler.kt (100%) rename {tgbotapi.extensions.behaviour_builder.fsm => tgbotapi.behaviour_builder.fsm}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder.kt (100%) rename {tgbotapi.extensions.behaviour_builder.fsm => tgbotapi.behaviour_builder.fsm}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/README.md (100%) create mode 100644 tgbotapi.behaviour_builder/build.gradle create mode 100644 tgbotapi.behaviour_builder/mpp_publish_template.kpsb create mode 100644 tgbotapi.behaviour_builder/publish.gradle rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/Variants.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPassportData.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChat.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterExcludingMediaGroups.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMemberUpdatedTriggers.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChosenInlineResultTriggers.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PassportTriggers.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollAnswersTriggers.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PreCheckoutQueryTriggers.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ShippingQueryTriggers.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/LiveLocation.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/SubcontextUpdatesFilterOperations.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChatMemberUpdatedMarkerFactories.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChosenInlineResultsMarkerFactories.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/InlineQueryMarkerFactories.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MediaGroupMarkerFactories.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MessageMarkerFactories.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/PollMarkerFactories.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/QueryMarkerFactories.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/jsMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/DefaultCoroutineScopeProvider.kt (100%) rename {tgbotapi.extensions.behaviour_builder => tgbotapi.behaviour_builder}/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/DefaultCoroutineScopeProvider.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/README.md (100%) create mode 100644 tgbotapi.utils/build.gradle create mode 100644 tgbotapi.utils/mpp_publish_template.kpsb create mode 100644 tgbotapi.utils/publish.gradle rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/CallbackQueryConversations.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/CommonMessageConversations.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ContentMessageConversations.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/JsonFormat.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/SlotMachineUtils.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/WithContent.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/FilesDownloading.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/FlowsUpdatesFilter.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/TextCaptionBotCommandsParser.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/venue/Foursquare.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/venue/Google.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/ResendingTextFormatting.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/StringFormatting.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/internal_utils/UpdatesFiltering.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/CommandsShortcuts.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/MediaGroupsShortcuts.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/PollCloseShortcuts.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/RequestsExecutor.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardMarkup.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardMarkup.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/files/ContentAsStorageFile.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/BaseMessagesUpdatesConversations.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CallbackQueryUpdatesConversations.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/ChosenInlineResultUpdatesConversations.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CommandsFilters.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/FlowsUpdatesFactory.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/InlineQueryUpdatesConversations.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/SentMessageUpdatesConversations.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdateDeserialization.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesChatFilters.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesUtils.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/MediaGroupsIncluder.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/Webhook.kt (100%) rename {tgbotapi.extensions.utils => tgbotapi.utils}/src/jvmMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt (100%) diff --git a/.github/labeler.yml b/.github/labeler.yml index 6640b8eb8e..7a83cbf246 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,6 +1,8 @@ -api: "TelegramBotAPI-extensions-api/**" -utils: "TelegramBotAPI-extensions-utils/**" -core: "TelegramBotAPI/**" # currently not work +api: "TelegramBotAPI-api/**" +utils: "TelegramBotAPI-utils/**" +behaviour-builder: "TelegramBotAPI-behaviour_builder/**" +behaviour-builder_fsm: "TelegramBotAPI-behaviour_builder-fsm/**" +core: "TelegramBotAPI-core/**" # currently not work code: "**/*.kt" gradle: "**/*.gradle" diff --git a/CHANGELOG.md b/CHANGELOG.md index 527eeb9b62..ba8b7b23e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ ## 0.36.0 **ALL PREVIOUS DEPRECATIONS HAVE BEEN REMOVED** +**ALL EXTENSION PACKAGES HAS BEEN RENAMES**. Old packages are still available, but will be removed in next major update: + +* `tgbotapi.extensions.api` -> `tgbotape.api` +* `tgbotapi.extensions.utils` -> `tgbotape.utils` +* `tgbotapi.extensions.behaviour_builder` -> `tgbotape.behaviour_builder` * `Common`: * `Version`: diff --git a/README.md b/README.md index 1a4669ec73..0d30036f1b 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Hello! This is a set of libraries for working with Telegram Bot API. | Common info | [![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) [![Build Status](https://github.com/InsanusMokrassar/TelegramBotAPI/workflows/Build/badge.svg)](https://github.com/InsanusMokrassar/TelegramBotAPI/actions) [Small survey](https://forms.gle/2Hex2ynbHWHhi1KY7)| | -------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| Useful links | [![Chat in Telegram](badges/chat.svg)](https://t.me/InMoTelegramBotAPI) [![Create bot](badges/template.svg)](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [![KDocs](badges/kdocs.svg)](https://tgbotapi.inmo.dev/index.html) [Examples](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/), [Mini tutorial](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) | +| Useful links | [![Chat in Telegram](https://img.shields.io/static/v1?label=Talk&message=Telegram&color=blue)](https://t.me/InMoTelegramBotAPI) [![Create bot](https://img.shields.io/static/v1?label=Github&message=Template&color=blue)](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [![KDocs](https://img.shields.io/static/v1?label=Open&message=kdocs&color=blue)](https://tgbotapi.inmo.dev/index.html) [Examples](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/), [Mini tutorial](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) | | TelegramBotAPI Core status | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core) | | TelegramBotAPI API Extensions status | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.api) | | TelegramBotAPI Util Extensions status | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.utils/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.utils) | diff --git a/TelegramBotAPI.drawio b/TelegramBotAPI.drawio index f0839eea47..ffc54b5fb8 100644 --- a/TelegramBotAPI.drawio +++ b/TelegramBotAPI.drawio @@ -1 +1 @@ -7Vptc+I2EP41TD/BgI0J+Zi33t302t5cOr3mU0fYwtZFtnyyHKC/vruy/G4TAglkchlmgrUSq9Vq93m0cgb2Vbj+IEkc/C48ygfW2FsP7OuBZU0mYwu+ULLJJPPJWSbwJfPMoFJwy/6jRjg20pR5NKkNVEJwxeK60BVRRF1VkxEpxao+bCl4fdaY+LQluHUJb0u/MU8FZhXOuJR/pMwPVLFg0xOSfLARJAHxxKqi1b4Z2FdSCJU9hesrytF5uV+y3/3a01sYJmmkdvmBMzN2qE2+OOrBWk1TSBUIX0SE35TSy1L6WYgYhk1A+J0qtTFbRVIlQBSokJteMEdu/oHGOG/cYWPk5M3rdbXzemNa7fWYJSYila6xeGqiRxHpUzPMcTIZrqbpXohLKkIK88AASTlR7KG+s8QEiF+MK30ID8aN3S7NrXkgPDVaB9aMK3QIqJ/5Sq8rkyQxiWrun/1Ice8vFV2rIeHMjwb2BYzgdKnK3p3VcBbRYWBiEfVY89E8XvdrWnSqWYpIDRO9uVrJtEuF8hdCkZiNwHQaJUxEyQiauWbw26I5G8gy03cVtz0YP7NLbwrjMfCk+I4Aghghdf7eUx0zP1KaKBwRCokSLsQ9fjHdz9AAFeDjX5RTX5IQHi8FKrr48gkDLPIQxzDurLGIY0ipNGJqo5EM/qSJ1qN+wTkoSRiVjzun4opGTuPS6wlp/HDtQmKBbvvygUrFAOIuTEfIPE9newFRmI8+J0linsEKl0U+tDCLVwFT9BZEOOUKcB/DhnF+JTi4Dq2wLYIfE04V+c0MP9uyHY2j6615bKjEyqF2VQKznaNtUAXlXHhIrueIfzz4LBHzrgaYh8DnvA2fOYgdHz6dyVt16fnJXDp9CyTf4VLHOhnJz3tJPt6NiCdTwA6nn4jreP7k88NOjF0h/QaFu5rW9iHuQxi6YfTEQqOzCBnrvlXFgZGQIeHtRX0VmmdL6l4xIAJNvCP4+oQilmgFSoeGK8KQRh71muSb1KneYzBW8U1B3wvIBuTl6q+I0icLkuD34yeix5m8x4c/O92bXmtqGNjQ/7TN/sWJ4PnZ3z46VVkvwFXnrwlYx1/FN8df3Q3//vP+Plj8MSS/XQ1n+xyzpEh1Umeu2Mfta6YKNoPnCplBq3Q5NjZV/+99qmi4e7+tcw7cKf3TCynJpjIgFixCECw0f0FBmYe2Xc9DazZu7HqmsYyBwrTd+Pb8vaguKCRVjCfHKqt76mFDqsYUKHaBGvABeMENdL/eP1Mw5xUscOhySXVMY9lLJYSk1mz8JN9prpPm7FkjvY5a5XZisnN+UkwucPiu0tONyftha06BVWztdsT8pNRovR5qPNuZG/c5xjzHBh5MjjsfDa2tfPVy3HRg3VdhmQUNyAMDh/67SBn3aheQr7EenCIm9t7mDtqXuXpZCPXwqEvBYsW4cYygSTF1GRaZ4+vbz+8XsPtQVdGuUNX07MVKMqc3797CvcwzpuDeEPSRyuwdh8vT7NKE6C0gD4RxsuDVtx6XQmXvOzhbSCIZvrS9OOCeI5OlvCnh7IAF9V16odKXmKb3MugIEzZLhyNMuY1HTjH9aJmEW00AYTvCdgrM91u6bk6YnNc5YTbvuKabd3HC7KXKl9k+r5lOUr4Ux+biKvApb1WeemreUuKc6Ci91aK3dL5uANP7Gfstn7Fb4NmRmf1n7MZbD8dq46kzeaYzNjTL/0fLrm7L/+qzb/4H \ No newline at end of file + \ No newline at end of file diff --git a/badges/chat.svg b/badges/chat.svg deleted file mode 100644 index 3d3131e183..0000000000 --- a/badges/chat.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - Talk - Talk - Telegram - Telegram - - \ No newline at end of file diff --git a/badges/kdocs.svg b/badges/kdocs.svg deleted file mode 100644 index 01f750a6de..0000000000 --- a/badges/kdocs.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - Open - Open - KDocs - KDocs - - \ No newline at end of file diff --git a/badges/template.svg b/badges/template.svg deleted file mode 100644 index 999fceb4c7..0000000000 --- a/badges/template.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - Bot - Bot - Template - Template - - \ No newline at end of file diff --git a/resources/TelegramBotAPI-libraries-hierarchy.svg b/resources/TelegramBotAPI-libraries-hierarchy.svg index 6b39a9717b..703af70e98 100644 --- a/resources/TelegramBotAPI-libraries-hierarchy.svg +++ b/resources/TelegramBotAPI-libraries-hierarchy.svg @@ -1,3 +1,144 @@ - - -

tgbotapi.extensions.api

Extensions project for make requests more look like in the Telegram Bot API and give opportunity to use it's easier

tgbotapi.extensions.api...

tgbotapi.core

Root project with API. It is not recommended to use its requests directly and better to use at least tgbotapi.extensions.api

tgbotapi.core...

tgbotapi.extensions.utils

Extensions project with utils things which will make easier different operations

tgbotapi.extensions.utils...

tgbotapi.extensions.behaviour_builder

Extension project for building bot behaviour via special DSL

tgbotapi.extensions.behaviour_builder...

tgbotapi

Here included all available TelegramBotAPI libraries:

  • tgbotapi.core
  • tgbotapi.extensions.api
  • tgbotapi.extensions.utils
  • tgbotapi.extensions.behaviour_builder
  • tgbotapi.extensions.behaviour_builder.fsm

tgbotapi...

tgbotapi.extensions.behaviour_builder.fsm

Extension project for building bot behaviour via special DSL

tgbotapi.extensions.behaviour_builder.fsm...
Viewer does not support full SVG 1.1
\ No newline at end of file +

tgbotapi.api

Extensions project for make requests more look like in the Telegram Bot API and give opportunity to use it's easier

tgbotapi.api...

tgbotapi.core

Root project with API. It is not recommended to use its requests directly and better to use at least tgbotapi.extensions.api

tgbotapi.core...

tgbotapi.utils

Extensions project with utils things which will make easier different operations

tgbotapi.utils...

tgbotapi.behaviour_builder

Extension project for building bot behaviour via special DSL

tgbotapi.behaviour_builder...

tgbotapi

Here included all available TelegramBotAPI libraries:

  • tgbotapi.core
  • tgbotapi.api
  • tgbotapi.utils
  • tgbotapi.behaviour_builder
  • tgbotapi.behaviour_builder.fsm

tgbotapi...

tgbotapi.behaviour_builder.fsm

Extension project for building bot behaviour via special DSL

tgbotapi.behaviour_builder.fsm...
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 70c3b4c77a..f33377257e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -12,6 +12,10 @@ pluginManagement { } include ":tgbotapi.core" +include ":tgbotapi.api" +include ":tgbotapi.utils" +include ":tgbotapi.behaviour_builder" +include ":tgbotapi.behaviour_builder.fsm" include ":tgbotapi.extensions.api" include ":tgbotapi.extensions.utils" include ":tgbotapi.extensions.behaviour_builder" diff --git a/tgbotapi.extensions.api/README.md b/tgbotapi.api/README.md similarity index 100% rename from tgbotapi.extensions.api/README.md rename to tgbotapi.api/README.md diff --git a/tgbotapi.api/build.gradle b/tgbotapi.api/build.gradle new file mode 100644 index 0000000000..54888411ac --- /dev/null +++ b/tgbotapi.api/build.gradle @@ -0,0 +1,50 @@ +buildscript { + repositories { + mavenLocal() + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" + } +} + +plugins { + id "org.jetbrains.kotlin.multiplatform" + id "org.jetbrains.kotlin.plugin.serialization" +} + +project.version = "$library_version" +project.group = "$library_group" + +apply from: "publish.gradle" + +repositories { + mavenLocal() + mavenCentral() +} + +kotlin { + jvm() + js(IR) { + browser() + nodejs() + } + + sourceSets { + commonMain { + dependencies { + implementation kotlin('stdlib') + api project(":tgbotapi.core") + } + } + } +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} + diff --git a/tgbotapi.api/mpp_publish_template.kpsb b/tgbotapi.api/mpp_publish_template.kpsb new file mode 100644 index 0000000000..a0b4d37d9d --- /dev/null +++ b/tgbotapi.api/mpp_publish_template.kpsb @@ -0,0 +1 @@ +{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Extensions for API","description":"API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-api","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}]}} \ No newline at end of file diff --git a/tgbotapi.api/publish.gradle b/tgbotapi.api/publish.gradle new file mode 100644 index 0000000000..3d4d7407f8 --- /dev/null +++ b/tgbotapi.api/publish.gradle @@ -0,0 +1,69 @@ +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task javadocsJar(type: Jar) { + classifier = 'javadoc' +} + +publishing { + publications.all { + artifact javadocsJar + + pom { + description = "API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference" + name = "Telegram Bot API Extensions for API" + url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-api" + + scm { + developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git" + url = "https://github.com/insanusmokrassar/TelegramBotAPI.git" + } + + developers { + + developer { + id = "InsanusMokrassar" + name = "Ovsiannikov Aleksei" + email = "ovsyannikov.alexey95@gmail.com" + } + + } + + licenses { + + license { + name = "Apache Software License 2.0" + url = "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE" + } + + } + } + repositories { + if ((project.hasProperty('GITHUBPACKAGES_USER') || System.getenv('GITHUBPACKAGES_USER') != null) && (project.hasProperty('GITHUBPACKAGES_PASSWORD') || System.getenv('GITHUBPACKAGES_PASSWORD') != null)) { + maven { + name = "GithubPackages" + url = uri("https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI") + credentials { + username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER') + password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD') + } + } + } + if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) { + maven { + name = "sonatype" + url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") + credentials { + username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER') + password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD') + } + } + } + } + } +} + +signing { + useGpgCmd() + sign publishing.publications +} diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotBuilder.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotBuilder.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotBuilder.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotBuilder.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotExtensions.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotExtensions.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotExtensions.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/BotExtensions.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/Close.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/Close.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/Close.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/Close.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessage.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessage.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DeleteMessage.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessage.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessage.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/ForwardMessage.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/GetUpdates.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/GetUpdates.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/GetUpdates.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/GetUpdates.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/InternalUtils/UpdatesUtils.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/InternalUtils/UpdatesUtils.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/InternalUtils/UpdatesUtils.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/InternalUtils/UpdatesUtils.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/JsonUtils.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/JsonUtils.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/JsonUtils.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/JsonUtils.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LiveLocationProvider.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LogOut.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LogOut.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LogOut.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/LogOut.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/StopPoll.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/StopPoll.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/StopPoll.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/StopPoll.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerCallbackQuery.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerCallbackQuery.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerCallbackQuery.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerCallbackQuery.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerInlineQuery.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerInlineQuery.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerInlineQuery.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerInlineQuery.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/payments/AnswerPreCheckoutQuery.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/payments/AnswerPreCheckoutQuery.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/payments/AnswerPreCheckoutQuery.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/payments/AnswerPreCheckoutQuery.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/payments/AnswerShippingQuery.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/payments/AnswerShippingQuery.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/payments/AnswerShippingQuery.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/payments/AnswerShippingQuery.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/DeleteMyCommands.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/DeleteMyCommands.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/DeleteMyCommands.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/DeleteMyCommands.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMe.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMe.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMe.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMe.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyCommands.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyCommands.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyCommands.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/GetMyCommands.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyCommands.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyCommands.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyCommands.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/bot/SetMyCommands.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/ExportChatInviteLink.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/ExportChatInviteLink.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/ExportChatInviteLink.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/ExportChatInviteLink.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/LeaveChat.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/LeaveChat.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/LeaveChat.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/LeaveChat.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChat.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChat.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChat.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChat.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatAdministrators.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatAdministrators.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatAdministrators.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatAdministrators.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatMemberCount.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatMemberCount.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatMemberCount.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatMemberCount.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/CreateChatInviteLink.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/CreateChatInviteLink.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/CreateChatInviteLink.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/CreateChatInviteLink.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/EditChatInviteLink.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/EditChatInviteLink.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/EditChatInviteLink.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/EditChatInviteLink.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/RevokeChatInviteLink.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/RevokeChatInviteLink.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/RevokeChatInviteLink.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/RevokeChatInviteLink.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatMember.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatMember.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatMember.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatMember.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/GetChatMember.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/GetChatMember.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/GetChatMember.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/GetChatMember.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/RestrictChatMember.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/RestrictChatMember.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/RestrictChatMember.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/RestrictChatMember.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/SetChatAdministratorCustomTitle.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/SetChatAdministratorCustomTitle.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/SetChatAdministratorCustomTitle.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/SetChatAdministratorCustomTitle.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/UnbanChatMember.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/UnbanChatMember.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/UnbanChatMember.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/UnbanChatMember.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/DeleteChatPhoto.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/DeleteChatPhoto.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/DeleteChatPhoto.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/DeleteChatPhoto.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/PinChatMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/PinChatMessage.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/PinChatMessage.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/PinChatMessage.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatDescription.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatDescription.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatDescription.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatDescription.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatPermissions.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatPermissions.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatPermissions.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatPermissions.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatPhoto.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatPhoto.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatPhoto.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatPhoto.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatTitle.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatTitle.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatTitle.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/SetChatTitle.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/UnpinAllChatMessages.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/UnpinAllChatMessages.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/UnpinAllChatMessages.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/UnpinAllChatMessages.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/UnpinChatMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/UnpinChatMessage.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/UnpinChatMessage.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/modify/UnpinChatMessage.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/stickers/DeleteChatStickerSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/stickers/DeleteChatStickerSet.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/stickers/DeleteChatStickerSet.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/stickers/DeleteChatStickerSet.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/stickers/SetChatStickerSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/stickers/SetChatStickerSet.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/stickers/SetChatStickerSet.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/stickers/SetChatStickerSet.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditChatMessageLiveLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditChatMessageLiveLocation.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditChatMessageLiveLocation.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditChatMessageLiveLocation.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditInlineMessageLiveLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditInlineMessageLiveLocation.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditInlineMessageLiveLocation.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/EditInlineMessageLiveLocation.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopChatMessageLiveLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopChatMessageLiveLocation.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopChatMessageLiveLocation.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopChatMessageLiveLocation.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopInlineMessageLiveLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopInlineMessageLiveLocation.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopInlineMessageLiveLocation.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopInlineMessageLiveLocation.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditInlineMessageCaption.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditInlineMessageCaption.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditInlineMessageCaption.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditInlineMessageCaption.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditChatMessageMedia.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditChatMessageMedia.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditChatMessageMedia.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditChatMessageMedia.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditInlineMessageMedia.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditInlineMessageMedia.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditInlineMessageMedia.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditInlineMessageMedia.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFile.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFile.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFile.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFile.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileStream.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileStream.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileStream.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileStream.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileStreamAllocator.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileStreamAllocator.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileStreamAllocator.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileStreamAllocator.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/GetGameHighScoresByChat.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/GetGameHighScoresByChat.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/GetGameHighScoresByChat.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/GetGameHighScoresByChat.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/GetGameHighScoresByInlineMessageId.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/GetGameHighScoresByInlineMessageId.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/GetGameHighScoresByInlineMessageId.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/GetGameHighScoresByInlineMessageId.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/SetGameScoreByChatId.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/SetGameScoreByChatId.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/SetGameScoreByChatId.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/SetGameScoreByChatId.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/SetGameScoreByInlineMessageId.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/SetGameScoreByInlineMessageId.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/SetGameScoreByInlineMessageId.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/games/SetGameScoreByInlineMessageId.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetFile.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetFile.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetFile.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetFile.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetStickerSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetStickerSet.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetStickerSet.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetStickerSet.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetUserProfilePhotos.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetUserProfilePhotos.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetUserProfilePhotos.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/get/GetUserProfilePhotos.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/passport/SetPassportDataErrors.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/passport/SetPassportDataErrors.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/passport/SetPassportDataErrors.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/passport/SetPassportDataErrors.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/CopyMessage.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendAction.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendActionDSL.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendContact.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendContact.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendContact.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendContact.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendDice.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendDice.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendDice.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendDice.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLocation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLocation.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLocation.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLocation.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendVenue.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendVenue.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendVenue.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendVenue.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/games/SendGame.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/games/SendGame.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/games/SendGame.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/games/SendGame.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddAnimatedStickerToSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddAnimatedStickerToSet.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddAnimatedStickerToSet.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddAnimatedStickerToSet.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStaticStickerToSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStaticStickerToSet.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStaticStickerToSet.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/AddStaticStickerToSet.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewAnimatedStickerSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewAnimatedStickerSet.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewAnimatedStickerSet.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewAnimatedStickerSet.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewStaticStickerSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewStaticStickerSet.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewStaticStickerSet.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/CreateNewStaticStickerSet.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/DeleteStickerFromSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/DeleteStickerFromSet.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/DeleteStickerFromSet.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/DeleteStickerFromSet.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerPositionInSet.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerPositionInSet.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerPositionInSet.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerPositionInSet.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerSetThumb.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerSetThumb.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerSetThumb.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/SetStickerSetThumb.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/UploadStickerFile.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/UploadStickerFile.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/UploadStickerFile.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/stickers/UploadStickerFile.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/utils/UpdatesHandling.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/utils/UpdatesHandling.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/utils/UpdatesHandling.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/utils/UpdatesHandling.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/DeleteWebhook.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/DeleteWebhook.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/DeleteWebhook.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/DeleteWebhook.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/GetWebhookInfo.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/GetWebhookInfo.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/GetWebhookInfo.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/GetWebhookInfo.kt diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/SetWebhookInfo.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/SetWebhookInfo.kt similarity index 100% rename from tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/SetWebhookInfo.kt rename to tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/webhook/SetWebhookInfo.kt diff --git a/tgbotapi.extensions.api/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileToFile.kt b/tgbotapi.api/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileToFile.kt similarity index 100% rename from tgbotapi.extensions.api/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileToFile.kt rename to tgbotapi.api/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/api/files/DownloadFileToFile.kt diff --git a/tgbotapi.extensions.behaviour_builder.fsm/README.md b/tgbotapi.behaviour_builder.fsm/README.md similarity index 100% rename from tgbotapi.extensions.behaviour_builder.fsm/README.md rename to tgbotapi.behaviour_builder.fsm/README.md diff --git a/tgbotapi.behaviour_builder.fsm/build.gradle b/tgbotapi.behaviour_builder.fsm/build.gradle new file mode 100644 index 0000000000..285b417626 --- /dev/null +++ b/tgbotapi.behaviour_builder.fsm/build.gradle @@ -0,0 +1,50 @@ +buildscript { + repositories { + mavenLocal() + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" + } +} + +plugins { + id "org.jetbrains.kotlin.multiplatform" + id "org.jetbrains.kotlin.plugin.serialization" +} + +project.version = "$library_version" +project.group = "$library_group" + +apply from: "publish.gradle" + +repositories { + mavenLocal() + mavenCentral() +} + +kotlin { + jvm() + js(IR) { + browser() + nodejs() + } + + sourceSets { + commonMain { + dependencies { + implementation kotlin('stdlib') + api project(":tgbotapi.behaviour_builder") + api "dev.inmo:micro_utils.fsm.common:$micro_utils_version" + } + } + } +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} diff --git a/tgbotapi.behaviour_builder.fsm/mpp_publish_template.kpsb b/tgbotapi.behaviour_builder.fsm/mpp_publish_template.kpsb new file mode 100644 index 0000000000..be7b82e6ec --- /dev/null +++ b/tgbotapi.behaviour_builder.fsm/mpp_publish_template.kpsb @@ -0,0 +1 @@ +{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot Behaviour Builder FSM Extensions","description":"FSM extension for dev.inmo:tgbotapi.extensions.behaviour_builder.fsm","url":"https://insanusmokrassar.github.io/TelegramBotAPI/tgbotapi.extensions.behaviour_builder","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}]}} diff --git a/tgbotapi.behaviour_builder.fsm/publish.gradle b/tgbotapi.behaviour_builder.fsm/publish.gradle new file mode 100644 index 0000000000..562185a08c --- /dev/null +++ b/tgbotapi.behaviour_builder.fsm/publish.gradle @@ -0,0 +1,69 @@ +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task javadocsJar(type: Jar) { + classifier = 'javadoc' +} + +publishing { + publications.all { + artifact javadocsJar + + pom { + description = "FSM extension for dev.inmo:tgbotapi.extensions.behaviour_builder.fsm" + name = "Telegram Bot Behaviour Builder FSM Extensions" + url = "https://insanusmokrassar.github.io/TelegramBotAPI/tgbotapi.extensions.behaviour_builder" + + scm { + developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git" + url = "https://github.com/insanusmokrassar/TelegramBotAPI.git" + } + + developers { + + developer { + id = "InsanusMokrassar" + name = "Ovsiannikov Aleksei" + email = "ovsyannikov.alexey95@gmail.com" + } + + } + + licenses { + + license { + name = "Apache Software License 2.0" + url = "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE" + } + + } + } + repositories { + if ((project.hasProperty('GITHUBPACKAGES_USER') || System.getenv('GITHUBPACKAGES_USER') != null) && (project.hasProperty('GITHUBPACKAGES_PASSWORD') || System.getenv('GITHUBPACKAGES_PASSWORD') != null)) { + maven { + name = "GithubPackages" + url = uri("https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI") + credentials { + username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER') + password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD') + } + } + } + if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) { + maven { + name = "sonatype" + url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") + credentials { + username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER') + password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD') + } + } + } + } + } +} + +signing { + useGpgCmd() + sign publishing.publications +} diff --git a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt rename to tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt diff --git a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt rename to tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt diff --git a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandler.kt b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandler.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandler.kt rename to tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandler.kt diff --git a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder.kt b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder.kt rename to tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder.kt diff --git a/tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt rename to tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt diff --git a/tgbotapi.extensions.behaviour_builder/README.md b/tgbotapi.behaviour_builder/README.md similarity index 100% rename from tgbotapi.extensions.behaviour_builder/README.md rename to tgbotapi.behaviour_builder/README.md diff --git a/tgbotapi.behaviour_builder/build.gradle b/tgbotapi.behaviour_builder/build.gradle new file mode 100644 index 0000000000..7a3d80e9da --- /dev/null +++ b/tgbotapi.behaviour_builder/build.gradle @@ -0,0 +1,49 @@ +buildscript { + repositories { + mavenLocal() + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" + } +} + +plugins { + id "org.jetbrains.kotlin.multiplatform" + id "org.jetbrains.kotlin.plugin.serialization" +} + +project.version = "$library_version" +project.group = "$library_group" + +apply from: "publish.gradle" + +repositories { + mavenLocal() + mavenCentral() +} + +kotlin { + jvm() + js(IR) { + browser() + nodejs() + } + + sourceSets { + commonMain { + dependencies { + implementation kotlin('stdlib') + api project(":tgbotapi.utils") + } + } + } +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} diff --git a/tgbotapi.behaviour_builder/mpp_publish_template.kpsb b/tgbotapi.behaviour_builder/mpp_publish_template.kpsb new file mode 100644 index 0000000000..21548e829f --- /dev/null +++ b/tgbotapi.behaviour_builder/mpp_publish_template.kpsb @@ -0,0 +1 @@ +{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Steps Extensions","description":"This extensions project contains tools for simple interaction with chats","url":"https://insanusmokrassar.github.io/TelegramBotAPI/tgbotapi.extensions.steps","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}]}} \ No newline at end of file diff --git a/tgbotapi.behaviour_builder/publish.gradle b/tgbotapi.behaviour_builder/publish.gradle new file mode 100644 index 0000000000..5af61a71f8 --- /dev/null +++ b/tgbotapi.behaviour_builder/publish.gradle @@ -0,0 +1,69 @@ +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task javadocsJar(type: Jar) { + classifier = 'javadoc' +} + +publishing { + publications.all { + artifact javadocsJar + + pom { + description = "This extensions project contains tools for simple interaction with chats" + name = "Telegram Bot API Steps Extensions" + url = "https://insanusmokrassar.github.io/TelegramBotAPI/tgbotapi.extensions.steps" + + scm { + developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git" + url = "https://github.com/insanusmokrassar/TelegramBotAPI.git" + } + + developers { + + developer { + id = "InsanusMokrassar" + name = "Ovsiannikov Aleksei" + email = "ovsyannikov.alexey95@gmail.com" + } + + } + + licenses { + + license { + name = "Apache Software License 2.0" + url = "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE" + } + + } + } + repositories { + if ((project.hasProperty('GITHUBPACKAGES_USER') || System.getenv('GITHUBPACKAGES_USER') != null) && (project.hasProperty('GITHUBPACKAGES_PASSWORD') || System.getenv('GITHUBPACKAGES_PASSWORD') != null)) { + maven { + name = "GithubPackages" + url = uri("https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI") + credentials { + username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER') + password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD') + } + } + } + if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) { + maven { + name = "sonatype" + url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") + credentials { + username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER') + password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD') + } + } + } + } + } +} + +signing { + useGpgCmd() + sign publishing.publications +} diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/Variants.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/Variants.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/Variants.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/Variants.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/Base.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitCallbackQuery.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChatMemberUpdated.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitChosenInlineResult.kt diff --git a/tgbotapi.extensions.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 similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt diff --git a/tgbotapi.extensions.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 similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt diff --git a/tgbotapi.extensions.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 similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitInlineQuery.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitMediaGroup.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPassportData.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPassportData.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPassportData.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPassportData.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollAnswers.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPollUpdates.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitPreCheckoutQuery.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitShippingQuery.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChat.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChat.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChat.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChat.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterExcludingMediaGroups.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterExcludingMediaGroups.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterExcludingMediaGroups.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterExcludingMediaGroups.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CallbackQueryTriggers.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMemberUpdatedTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMemberUpdatedTriggers.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMemberUpdatedTriggers.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMemberUpdatedTriggers.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChosenInlineResultTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChosenInlineResultTriggers.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChosenInlineResultTriggers.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChosenInlineResultTriggers.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt diff --git a/tgbotapi.extensions.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 similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt diff --git a/tgbotapi.extensions.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 similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MediaGroupTriggers.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PassportTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PassportTriggers.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PassportTriggers.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PassportTriggers.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollAnswersTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollAnswersTriggers.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollAnswersTriggers.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollAnswersTriggers.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PollUpdatesTriggers.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PreCheckoutQueryTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PreCheckoutQueryTriggers.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PreCheckoutQueryTriggers.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PreCheckoutQueryTriggers.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ShippingQueryTriggers.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ShippingQueryTriggers.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ShippingQueryTriggers.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ShippingQueryTriggers.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/LiveLocation.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/LiveLocation.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/LiveLocation.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/LiveLocation.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/SubcontextUpdatesFilterOperations.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/SubcontextUpdatesFilterOperations.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/SubcontextUpdatesFilterOperations.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/SubcontextUpdatesFilterOperations.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChatMemberUpdatedMarkerFactories.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChatMemberUpdatedMarkerFactories.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChatMemberUpdatedMarkerFactories.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChatMemberUpdatedMarkerFactories.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChosenInlineResultsMarkerFactories.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChosenInlineResultsMarkerFactories.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChosenInlineResultsMarkerFactories.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/ChosenInlineResultsMarkerFactories.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/InlineQueryMarkerFactories.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/InlineQueryMarkerFactories.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/InlineQueryMarkerFactories.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/InlineQueryMarkerFactories.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MediaGroupMarkerFactories.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MediaGroupMarkerFactories.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MediaGroupMarkerFactories.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MediaGroupMarkerFactories.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MessageMarkerFactories.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MessageMarkerFactories.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MessageMarkerFactories.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MessageMarkerFactories.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/PollMarkerFactories.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/PollMarkerFactories.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/PollMarkerFactories.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/PollMarkerFactories.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/QueryMarkerFactories.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/QueryMarkerFactories.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/QueryMarkerFactories.kt rename to tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/QueryMarkerFactories.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/jsMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/DefaultCoroutineScopeProvider.kt b/tgbotapi.behaviour_builder/src/jsMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/DefaultCoroutineScopeProvider.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/jsMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/DefaultCoroutineScopeProvider.kt rename to tgbotapi.behaviour_builder/src/jsMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/DefaultCoroutineScopeProvider.kt diff --git a/tgbotapi.extensions.behaviour_builder/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/DefaultCoroutineScopeProvider.kt b/tgbotapi.behaviour_builder/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/DefaultCoroutineScopeProvider.kt similarity index 100% rename from tgbotapi.extensions.behaviour_builder/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/DefaultCoroutineScopeProvider.kt rename to tgbotapi.behaviour_builder/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/DefaultCoroutineScopeProvider.kt diff --git a/tgbotapi.core/README.md b/tgbotapi.core/README.md index 428c1a191a..baac76ec7f 100644 --- a/tgbotapi.core/README.md +++ b/tgbotapi.core/README.md @@ -39,7 +39,7 @@ of signed artifacts in Bintray). You can: * Use earlier version (available version you can find [here](https://mvnrepository.com/artifact/com.github.insanusmokrassar/TelegramBotAPI) (before 0.28.0) or [here](https://mvnrepository.com/artifact/dev.inmo/tgbotapi.core)) -* Add `jCenter` repository in build config +* Add `mavenCentral` repository in build config ### Maven diff --git a/tgbotapi.extensions.api/build.gradle b/tgbotapi.extensions.api/build.gradle index 54888411ac..2e59abfe91 100644 --- a/tgbotapi.extensions.api/build.gradle +++ b/tgbotapi.extensions.api/build.gradle @@ -36,7 +36,7 @@ kotlin { commonMain { dependencies { implementation kotlin('stdlib') - api project(":tgbotapi.core") + api project(":tgbotapi.api") } } } diff --git a/tgbotapi.extensions.api/mpp_publish_template.kpsb b/tgbotapi.extensions.api/mpp_publish_template.kpsb index a0b4d37d9d..693f3cac16 100644 --- a/tgbotapi.extensions.api/mpp_publish_template.kpsb +++ b/tgbotapi.extensions.api/mpp_publish_template.kpsb @@ -1 +1 @@ -{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Extensions for API","description":"API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-api","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}]}} \ No newline at end of file +{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API API Extensions for tgbotapi.api","description":"","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-behaviour_builder-fsm","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}]}} diff --git a/tgbotapi.extensions.behaviour_builder.fsm/build.gradle b/tgbotapi.extensions.behaviour_builder.fsm/build.gradle index 9183791d96..70bda66a94 100644 --- a/tgbotapi.extensions.behaviour_builder.fsm/build.gradle +++ b/tgbotapi.extensions.behaviour_builder.fsm/build.gradle @@ -36,8 +36,7 @@ kotlin { commonMain { dependencies { implementation kotlin('stdlib') - api project(":tgbotapi.extensions.behaviour_builder") - api "dev.inmo:micro_utils.fsm.common:$micro_utils_version" + api project(":tgbotapi.behaviour_builder.fsm") } } } @@ -48,3 +47,4 @@ java { languageVersion = JavaLanguageVersion.of(8) } } + diff --git a/tgbotapi.extensions.behaviour_builder.fsm/mpp_publish_template.kpsb b/tgbotapi.extensions.behaviour_builder.fsm/mpp_publish_template.kpsb index be7b82e6ec..eebed183f7 100644 --- a/tgbotapi.extensions.behaviour_builder.fsm/mpp_publish_template.kpsb +++ b/tgbotapi.extensions.behaviour_builder.fsm/mpp_publish_template.kpsb @@ -1 +1 @@ -{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot Behaviour Builder FSM Extensions","description":"FSM extension for dev.inmo:tgbotapi.extensions.behaviour_builder.fsm","url":"https://insanusmokrassar.github.io/TelegramBotAPI/tgbotapi.extensions.behaviour_builder","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}]}} +{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API BehaviourBuilder FSM Extensions for tgbotapi.behaviour_builder.fsm","description":"","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-behaviour_builder-fsm","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}]}} \ No newline at end of file diff --git a/tgbotapi.extensions.behaviour_builder.fsm/publish.gradle b/tgbotapi.extensions.behaviour_builder.fsm/publish.gradle index 562185a08c..3d4d7407f8 100644 --- a/tgbotapi.extensions.behaviour_builder.fsm/publish.gradle +++ b/tgbotapi.extensions.behaviour_builder.fsm/publish.gradle @@ -10,9 +10,9 @@ publishing { artifact javadocsJar pom { - description = "FSM extension for dev.inmo:tgbotapi.extensions.behaviour_builder.fsm" - name = "Telegram Bot Behaviour Builder FSM Extensions" - url = "https://insanusmokrassar.github.io/TelegramBotAPI/tgbotapi.extensions.behaviour_builder" + description = "API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference" + name = "Telegram Bot API Extensions for API" + url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-api" scm { developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git" diff --git a/tgbotapi.extensions.behaviour_builder/build.gradle b/tgbotapi.extensions.behaviour_builder/build.gradle index b85db355e2..4536301cf5 100644 --- a/tgbotapi.extensions.behaviour_builder/build.gradle +++ b/tgbotapi.extensions.behaviour_builder/build.gradle @@ -36,7 +36,7 @@ kotlin { commonMain { dependencies { implementation kotlin('stdlib') - api project(":tgbotapi.extensions.utils") + api project(":tgbotapi.behaviour_builder") } } } @@ -47,3 +47,4 @@ java { languageVersion = JavaLanguageVersion.of(8) } } + diff --git a/tgbotapi.extensions.behaviour_builder/mpp_publish_template.kpsb b/tgbotapi.extensions.behaviour_builder/mpp_publish_template.kpsb index 21548e829f..faf67d4114 100644 --- a/tgbotapi.extensions.behaviour_builder/mpp_publish_template.kpsb +++ b/tgbotapi.extensions.behaviour_builder/mpp_publish_template.kpsb @@ -1 +1 @@ -{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Steps Extensions","description":"This extensions project contains tools for simple interaction with chats","url":"https://insanusmokrassar.github.io/TelegramBotAPI/tgbotapi.extensions.steps","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}]}} \ No newline at end of file +{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API BehaviourBuilder Extensions for tgbotapi.behaviour_builder","description":"","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-behaviour_builder-fsm","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}]}} diff --git a/tgbotapi.extensions.behaviour_builder/publish.gradle b/tgbotapi.extensions.behaviour_builder/publish.gradle index 5af61a71f8..3d4d7407f8 100644 --- a/tgbotapi.extensions.behaviour_builder/publish.gradle +++ b/tgbotapi.extensions.behaviour_builder/publish.gradle @@ -10,9 +10,9 @@ publishing { artifact javadocsJar pom { - description = "This extensions project contains tools for simple interaction with chats" - name = "Telegram Bot API Steps Extensions" - url = "https://insanusmokrassar.github.io/TelegramBotAPI/tgbotapi.extensions.steps" + description = "API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference" + name = "Telegram Bot API Extensions for API" + url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-api" scm { developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git" diff --git a/tgbotapi.extensions.utils/build.gradle b/tgbotapi.extensions.utils/build.gradle index eca97cef94..ad0a0d7910 100644 --- a/tgbotapi.extensions.utils/build.gradle +++ b/tgbotapi.extensions.utils/build.gradle @@ -36,25 +36,7 @@ kotlin { commonMain { dependencies { implementation kotlin('stdlib') - api project(":tgbotapi.core") - } - } - - commonTest { - dependencies { - implementation kotlin('test-common') - implementation kotlin('test-annotations-common') - } - } - jvmTest { - dependencies { - implementation kotlin('test-junit') - } - } - jsTest { - dependencies { - implementation kotlin('test-junit') - implementation kotlin('test-js') + api project(":tgbotapi.utils") } } } @@ -65,3 +47,4 @@ java { languageVersion = JavaLanguageVersion.of(8) } } + diff --git a/tgbotapi.extensions.utils/mpp_publish_template.kpsb b/tgbotapi.extensions.utils/mpp_publish_template.kpsb index b9cb0896cd..d3b6348ee8 100644 --- a/tgbotapi.extensions.utils/mpp_publish_template.kpsb +++ b/tgbotapi.extensions.utils/mpp_publish_template.kpsb @@ -1 +1 @@ -{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Utility Extensions","description":"Util extensions for more useful work with updates and other things","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-utils","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}]}} \ No newline at end of file +{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Utils Extensions for tgbotapi.utils","description":"","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-behaviour_builder-fsm","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}]}} diff --git a/tgbotapi.extensions.utils/publish.gradle b/tgbotapi.extensions.utils/publish.gradle index 8cd9a87e46..3d4d7407f8 100644 --- a/tgbotapi.extensions.utils/publish.gradle +++ b/tgbotapi.extensions.utils/publish.gradle @@ -10,9 +10,9 @@ publishing { artifact javadocsJar pom { - description = "Util extensions for more useful work with updates and other things" - name = "Telegram Bot API Utility Extensions" - url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-utils" + description = "API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference" + name = "Telegram Bot API Extensions for API" + url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-api" scm { developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git" diff --git a/tgbotapi.extensions.utils/README.md b/tgbotapi.utils/README.md similarity index 100% rename from tgbotapi.extensions.utils/README.md rename to tgbotapi.utils/README.md diff --git a/tgbotapi.utils/build.gradle b/tgbotapi.utils/build.gradle new file mode 100644 index 0000000000..eca97cef94 --- /dev/null +++ b/tgbotapi.utils/build.gradle @@ -0,0 +1,67 @@ +buildscript { + repositories { + mavenLocal() + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" + } +} + +plugins { + id "org.jetbrains.kotlin.multiplatform" + id "org.jetbrains.kotlin.plugin.serialization" +} + +project.version = "$library_version" +project.group = "$library_group" + +apply from: "publish.gradle" + +repositories { + mavenLocal() + mavenCentral() +} + +kotlin { + jvm() + js(IR) { + browser() + nodejs() + } + + sourceSets { + commonMain { + dependencies { + implementation kotlin('stdlib') + api project(":tgbotapi.core") + } + } + + commonTest { + dependencies { + implementation kotlin('test-common') + implementation kotlin('test-annotations-common') + } + } + jvmTest { + dependencies { + implementation kotlin('test-junit') + } + } + jsTest { + dependencies { + implementation kotlin('test-junit') + implementation kotlin('test-js') + } + } + } +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} diff --git a/tgbotapi.utils/mpp_publish_template.kpsb b/tgbotapi.utils/mpp_publish_template.kpsb new file mode 100644 index 0000000000..b9cb0896cd --- /dev/null +++ b/tgbotapi.utils/mpp_publish_template.kpsb @@ -0,0 +1 @@ +{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Utility Extensions","description":"Util extensions for more useful work with updates and other things","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-utils","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}]}} \ No newline at end of file diff --git a/tgbotapi.utils/publish.gradle b/tgbotapi.utils/publish.gradle new file mode 100644 index 0000000000..8cd9a87e46 --- /dev/null +++ b/tgbotapi.utils/publish.gradle @@ -0,0 +1,69 @@ +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task javadocsJar(type: Jar) { + classifier = 'javadoc' +} + +publishing { + publications.all { + artifact javadocsJar + + pom { + description = "Util extensions for more useful work with updates and other things" + name = "Telegram Bot API Utility Extensions" + url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-utils" + + scm { + developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git" + url = "https://github.com/insanusmokrassar/TelegramBotAPI.git" + } + + developers { + + developer { + id = "InsanusMokrassar" + name = "Ovsiannikov Aleksei" + email = "ovsyannikov.alexey95@gmail.com" + } + + } + + licenses { + + license { + name = "Apache Software License 2.0" + url = "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE" + } + + } + } + repositories { + if ((project.hasProperty('GITHUBPACKAGES_USER') || System.getenv('GITHUBPACKAGES_USER') != null) && (project.hasProperty('GITHUBPACKAGES_PASSWORD') || System.getenv('GITHUBPACKAGES_PASSWORD') != null)) { + maven { + name = "GithubPackages" + url = uri("https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI") + credentials { + username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER') + password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD') + } + } + } + if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) { + maven { + name = "sonatype" + url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") + credentials { + username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER') + password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD') + } + } + } + } + } +} + +signing { + useGpgCmd() + sign publishing.publications +} diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/CallbackQueryConversations.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/CallbackQueryConversations.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/CallbackQueryConversations.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/CallbackQueryConversations.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/CommonMessageConversations.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/CommonMessageConversations.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/CommonMessageConversations.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/CommonMessageConversations.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ContentMessageConversations.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ContentMessageConversations.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ContentMessageConversations.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ContentMessageConversations.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/FlowsAggregation.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/JsonFormat.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/JsonFormat.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/JsonFormat.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/JsonFormat.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/SlotMachineUtils.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/SlotMachineUtils.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/SlotMachineUtils.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/SlotMachineUtils.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/WithContent.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/WithContent.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/WithContent.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/WithContent.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/FilesDownloading.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/FilesDownloading.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/FilesDownloading.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/FilesDownloading.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/FlowsUpdatesFilter.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/FlowsUpdatesFilter.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/FlowsUpdatesFilter.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/FlowsUpdatesFilter.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/TextCaptionBotCommandsParser.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/TextCaptionBotCommandsParser.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/TextCaptionBotCommandsParser.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/TextCaptionBotCommandsParser.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/UpdateChatRetriever.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/venue/Foursquare.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/venue/Foursquare.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/venue/Foursquare.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/venue/Foursquare.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/venue/Google.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/venue/Google.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/venue/Google.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/venue/Google.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/EntitiesBuilder.kt diff --git a/tgbotapi.extensions.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 similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/LinksFormatting.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/ResendingTextFormatting.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/ResendingTextFormatting.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/ResendingTextFormatting.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/ResendingTextFormatting.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/StringFormatting.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/StringFormatting.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/StringFormatting.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/formatting/StringFormatting.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/internal_utils/UpdatesFiltering.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/internal_utils/UpdatesFiltering.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/internal_utils/UpdatesFiltering.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/internal_utils/UpdatesFiltering.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/CommandsShortcuts.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/CommandsShortcuts.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/CommandsShortcuts.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/CommandsShortcuts.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/EventsShortcuts.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/FlowsUpdatesFilter.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/MediaGroupsShortcuts.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/MediaGroupsShortcuts.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/MediaGroupsShortcuts.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/MediaGroupsShortcuts.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/PollCloseShortcuts.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/PollCloseShortcuts.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/PollCloseShortcuts.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/PollCloseShortcuts.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/RequestsExecutor.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/RequestsExecutor.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/RequestsExecutor.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/shortcuts/RequestsExecutor.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardBuilder.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardMarkup.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardMarkup.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardMarkup.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/InlineKeyboardMarkup.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardBuilder.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardMarkup.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardMarkup.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardMarkup.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/buttons/ReplyKeyboardMarkup.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/files/ContentAsStorageFile.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/files/ContentAsStorageFile.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/files/ContentAsStorageFile.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/types/files/ContentAsStorageFile.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/BaseMessagesUpdatesConversations.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/BaseMessagesUpdatesConversations.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/BaseMessagesUpdatesConversations.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/BaseMessagesUpdatesConversations.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CallbackQueryUpdatesConversations.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CallbackQueryUpdatesConversations.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CallbackQueryUpdatesConversations.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CallbackQueryUpdatesConversations.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/ChosenInlineResultUpdatesConversations.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/ChosenInlineResultUpdatesConversations.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/ChosenInlineResultUpdatesConversations.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/ChosenInlineResultUpdatesConversations.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CommandsFilters.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CommandsFilters.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CommandsFilters.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/CommandsFilters.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/FlowsUpdatesFactory.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/FlowsUpdatesFactory.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/FlowsUpdatesFactory.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/FlowsUpdatesFactory.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/InlineQueryUpdatesConversations.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/InlineQueryUpdatesConversations.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/InlineQueryUpdatesConversations.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/InlineQueryUpdatesConversations.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/SentMessageUpdatesConversations.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/SentMessageUpdatesConversations.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/SentMessageUpdatesConversations.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/SentMessageUpdatesConversations.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdateDeserialization.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdateDeserialization.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdateDeserialization.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdateDeserialization.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesChatFilters.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesChatFilters.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesChatFilters.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesChatFilters.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesUtils.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesUtils.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesUtils.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/UpdatesUtils.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/LongPolling.kt diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/MediaGroupsIncluder.kt b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/MediaGroupsIncluder.kt similarity index 100% rename from tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/MediaGroupsIncluder.kt rename to tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/MediaGroupsIncluder.kt diff --git a/tgbotapi.extensions.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/Webhook.kt b/tgbotapi.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/Webhook.kt similarity index 100% rename from tgbotapi.extensions.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/Webhook.kt rename to tgbotapi.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/extensions/utils/updates/retrieving/Webhook.kt diff --git a/tgbotapi.extensions.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt b/tgbotapi.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt similarity index 100% rename from tgbotapi.extensions.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt rename to tgbotapi.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt diff --git a/tgbotapi/build.gradle b/tgbotapi/build.gradle index 6efa3efad7..5cd816bf7b 100644 --- a/tgbotapi/build.gradle +++ b/tgbotapi/build.gradle @@ -37,10 +37,10 @@ kotlin { dependencies { implementation kotlin('stdlib') api project(":tgbotapi.core") - api project(":tgbotapi.extensions.api") - api project(":tgbotapi.extensions.utils") - api project(":tgbotapi.extensions.behaviour_builder") - api project(":tgbotapi.extensions.behaviour_builder.fsm") + api project(":tgbotapi.api") + api project(":tgbotapi.utils") + api project(":tgbotapi.behaviour_builder") + api project(":tgbotapi.behaviour_builder.fsm") } } } From dd979d8626ef977911fd3c6cf88ce59266b2072f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 18 Oct 2021 15:23:43 +0600 Subject: [PATCH 36/40] update publish scripts of old packages --- tgbotapi.extensions.api/publish.gradle | 6 +++--- tgbotapi.extensions.behaviour_builder.fsm/publish.gradle | 6 +++--- tgbotapi.extensions.behaviour_builder/publish.gradle | 6 +++--- tgbotapi.extensions.utils/publish.gradle | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tgbotapi.extensions.api/publish.gradle b/tgbotapi.extensions.api/publish.gradle index 3d4d7407f8..2b4408727a 100644 --- a/tgbotapi.extensions.api/publish.gradle +++ b/tgbotapi.extensions.api/publish.gradle @@ -10,9 +10,9 @@ publishing { artifact javadocsJar pom { - description = "API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference" - name = "Telegram Bot API Extensions for API" - url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-api" + description = "${project.name}" + name = "Telegram Bot API API Extensions for tgbotapi.api" + url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-behaviour_builder-fsm" scm { developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git" diff --git a/tgbotapi.extensions.behaviour_builder.fsm/publish.gradle b/tgbotapi.extensions.behaviour_builder.fsm/publish.gradle index 3d4d7407f8..80c48eb3ff 100644 --- a/tgbotapi.extensions.behaviour_builder.fsm/publish.gradle +++ b/tgbotapi.extensions.behaviour_builder.fsm/publish.gradle @@ -10,9 +10,9 @@ publishing { artifact javadocsJar pom { - description = "API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference" - name = "Telegram Bot API Extensions for API" - url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-api" + description = "${project.name}" + name = "Telegram Bot API BehaviourBuilder FSM Extensions for tgbotapi.behaviour_builder.fsm" + url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-behaviour_builder-fsm" scm { developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git" diff --git a/tgbotapi.extensions.behaviour_builder/publish.gradle b/tgbotapi.extensions.behaviour_builder/publish.gradle index 3d4d7407f8..5f260c1a79 100644 --- a/tgbotapi.extensions.behaviour_builder/publish.gradle +++ b/tgbotapi.extensions.behaviour_builder/publish.gradle @@ -10,9 +10,9 @@ publishing { artifact javadocsJar pom { - description = "API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference" - name = "Telegram Bot API Extensions for API" - url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-api" + description = "${project.name}" + name = "Telegram Bot API BehaviourBuilder Extensions for tgbotapi.behaviour_builder" + url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-behaviour_builder-fsm" scm { developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git" diff --git a/tgbotapi.extensions.utils/publish.gradle b/tgbotapi.extensions.utils/publish.gradle index 3d4d7407f8..7fccf82acc 100644 --- a/tgbotapi.extensions.utils/publish.gradle +++ b/tgbotapi.extensions.utils/publish.gradle @@ -10,9 +10,9 @@ publishing { artifact javadocsJar pom { - description = "API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference" - name = "Telegram Bot API Extensions for API" - url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-api" + description = "${project.name}" + name = "Telegram Bot API Utils Extensions for tgbotapi.utils" + url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-behaviour_builder-fsm" scm { developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git" From 576b25190a2d0af2e62f4a1f2bc796ad3b18e353 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 18 Oct 2021 15:37:10 +0600 Subject: [PATCH 37/40] cleanup 'extension' suffix in readmes --- README.md | 7 ++--- tgbotapi.api/README.md | 33 +++++++----------------- tgbotapi.behaviour_builder.fsm/README.md | 4 +-- tgbotapi.behaviour_builder/README.md | 9 +------ tgbotapi.core/README.md | 2 +- tgbotapi.utils/README.md | 31 +++++----------------- tgbotapi/README.md | 7 ++--- 7 files changed, 28 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index 0d30036f1b..acefa84cc1 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,10 @@ Hello! This is a set of libraries for working with Telegram Bot API. | -------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | Useful links | [![Chat in Telegram](https://img.shields.io/static/v1?label=Talk&message=Telegram&color=blue)](https://t.me/InMoTelegramBotAPI) [![Create bot](https://img.shields.io/static/v1?label=Github&message=Template&color=blue)](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [![KDocs](https://img.shields.io/static/v1?label=Open&message=kdocs&color=blue)](https://tgbotapi.inmo.dev/index.html) [Examples](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/), [Mini tutorial](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) | | TelegramBotAPI Core status | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core) | -| TelegramBotAPI API Extensions status | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.api) | -| TelegramBotAPI Util Extensions status | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.utils/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.utils) | -| TelegramBotAPI Behaviour Builder Extensions status | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.behaviour_builder/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.behaviour_builder) | +| TelegramBotAPI API Extensions status | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.api) | +| TelegramBotAPI Util Extensions status | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.utils/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.utils) | +| TelegramBotAPI Behaviour Builder Extensions status | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.behaviour_builder/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.behaviour_builder) | +| TelegramBotAPI Behaviour Builder Extensions status | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.behaviour_builder.fsm/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.behaviour_builder.fsm) | | TelegramBotAPI All status | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) | ## Examples diff --git a/tgbotapi.api/README.md b/tgbotapi.api/README.md index a686fbf6f4..52441ed4f4 100644 --- a/tgbotapi.api/README.md +++ b/tgbotapi.api/README.md @@ -1,18 +1,6 @@ -# TelegramBotAPI extensions +# TelegramBotAPI API extensions -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.api) - -- [TelegramBotAPI extensions](#telegrambotapi-extensions) - * [What is it?](#what-is-it) - * [Compatibility](#compatibility) - * [How to implement library?](#how-to-implement-library) - + [Maven](#maven) - + [Gradle](#gradle) - * [Example of usage and comparison with `TelegramBotAPI`](#example-of-usage-and-comparison-with-telegrambotapi) - * [Updates](#updates) - + [Alternative way](#alternative-way) - -Table of contents generated with markdown-toc +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.api) ## What is it? @@ -28,10 +16,9 @@ This library always compatible with original `tgbotapi.core` library version Common ways to implement this library are presented here. In some cases it will require additional steps like inserting of additional libraries (like `kotlin stdlib`). In the examples will be used variable -`telegrambotapi-extensions-api.version`, which must be set up by developer. Available versions are presented on -[bintray](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.api), next version is last published: +`telegrambotapi-extensions-api.version`, which must be set up by developer. -[![Download](https://api.bintray.com/packages/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.api/images/download.svg) ](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.api/_latestVersion) +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.api) ### Maven @@ -40,7 +27,7 @@ Dependency config presented here: ```xml dev.inmo - tgbotapi.extensions.api + tgbotapi.api ${telegrambotapi-extensions-api.version} ``` @@ -54,13 +41,13 @@ To use last versions you will need to add one line in repositories block of your And add next line to your dependencies block: ```groovy -implementation "dev.inmo:tgbotapi.extensions.api:$telegrambotapi_extensions_api_version" +implementation "dev.inmo:tgbotapi.api:$telegrambotapi_extensions_api_version" ``` or for old gradle: ```groovy -compile "dev.inmo:tgbotapi.extensions.api:$telegrambotapi_extensions_api_version" +compile "dev.inmo:tgbotapi.api:$telegrambotapi_extensions_api_version" ``` ## Example of usage and comparison with `TelegramBotAPI` @@ -82,7 +69,7 @@ val bot = telegramBot("IT IS YOUR TOKEN") { In all examples supposed that you have created bot. -| tgbotapi.core | tgbotapi.extensions.api | +| tgbotapi.core | tgbotapi.api | |---------------------|-------------------------------| | bot.execute(GetMe) | bot.getMe() | | bot.execute(SendTextMessage(someChatId, text)) | bot.sendTextMessage(chat, text) | @@ -90,8 +77,8 @@ In all examples supposed that you have created bot. ## Updates **Currently, these paragraphs almost outdated due to the fact that extensions for listening of updates and webhooks were -replaced into `tgbotapi.extensions.utils`. But, most part of information below is correct with small fixes and -adding of `tgbotapi.extensions.utils` dependency.** +replaced into `tgbotapi.utils`. But, most part of information below is correct with small fixes and +adding of `tgbotapi.utils` dependency.** Usually, it is more comfortable to use filter object to get separated types of updates: diff --git a/tgbotapi.behaviour_builder.fsm/README.md b/tgbotapi.behaviour_builder.fsm/README.md index 50375a9607..5bdfd2ef2c 100644 --- a/tgbotapi.behaviour_builder.fsm/README.md +++ b/tgbotapi.behaviour_builder.fsm/README.md @@ -1,8 +1,8 @@ # TelegramBotAPI Behaviour Builder FSM Extensions -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.behaviour_builder.fsm/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.behaviour_builder.fsm) +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.behaviour_builder.fsm/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.behaviour_builder.fsm) -This extension has been created to integrate finite state machine in [BehaviourBuilder](../tgbotapi.extensions.behaviour_builder/README.md). +This extension has been created to integrate finite state machine in [BehaviourBuilder](../tgbotapi.behaviour_builder/README.md). In case you wish to use some custom store for steps (states), you may extend `StatesManager` or use `DefaultStatesManager` with custom `DefaultStatesManagerRepo`. See [Examples repo](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/tree/master/FSMBot) to get more info and see how it works on base level diff --git a/tgbotapi.behaviour_builder/README.md b/tgbotapi.behaviour_builder/README.md index d4160d7c6b..a1ffe177d3 100644 --- a/tgbotapi.behaviour_builder/README.md +++ b/tgbotapi.behaviour_builder/README.md @@ -1,13 +1,6 @@ # TelegramBotAPI Behaviour Builder Extensions -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.behaviour_builder/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.behaviour_builder) - -- [TelegramBotAPI Behaviour Builder Extensions](#telegrambotapi-behaviour-builder-extensions) - * [What is it?](#what-is-it) - * [Triggers](#triggers) - * [Waiters](#waiters) - -Table of contents generated with markdown-toc +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.behaviour_builder/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.behaviour_builder) ## What is it? diff --git a/tgbotapi.core/README.md b/tgbotapi.core/README.md index baac76ec7f..ac3a0a7e9e 100644 --- a/tgbotapi.core/README.md +++ b/tgbotapi.core/README.md @@ -106,7 +106,7 @@ requestsExecutor.execute(GetMe()) ``` Also there is an alternative syntax for requests (like `requestsExecutor.getMe()` in project -[tgbotapi.extensions.api](../tgbotapi.extensions.api/README.md)) +[tgbotapi.api](../tgbotapi.api/README.md)) The result type of [GetMe (and getMe extension)](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/tgbotapi.core/src/commonMain/kotlin/com/github/insanusmokrassar/tgbotapi/requests/GetMe.kt) request is diff --git a/tgbotapi.utils/README.md b/tgbotapi.utils/README.md index d611fd6336..80a302df3b 100644 --- a/tgbotapi.utils/README.md +++ b/tgbotapi.utils/README.md @@ -1,24 +1,6 @@ # TelegramBotAPI Util Extensions -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.utils/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.extensions.utils) - -- [TelegramBotAPI Util Extensions](#telegrambotapi-util-extensions) - * [What is it?](#what-is-it) - * [How to implement library?](#how-to-implement-library) - + [Maven](#maven) - + [Gradle](#gradle) - * [How to use?](#how-to-use) - + [Updates](#updates) - - [Long polling](#long-polling) - - [WebHooks (currently JVM-only)](#webhooks-currently-jvm-only) - + [Filters](#filters) - - [Sent messages](#sent-messages) - * [Common messages](#common-messages) - * [Chat actions](#chat-actions) - + [Shortcuts](#shortcuts) - - [ScheduledCloseInfo](#scheduledcloseinfo) - -Table of contents generated with markdown-toc +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.utils/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.utils) ## What is it? @@ -28,10 +10,9 @@ It is wrapper library for [TelegramBotAPI Core](../tgbotapi.core/README.md). Cur Common ways to implement this library are presented here. In some cases it will require additional steps like inserting of additional libraries (like `kotlin stdlib`). In the examples will be used variable -`telegrambotapi-extensions-utils_version`, which must be set up by developer. Available versions are presented on -[bintray](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.utils), next version is last published: +`telegrambotapi-extensions-utils_version`, which must be set up by developer. Next version is last published: -[![Download](https://api.bintray.com/packages/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.utils/images/download.svg) ](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.extensions.utils/_latestVersion) +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.utils/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.utils) ### Maven @@ -40,7 +21,7 @@ Dependency config presented here: ```xml dev.inmo - tgbotapi.extensions.utils + tgbotapi.utils ${telegrambotapi-extensions-utils_version} ``` @@ -54,13 +35,13 @@ To use last versions you will need to add one line in repositories block of your And add next line to your dependencies block: ```groovy -implementation "dev.inmo:tgbotapi.extensions.utils:$telegrambotapi-extensions-utils_version" +implementation "dev.inmo:tgbotapi.utils:$telegrambotapi-extensions-utils_version" ``` or for old gradle: ```groovy -compile "dev.inmo:tgbotapi.extensions.utils:$telegrambotapi-extensions-utils_version" +compile "dev.inmo:tgbotapi.utils:$telegrambotapi-extensions-utils_version" ``` ## How to use? diff --git a/tgbotapi/README.md b/tgbotapi/README.md index f28a163a68..52be8d83b5 100644 --- a/tgbotapi/README.md +++ b/tgbotapi/README.md @@ -3,9 +3,10 @@ Concentration of all TelegramBotAPI libraries: * [TelegramBotAPI Core](../tgbotapi.core/README.md) -* [TelegramBotAPI Extensions](../tgbotapi.extensions.api/README.md) -* [TelegramBotAPI Util Extensions](../tgbotapi.extensions.utils/README.md) -* [TelegramBotAPI Behaviour Builder Extensions](../tgbotapi.extensions.behaviour_builder/README.md) +* [TelegramBotAPI Extensions](../tgbotapi.api/README.md) +* [TelegramBotAPI Util Extensions](../tgbotapi.utils/README.md) +* [TelegramBotAPI Behaviour Builder Extensions](../tgbotapi.behaviour_builder/README.md) +* [TelegramBotAPI Behaviour Builder FSM Extensions](../tgbotapi.behaviour_builder.fsm/README.md) ## Implementation From 15386a63f9bda7a53df534199f70af514c08d325 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 18 Oct 2021 15:38:42 +0600 Subject: [PATCH 38/40] small fix --- tgbotapi/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tgbotapi/README.md b/tgbotapi/README.md index 52be8d83b5..ce86e27e09 100644 --- a/tgbotapi/README.md +++ b/tgbotapi/README.md @@ -3,10 +3,11 @@ Concentration of all TelegramBotAPI libraries: * [TelegramBotAPI Core](../tgbotapi.core/README.md) -* [TelegramBotAPI Extensions](../tgbotapi.api/README.md) -* [TelegramBotAPI Util Extensions](../tgbotapi.utils/README.md) -* [TelegramBotAPI Behaviour Builder Extensions](../tgbotapi.behaviour_builder/README.md) -* [TelegramBotAPI Behaviour Builder FSM Extensions](../tgbotapi.behaviour_builder.fsm/README.md) +* Extensions: + * [TelegramBotAPI API](../tgbotapi.api/README.md) + * [TelegramBotAPI Utils](../tgbotapi.utils/README.md) + * [TelegramBotAPI Behaviour Builder](../tgbotapi.behaviour_builder/README.md) + * [TelegramBotAPI Behaviour Builder FSM](../tgbotapi.behaviour_builder.fsm/README.md) ## Implementation From f385101e223b4cd017b1f5384597ff9712a96f1a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 18 Oct 2021 15:48:24 +0600 Subject: [PATCH 39/40] deprecate several behaviour builder methods --- .../behaviour_builder/TelegramBotWithFSM.kt | 8 +++---- .../behaviour_builder/BehaviourBuilders.kt | 10 ++++++++- .../behaviour_builder/TelegramBot.kt | 21 +++++++++++++------ 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt index 23ead91b93..e7ef4fd5b3 100644 --- a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt +++ b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt @@ -22,10 +22,10 @@ import kotlin.coroutines.coroutineContext * **WARNING** This method WILL NOT launch any listening of updates. Use something like * [startGettingOfUpdatesByLongPolling] or tools for work with webhooks * - * @return Created bot which has been used to create [BehaviourContext] via [buildBehaviour] + * @return Created bot which has been used to create [BehaviourContext] via [buildBehaviourWithFSM] * * @see [BehaviourContext] - * @see [buildBehaviour] + * @see [buildBehaviourWithFSM] * @see startGettingOfUpdatesByLongPolling */ suspend fun telegramBotWithBehaviourAndFSM( @@ -60,8 +60,8 @@ suspend fun telegramBotWithBehaviourAndFSM( * @return Pair of [TelegramBot] and [Job]. This [Job] can be used to stop listening updates in your [block] you passed * here * - * @see [BehaviourContext] - * @see [buildBehaviour] + * @see BehaviourContext + * @see buildBehaviourWithFSMAndStartLongPolling * @see startGettingOfUpdatesByLongPolling */ suspend fun telegramBotWithBehaviourAndFSMAndStartLongPolling( diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt index 00e0a527d4..e6111623bd 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt @@ -54,7 +54,7 @@ suspend fun TelegramBot.buildBehaviour( * @see startGettingOfUpdatesByLongPolling */ @PreviewFeature -suspend fun TelegramBot.buildBehaviour( +suspend fun TelegramBot.buildBehaviourWithLongPolling( scope: CoroutineScope = defaultCoroutineScopeProvider(), defaultExceptionsHandler: ExceptionHandler? = null, block: BehaviourContextReceiver @@ -70,3 +70,11 @@ suspend fun TelegramBot.buildBehaviour( scope = scope ) } + +@PreviewFeature +@Deprecated("Renamed to buildBehaviourWithLongPolling") +suspend fun TelegramBot.buildBehaviour( + scope: CoroutineScope = defaultCoroutineScopeProvider(), + defaultExceptionsHandler: ExceptionHandler? = null, + block: BehaviourContextReceiver +) = buildBehaviourWithLongPolling(scope, defaultExceptionsHandler, block) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt index 613c923146..b0ab06183d 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBot.kt @@ -45,20 +45,19 @@ suspend fun telegramBotWithBehaviour( } /** - * Create bot using [telegramBot] and start listening for updates using [buildBehaviour]. + * Create bot using [telegramBot] and start listening for updates using [buildBehaviourWithLongPolling]. * Use this method in case you wish to make some additional actions with [flowsUpdatesFilter]. * - * **WARNING** This method WILL NOT launch any listening of updates. Use something like - * [startGettingOfUpdatesByLongPolling] or tools for work with webhooks + * **WARNING** This method WILL launch updates listening inside of calling [buildBehaviourWithLongPolling] * * @return Pair of [TelegramBot] and [Job]. This [Job] can be used to stop listening updates in your [block] you passed * here * * @see [BehaviourContext] - * @see [buildBehaviour] + * @see buildBehaviourWithLongPolling * @see startGettingOfUpdatesByLongPolling */ -suspend fun telegramBotWithBehaviour( +suspend fun telegramBotWithBehaviourAndLongPolling( token: String, scope: CoroutineScope? = null, apiUrl: String = telegramBotAPIDefaultUrl, @@ -71,10 +70,20 @@ suspend fun telegramBotWithBehaviour( apiUrl, builder ).let { - it to it.buildBehaviour( + it to it.buildBehaviourWithLongPolling( scope ?: CoroutineScope(coroutineContext), defaultExceptionsHandler, block ) } } + +@Deprecated("Renamed to telegramBotWithBehaviourAndLongPolling") +suspend fun telegramBotWithBehaviour( + token: String, + scope: CoroutineScope? = null, + apiUrl: String = telegramBotAPIDefaultUrl, + builder: KtorRequestsExecutorBuilder.() -> Unit = {}, + defaultExceptionsHandler: ExceptionHandler? = null, + block: BehaviourContextReceiver +) = telegramBotWithBehaviourAndLongPolling(token, scope, apiUrl, builder, defaultExceptionsHandler, block) From ad8710db92bfbf7cf677c83190327f39189226d5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 18 Oct 2021 16:43:37 +0600 Subject: [PATCH 40/40] add telegraph note --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba8b7b23e9..1328679833 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,7 +43,7 @@ * `waitChosenInlineResult`/`onChosenInlineResult` * `waitPollUpdates`/`onPollUpdates` * `Behaviour Builder FSM extension`: - * Has been created :) + * See [Difference between old Behaviour Builder and new one with FSM](https://telegra.ph/Difference-between-old-Behaviour-Builder-and-new-one-with-FSM-10-18) ## 0.35.9