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/.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: 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 4a19c868f7..1328679833 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,50 @@ # TelegramBotAPI changelog +## 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`: + * `Serialization`: `1.2.2` -> `1.3.0` + * `MicroUtils`: `0.5.28` -> `0.7.2` + * `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 + * `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`. `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` + * `replyKeyboard` for creating `ReplyKeyboardMarkup` + * 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` + * `waitPreCheckoutQueries`/`onPreCheckoutQuery` + * `waitChosenInlineResult`/`onChosenInlineResult` + * `waitPollUpdates`/`onPollUpdates` +* `Behaviour Builder FSM extension`: + * 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 * `Common`: diff --git a/README.md b/README.md index 1a4669ec73..acefa84cc1 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,12 @@ 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) | -| 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/TelegramBotAPI.drawio b/TelegramBotAPI.drawio index 0bc0fa2013..ffc54b5fb8 100644 --- a/TelegramBotAPI.drawio +++ b/TelegramBotAPI.drawio @@ -1 +1 @@ - \ 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/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/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 diff --git a/gradle.properties b/gradle.properties index fdb5b4b8bc..cb7b61b406 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,16 +7,16 @@ 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 +kotlin_serialisation_runtime_version=1.3.0 +klock_version=2.4.6 uuid_version=0.3.1 -ktor_version=1.6.3 +ktor_version=1.6.4 -micro_utils_version=0.5.28 +micro_utils_version=0.7.2 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 diff --git a/resources/TelegramBotAPI-libraries-hierarchy.svg b/resources/TelegramBotAPI-libraries-hierarchy.svg index 774ed45810..703af70e98 100644 --- a/resources/TelegramBotAPI-libraries-hierarchy.svg +++ b/resources/TelegramBotAPI-libraries-hierarchy.svg @@ -1 +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...
Viewer does not support full SVG 1.1
+

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 33e593255e..f33377257e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,13 +8,17 @@ pluginManagement { } repositories { gradlePluginPortal() - jcenter() } } 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" +include ":tgbotapi.extensions.behaviour_builder.fsm" include ":tgbotapi" include ":docs" diff --git a/tgbotapi.extensions.api/README.md b/tgbotapi.api/README.md similarity index 66% rename from tgbotapi.extensions.api/README.md rename to tgbotapi.api/README.md index bbe8b0bc77..52441ed4f4 100644 --- a/tgbotapi.extensions.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} ``` @@ -49,18 +36,18 @@ 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: ```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.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 82% 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 index 659f38da0a..2a063c8e46 100644 --- 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 @@ -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/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 63% 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 index 7c535c5233..c7e2106767 100644 --- 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 @@ -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/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 51% 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 index 0f165b759a..b53fe39ac6 100644 --- 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 @@ -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/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.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 new file mode 100644 index 0000000000..dc8a069e78 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatMember.kt @@ -0,0 +1,34 @@ +package dev.inmo.tgbotapi.extensions.api.chat.members + +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.chat.members.BanChatMember +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat + +suspend fun TelegramBot.banChatMember( + chatId: ChatIdentifier, + userId: UserId, + untilDate: TelegramDate? = null, + revokeMessages: Boolean? = null +) = execute(BanChatMember(chatId, userId, untilDate, revokeMessages)) + +suspend fun TelegramBot.banChatMember( + chat: PublicChat, + userId: UserId, + untilDate: TelegramDate? = null, + revokeMessages: Boolean? = null +) = banChatMember(chat.id, userId, untilDate, revokeMessages) + +suspend fun TelegramBot.banChatMember( + chatId: ChatId, + user: User, + untilDate: TelegramDate? = null, + revokeMessages: Boolean? = null +) = banChatMember(chatId, user.id, untilDate, revokeMessages) + +suspend fun TelegramBot.banChatMember( + chat: PublicChat, + user: User, + untilDate: TelegramDate? = null, + revokeMessages: Boolean? = null +) = banChatMember(chat.id, user.id, untilDate, revokeMessages) 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 75% 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 index 2548f015a2..e1fd361138 100644 --- 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 @@ -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/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 71% 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 index 5a8d2ead28..14865a4a4e 100644 --- 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 @@ -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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/LiveLocation/StopInlineMessageLiveLocation.kt similarity index 77% 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 index cdba949683..14aa6c3934 100644 --- 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 @@ -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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditChatMessageReplyMarkup.kt similarity index 69% 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 index 3a8d089fa5..b65d15f8c1 100644 --- 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 @@ -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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/ReplyMarkup/EditInlineMessageReplyMarkup.kt similarity index 76% 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 index 123c168522..f00c1133e3 100644 --- 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 @@ -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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditChatMessageCaption.kt similarity index 73% 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 index 4ed6b395f0..09cf7b3839 100644 --- 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 @@ -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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/caption/EditInlineMessageCaption.kt similarity index 75% 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 index 1ee2224a42..8f0f89b2a6 100644 --- 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 @@ -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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditChatMessageMedia.kt similarity index 73% 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 index 58c19261c7..b927dc0ef9 100644 --- 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 @@ -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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/media/EditInlineMessageMedia.kt similarity index 78% 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 index 31128eb6a7..dec47763cc 100644 --- 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 @@ -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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditChatMessageText.kt similarity index 73% 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 index fa94728a9e..8ca8ef5c06 100644 --- 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 @@ -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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/edit/text/EditInlineMessageText.kt similarity index 77% 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 index 1293e4a3fa..1411e2cf87 100644 --- 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 @@ -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/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 94% 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 index f601f643c9..f2c35a6d95 100644 --- 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 @@ -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/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 70% 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 index c7f2281461..d616675575 100644 --- 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 @@ -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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt similarity index 92% 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 index fb0e8e0ad0..306c2ad1aa 100644 --- 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 @@ -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/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 97% 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 index 024abedfff..d4ebb42816 100644 --- 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 @@ -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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendContact.kt similarity index 68% 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 index 85fb7693db..fc73848a31 100644 --- 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 @@ -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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendDice.kt similarity index 72% 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 index 9cac916e02..78622249bb 100644 --- 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 @@ -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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendLocation.kt similarity index 64% 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 index 12990c8031..b28da8d0c2 100644 --- 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 @@ -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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendMessage.kt similarity index 70% 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 index 9b1bcf899d..0ec10e0eee 100644 --- 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 @@ -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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/SendVenue.kt similarity index 79% 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 index 6cfcbe6cf8..b56153d786 100644 --- 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 @@ -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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/games/SendGame.kt similarity index 57% 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 index 5dd0fa73d0..beec35e4ed 100644 --- 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 @@ -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, @@ -56,39 +69,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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAnimation.kt similarity index 58% 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 index 67a3d7ba79..0d14ad66b9 100644 --- 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 @@ -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, @@ -159,128 +188,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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendAudio.kt similarity index 60% 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 index e3846e02f4..646870807f 100644 --- 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 @@ -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, @@ -147,97 +176,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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendDocument.kt similarity index 58% 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 index bd3ce148e5..13d3e25a54 100644 --- 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 @@ -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, @@ -138,93 +167,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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendMediaGroup.kt similarity index 60% 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 index 7bc3706479..abc11f38bb 100644 --- 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 @@ -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 @@ -127,60 +122,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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendPhoto.kt similarity index 59% 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 index 6b562f5c0e..6ae7bc6d46 100644 --- 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 @@ -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, @@ -120,86 +149,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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendSticker.kt similarity index 58% 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 index 08b00f0704..1a06fbc617 100644 --- 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 @@ -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, @@ -49,40 +62,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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideo.kt similarity index 60% 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 index b4b29b3292..4460af5284 100644 --- 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 @@ -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, @@ -146,93 +175,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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVideoNote.kt similarity index 60% 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 index 211d8b3427..5a9a734f1a 100644 --- 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 @@ -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,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.VideoNoteFile -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.sendVideoNote( chatId: ChatIdentifier, videoNote: InputFile, @@ -36,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, @@ -47,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, @@ -59,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, @@ -67,43 +80,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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/media/SendVoice.kt similarity index 59% 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 index 697c2d181c..5f32941240 100644 --- 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 @@ -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, @@ -129,88 +158,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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/payments/SendInvoice.kt similarity index 67% 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 index 9aaabef97d..f97ecffa50 100644 --- 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 @@ -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, @@ -60,32 +66,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.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/polls/SendPoll.kt similarity index 67% 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 index 96db4a23d0..b499b88f5b 100644 --- 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 @@ -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, @@ -227,114 +273,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.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.behaviour_builder.fsm/README.md b/tgbotapi.behaviour_builder.fsm/README.md new file mode 100644 index 0000000000..5bdfd2ef2c --- /dev/null +++ b/tgbotapi.behaviour_builder.fsm/README.md @@ -0,0 +1,8 @@ +# TelegramBotAPI Behaviour Builder FSM Extensions + +[![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.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.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.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 new file mode 100644 index 0000000000..69e4529dbb --- /dev/null +++ b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt @@ -0,0 +1,113 @@ +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 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) + + 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) + } +} + +/** + * 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, + 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.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 new file mode 100644 index 0000000000..a7e41bad85 --- /dev/null +++ b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSMBuilder.kt @@ -0,0 +1,204 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder + +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 +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 dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter +import dev.inmo.tgbotapi.utils.PreviewFeature +import kotlinx.coroutines.* +import kotlinx.coroutines.flow.Flow +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)) + } + + + /** + * 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] + */ + internal fun build() = resultBehaviourContext +} + +/** + * 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. + * + * !!! 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(), + defaultExceptionsHandler: ExceptionHandler? = null, + statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), + presetHandlers: MutableList> = mutableListOf(), + block: CustomBehaviourContextReceiver +): 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) + } +} + +/** + * 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 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 BehaviourContextWithFSMBuilder.strictlyOn + * @see BehaviourContextWithFSMBuilder.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( + DefaultBehaviourContext( + this, + defaultExceptionsHandler ?.let { scope + ContextSafelyExceptionHandler(it) } ?: scope, + upstreamUpdatesFlow = flowUpdatesFilter.allUpdatesFlow + ), + 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 + * + * @see buildBehaviourWithFSMAndStartLongPolling + * @see BehaviourContext + * @see longPolling + * @see BehaviourContextWithFSMBuilder.strictlyOn + * @see BehaviourContextWithFSMBuilder.onStateOrSubstate + */ +@PreviewFeature +suspend fun TelegramBot.buildBehaviourWithFSMAndStartLongPolling( + scope: CoroutineScope = defaultCoroutineScopeProvider(), + defaultExceptionsHandler: ExceptionHandler? = null, + statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), + presetHandlers: MutableList> = mutableListOf(), + block: CustomBehaviourContextReceiver +) = FlowsUpdatesFilter().let { + buildBehaviourWithFSM( + it, + scope, + defaultExceptionsHandler, + statesManager, + presetHandlers, + block + ).run { + start() + longPolling( + flowsUpdatesFilter, + scope = scope + ) + } +} diff --git a/tgbotapi.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 new file mode 100644 index 0000000000..c2e1b6f32f --- /dev/null +++ b/tgbotapi.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.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 new file mode 100644 index 0000000000..00a8d4a82a --- /dev/null +++ b/tgbotapi.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.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 new file mode 100644 index 0000000000..e7ef4fd5b3 --- /dev/null +++ b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/TelegramBotWithFSM.kt @@ -0,0 +1,90 @@ +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 [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 + * [startGettingOfUpdatesByLongPolling] or tools for work with webhooks + * + * @return Created bot which has been used to create [BehaviourContext] via [buildBehaviourWithFSM] + * + * @see [BehaviourContext] + * @see [buildBehaviourWithFSM] + * @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: CustomBehaviourContextReceiver +): TelegramBot = telegramBot( + token, + apiUrl, + builder +).apply { + buildBehaviourWithFSMAndStartLongPolling( + flowsUpdatesFilter.allUpdatesFlow, + scope ?: CoroutineScope(coroutineContext), + defaultExceptionsHandler, + statesManager, + presetHandlers, + block + ) +} + +/** + * 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 + * + * @see BehaviourContext + * @see buildBehaviourWithFSMAndStartLongPolling + * @see startGettingOfUpdatesByLongPolling + */ +suspend fun telegramBotWithBehaviourAndFSMAndStartLongPolling( + token: String, + scope: CoroutineScope? = null, + apiUrl: String = telegramBotAPIDefaultUrl, + builder: KtorRequestsExecutorBuilder.() -> Unit = {}, + defaultExceptionsHandler: ExceptionHandler? = null, + statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), + presetHandlers: MutableList> = mutableListOf(), + block: CustomBehaviourContextReceiver +): Pair { + return telegramBot( + token, + apiUrl, + builder + ).let { + it to it.buildBehaviourWithFSMAndStartLongPolling ( + scope ?: CoroutineScope(coroutineContext), + defaultExceptionsHandler, + statesManager, + presetHandlers, + block + ) + } +} diff --git a/tgbotapi.extensions.behaviour_builder/README.md b/tgbotapi.behaviour_builder/README.md similarity index 85% rename from tgbotapi.extensions.behaviour_builder/README.md rename to tgbotapi.behaviour_builder/README.md index d4160d7c6b..a1ffe177d3 100644 --- a/tgbotapi.extensions.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.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 75% 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 index 6ec5c5a862..e6111623bd 100644 --- 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 @@ -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]. * @@ -84,14 +54,14 @@ suspend fun TelegramBot.buildBehaviour( * @see startGettingOfUpdatesByLongPolling */ @PreviewFeature -suspend fun TelegramBot.buildBehaviour( +suspend fun TelegramBot.buildBehaviourWithLongPolling( scope: CoroutineScope = defaultCoroutineScopeProvider(), defaultExceptionsHandler: ExceptionHandler? = null, block: BehaviourContextReceiver ) = FlowsUpdatesFilter().let { buildBehaviour( - scope, it, + scope, defaultExceptionsHandler, block ) @@ -100,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/BehaviourContext.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt new file mode 100644 index 0000000000..0b62483ba6 --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt @@ -0,0 +1,176 @@ +@file:Suppress("NOTHING_TO_INLINE") + +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.* +import dev.inmo.tgbotapi.utils.RiskFeature +import kotlinx.coroutines.* +import kotlinx.coroutines.channels.BufferOverflow +import kotlinx.coroutines.flow.* + +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 CustomBehaviourContextAndTwoTypesReceiver.toOneType( + i1: I1, +): CustomBehaviourContextAndTypeReceiver = { invoke(this, i1, it) } + +/** + * This class contains all necessary tools for work with bots and especially for [buildBehaviour] + * + * @see DefaultBehaviourContext + */ +interface BehaviourContext : FlowsUpdatesFilter, TelegramBot, CoroutineScope { + val bot: TelegramBot + get() = this + + /** + * Will be used for creating of some subscriptions inside of methods, updates listening and different other things + * in context of working with [CoroutineScope] and coroutines. + */ + val scope: CoroutineScope + get() = this + + /** + * This parameter will be used to subscribe on different types of update + */ + val flowsUpdatesFilter: FlowsUpdatesFilter + get() = this + + fun copy( + bot: TelegramBot = this.bot, + scope: CoroutineScope = this.scope, + 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, + 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 { + + 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, + 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, 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 + * [CoroutineScope] as new [BehaviourContext.scope]. You must do all subscription/running of longPolling manually. + * + * @param newFlowsUpdatesFilterSetUp As a parameter receives [FlowsUpdatesFilter] from old [this] [BehaviourContext.flowsUpdatesFilter] + */ +@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.") +@Deprecated("This method is useless and will not be used in future") +suspend fun BC.doInSubContextWithFlowsUpdatesFilterSetup( + newFlowsUpdatesFilterSetUp: CustomBehaviourContextAndTypeReceiver?, + stopOnCompletion: Boolean = true, + behaviourContextReceiver: CustomBehaviourContextReceiver +): T = (copy( + scope = LinkedSupervisorScope(), +) as BC).run { + withContext(coroutineContext) { + newFlowsUpdatesFilterSetUp ?.let { + it.apply { invoke(this@run, this@doInSubContextWithFlowsUpdatesFilterSetup.flowsUpdatesFilter) } + } + behaviourContextReceiver().also { if (stopOnCompletion) stop() } + } +} + +/** + * Creates new one [BehaviourContext], adding subsequent [FlowsUpdatesFilter] in case [updatesFilter] is provided and + * [CoroutineScope] as new [BehaviourContext.scope] + */ +suspend fun BC.doInSubContextWithUpdatesFilter( + updatesFilter: CustomBehaviourContextAndTypeReceiver?, + stopOnCompletion: Boolean = true, + updatesUpstreamFlow: Flow = allUpdatesFlow, + scope: CoroutineScope = LinkedSupervisorScope(), + behaviourContextReceiver: CustomBehaviourContextReceiver +): T = copy( + scope = scope, + updatesFilter = updatesFilter ?.let { _ -> + { + (this as? BC) ?.run { + updatesFilter(it) + } ?: true + } + }, + upstreamUpdatesFlow = updatesUpstreamFlow +).run { + withContext(coroutineContext) { + behaviourContextReceiver().also { if (stopOnCompletion) stop() } + } +} + +suspend fun BehaviourContext.doInSubContext( + stopOnCompletion: Boolean = true, + updatesUpstreamFlow: Flow = allUpdatesFlow, + scope: CoroutineScope = LinkedSupervisorScope(), + behaviourContextReceiver: BehaviourContextReceiver +) = doInSubContextWithUpdatesFilter(updatesFilter = null, stopOnCompletion, updatesUpstreamFlow, scope, behaviourContextReceiver) + +/** + * This method will cancel ALL subsequent contexts, expectations and waiters + */ +fun BehaviourContext.stop() = scope.cancel() 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 78% 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 index eb62df598a..b0ab06183d 100644 --- 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 @@ -37,28 +37,27 @@ suspend fun telegramBotWithBehaviour( builder ).apply { buildBehaviour( - scope ?: CoroutineScope(coroutineContext), flowsUpdatesFilter, + scope ?: CoroutineScope(coroutineContext), defaultExceptionsHandler, block ) } /** - * 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) 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 97% 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 index 822785234a..c5f1364cbf 100644 --- 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 @@ -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/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.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 new file mode 100644 index 0000000000..3b277f24f6 --- /dev/null +++ b/tgbotapi.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/WaitContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt similarity index 97% 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 index d7abb32cee..b93449737e 100644 --- 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 @@ -14,7 +14,9 @@ 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 +import kotlin.reflect.KClass typealias CommonMessageToContentMapper = suspend CommonMessage.() -> T? @@ -25,7 +27,7 @@ private suspend fun BehaviourContext.waitCommonMessage( errorFactory: NullableRequestBuilder<*> = { null }, filter: SimpleFilter>? = null, mapper: suspend CommonMessage.() -> O? -): List = expectFlow( +): Flow = expectFlow( initRequest, count, errorFactory @@ -49,23 +51,21 @@ private suspend fun BehaviourContext.waitCommonMessage( null } } -}.toList().toList() +} 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, @@ -85,7 +85,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/expectations/WaitEditedContent.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEditedContent.kt similarity index 99% 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 index e00e832c0d..8489961012 100644 --- 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 @@ -119,6 +119,7 @@ suspend fun BehaviourContext.waitEditedStaticLocation( filter: SimpleFilter>? = null, mapper: CommonMessageToContentMapper? = null ) = waitEditedContent(count, initRequest, false, errorFactory, filter, mapper) +@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/WaitEventAction.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt similarity index 89% 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 index c0f7d534be..81672cc796 100644 --- 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 @@ -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.waitPublicChatEvents( + 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/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.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 new file mode 100644 index 0000000000..718bdd4c89 --- /dev/null +++ b/tgbotapi.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.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 new file mode 100644 index 0000000000..0aebcb4acd --- /dev/null +++ b/tgbotapi.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.waitPollUpdates( + 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.waitQuizPollUpdates( + 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.waitRegularPollUpdates( + 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.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 new file mode 100644 index 0000000000..d2c8cf9612 --- /dev/null +++ b/tgbotapi.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.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 new file mode 100644 index 0000000000..3ec4382a00 --- /dev/null +++ b/tgbotapi.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.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChat.kt similarity index 74% 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 index 67c2a187d3..370db3c006 100644 --- 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 @@ -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/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 59% 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 index 4de838699d..9e7bdce543 100644 --- 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 @@ -11,124 +11,15 @@ 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) } -@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, @@ -141,11 +32,11 @@ suspend fun BehaviourContext.onUnknownCallbackQueryType( * @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, @@ -165,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, @@ -189,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, @@ -213,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, @@ -237,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, @@ -261,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, @@ -285,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, @@ -309,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, @@ -333,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.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ChatMemberUpdatedTriggers.kt similarity index 60% 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 index f6dfb202fe..9f8cfa7193 100644 --- 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 @@ -13,54 +13,15 @@ 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) } -@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 @@ -74,12 +35,12 @@ suspend fun BehaviourContext.onMyChatMemberUpdated( * @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, @@ -98,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, @@ -122,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.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 new file mode 100644 index 0000000000..c2689cec06 --- /dev/null +++ b/tgbotapi.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 BC.onChosenInlineResultBase( + noinline initialFilter: SimpleFilter? = null, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByUserIdChosenInlineResultMarkerFactory, + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = 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 BC.onChosenInlineResult( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByUserIdChosenInlineResultMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = 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 BC.onLocationChosenInlineResult( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByUserIdChosenInlineResultMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = 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 BC.onBaseChosenInlineResult( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByUserIdChosenInlineResultMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = onChosenInlineResultBase( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) diff --git a/tgbotapi.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 new file mode 100644 index 0000000000..ad04efa0f2 --- /dev/null +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt @@ -0,0 +1,121 @@ +@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.filters.CommonMessageFilterExcludeMediaGroups +import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByChat +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMessageMarkerFactory +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory +import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times +import dev.inmo.tgbotapi.extensions.utils.asBotCommandTextSource +import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams +import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage +import dev.inmo.tgbotapi.types.message.content.TextContent +import dev.inmo.tgbotapi.types.update.abstracts.Update +import kotlinx.coroutines.Job + + +suspend fun BC.command( + commandRegex: Regex, + requireOnlyCommandInMessage: Boolean = true, + initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +): Job = onText( + 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) + } + }.let { + initialFilter ?.times(it) ?: it + }, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) + +suspend fun BC.command( + command: String, + requireOnlyCommandInMessage: Boolean = true, + initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = command(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) + +suspend inline fun BC.onCommand( + commandRegex: Regex, + requireOnlyCommandInMessage: Boolean = true, + noinline initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +): Job = command(commandRegex, requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) + +suspend inline fun BC.onCommand( + command: String, + requireOnlyCommandInMessage: Boolean = true, + noinline initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +): Job = onCommand(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) + +suspend fun BC.commandWithArgs( + commandRegex: Regex, + initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver, Array> +) = command( + commandRegex, + requireOnlyCommandInMessage = false, + initialFilter = initialFilter, + subcontextUpdatesFilter = subcontextUpdatesFilter, + 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) +} + +suspend fun BC.commandWithArgs( + command: String, + initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver, Array> +) = commandWithArgs( + command.toRegex(), + initialFilter = initialFilter, + subcontextUpdatesFilter = subcontextUpdatesFilter, + markerFactory = markerFactory, + scenarioReceiver = scenarioReceiver +) + +suspend inline fun BC.onCommandWithArgs( + commandRegex: Regex, + noinline initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + noinline scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver, Array> +): Job = commandWithArgs(commandRegex, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) + +suspend inline fun BC.onCommandWithArgs( + command: String, + noinline initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + 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.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt similarity index 61% 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 index 246eaccdc6..21a867bc4b 100644 --- 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 @@ -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) @@ -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 @@ -311,11 +50,11 @@ suspend fun BehaviourContext.onInvoice( * @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, @@ -335,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, @@ -359,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, @@ -383,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, @@ -407,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, @@ -431,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, @@ -455,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, @@ -479,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, @@ -503,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, @@ -527,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, @@ -551,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, @@ -575,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, @@ -599,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, @@ -623,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, @@ -647,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, @@ -671,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, @@ -695,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, @@ -719,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, @@ -743,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, @@ -767,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, @@ -791,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, @@ -815,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, @@ -839,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.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EditedContentTriggers.kt similarity index 80% 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 index c5ebda5b65..a78aa2ca76 100644 --- 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 @@ -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, @@ -166,23 +166,12 @@ 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 - */ -suspend fun BehaviourContext.onEditedPoll( +@Deprecated("Potentially, this trigger will never be used. Use `onPollUpdated` instead") +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, @@ -202,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, @@ -226,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, @@ -250,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, @@ -274,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, @@ -298,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, @@ -322,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, @@ -346,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, @@ -370,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, @@ -394,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, @@ -418,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, @@ -442,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, @@ -466,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, @@ -490,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, @@ -514,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, @@ -538,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.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt similarity index 60% 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 index b8fd04acc3..4fe6b2c3a3 100644 --- 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 @@ -13,161 +13,18 @@ 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( +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) } -@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, @@ -180,11 +37,11 @@ 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.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) /** @@ -199,11 +56,30 @@ 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.onChatEvent( +suspend fun BC.onPrivateEvent( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = 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 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) /** @@ -218,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) /** @@ -237,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) /** @@ -256,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) /** @@ -275,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) /** @@ -294,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) /** @@ -313,11 +189,30 @@ 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.onCommonEvent( +suspend fun BC.onPublicChatEvent( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver> +) = 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 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) /** @@ -332,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) /** @@ -351,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) /** @@ -370,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) /** @@ -389,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) /** @@ -408,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) /** @@ -427,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) /** @@ -446,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) /** @@ -465,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) /** @@ -484,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) /** @@ -503,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) /** @@ -522,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) /** @@ -541,9 +436,31 @@ 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) + +/** + * 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 + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onSuccessfulPayment( + initialFilter: SimpleFilter>? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver, Update>? = MessageFilterByChat, + markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, + 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.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/InlineQueryTriggers.kt similarity index 63% 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 index 52567eab55..fec661e30e 100644 --- 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 @@ -9,42 +9,15 @@ 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) } - -@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, @@ -57,11 +30,11 @@ suspend fun BehaviourContext.onLocationInlineQuery( * @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) @@ -77,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) @@ -97,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.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/MainTrigger.kt similarity index 65% 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 index 8556adc051..6618479bec 100644 --- 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 @@ -1,20 +1,17 @@ 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 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 -> @@ -24,9 +21,12 @@ internal suspend inline fun BehaviourContext.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) } 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 60% 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 index f402d97c0a..a308ecf3c0 100644 --- 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 @@ -16,67 +16,15 @@ 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) } -@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, @@ -89,11 +37,11 @@ suspend fun BehaviourContext.onVideoGallery( * @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) /** @@ -108,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) /** @@ -127,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) /** @@ -146,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) /** @@ -165,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) /** @@ -184,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) /** @@ -203,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.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/PassportTriggers.kt similarity index 66% 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 index 31de2cd1ba..e85c8bfe47 100644 --- 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 @@ -11,28 +11,15 @@ 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) } -@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 @@ -46,12 +33,12 @@ suspend fun BehaviourContext.onPassportMessage( * @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.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 new file mode 100644 index 0000000000..15ebf39209 --- /dev/null +++ b/tgbotapi.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 BC.onPollAnswered( + noinline initialFilter: SimpleFilter? = null, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByIdPollAnswerMarkerFactory, + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = 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 BC.onPollAnswer( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByIdPollAnswerMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = onPollAnswered( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) diff --git a/tgbotapi.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 new file mode 100644 index 0000000000..92d0d652fa --- /dev/null +++ b/tgbotapi.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 BC.onPollUpdatedBase( + noinline initialFilter: SimpleFilter? = null, + noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByIdPollMarkerFactory, + noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = 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 BC.onPollUpdates( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByIdPollMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = onPollUpdatedBase( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) + +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onRegularPollUpdates( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByIdPollMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = onPollUpdatedBase( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) + +/** + * @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call + * @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example, + * this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage]. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own. + * Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times] + * to combinate several filters + * @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously + * in one "stream". Output of [markerFactory] will be used as a key for "stream" + * @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that + * data + */ +suspend fun BC.onQuizPollUpdates( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = null, + markerFactory: MarkerFactory = ByIdPollMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = onPollUpdatedBase( + initialFilter, + subcontextUpdatesFilter, + markerFactory, + scenarioReceiver +) diff --git a/tgbotapi.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 new file mode 100644 index 0000000000..bcd7b220c5 --- /dev/null +++ b/tgbotapi.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 BC.onPreCheckoutQuery( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = PreCheckoutQueryFilterByUser, + markerFactory: MarkerFactory = ByUserPreCheckoutQueryMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) { + (it.asPreCheckoutQueryUpdate() ?.data) ?.let(::listOfNotNull) +} diff --git a/tgbotapi.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 new file mode 100644 index 0000000000..4fcbeab37e --- /dev/null +++ b/tgbotapi.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 BC.onShippingQuery( + initialFilter: SimpleFilter? = null, + subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver? = ShippingQueryFilterByUser, + markerFactory: MarkerFactory = ByUserShippingQueryMarkerFactory, + scenarioReceiver: CustomBehaviourContextAndTypeReceiver +) = 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/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.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 new file mode 100644 index 0000000000..f96c321ee7 --- /dev/null +++ b/tgbotapi.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/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.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 new file mode 100644 index 0000000000..d9ada9782d --- /dev/null +++ b/tgbotapi.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.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.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.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 } 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 4f888a0d23..ac3a0a7e9e 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 @@ -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: @@ -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.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 { 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/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/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/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/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/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/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/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/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/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/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/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/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/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.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/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/types/message/ChatEvents/DeleteChatPhoto.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/DeleteChatPhoto.kt index db88fc3dac..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.CommonEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent -class DeleteChatPhoto: CommonEvent +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 22a9def5f3..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.CommonEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent data class LeftChatMember( - val user: User -) : CommonEvent + override val user: User +) : PublicChatEvent, WithUser 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..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.CommonEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent data class NewChatPhoto( val photo: Photo -): CommonEvent +): 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 3b1eaf6533..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.CommonEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent data class NewChatTitle( val title: String -): CommonEvent +): 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 e502522020..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.CommonEvent +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 -) : CommonEvent +) : 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 feb9af40ff..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 : ChannelEvent, GroupEvent, SupergroupEvent \ No newline at end of file +interface CommonEvent : PublicChatEvent, PrivateEvent 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/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 289fc5daac..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 : CommonEvent +interface VoiceChatEvent : PublicChatEvent 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/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..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 @@ -7,11 +7,11 @@ 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, - override val user: User, + override val from: User, override val chat: Chat, override val content: T, override val date: DateTime, @@ -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.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.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/updateshandlers/FlowsUpdatesFilter.kt index a926a0c719..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 { @@ -32,61 +33,36 @@ 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 +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() } } /** @@ -94,17 +70,26 @@ interface FlowsUpdatesFilter : UpdatesFilter { */ @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) { @@ -114,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.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.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/build.gradle b/tgbotapi.extensions.api/build.gradle index 8dcc226dda..2e59abfe91 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 { @@ -39,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.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.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 627f75ec8b..0000000000 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/DownloadFile.kt +++ /dev/null @@ -1,33 +0,0 @@ -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 - -@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/members/BanChatMember.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatMember.kt deleted file mode 100644 index 6cf936caa6..0000000000 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/BanChatMember.kt +++ /dev/null @@ -1,66 +0,0 @@ -package dev.inmo.tgbotapi.extensions.api.chat.members - -import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.requests.chat.members.BanChatMember -import dev.inmo.tgbotapi.types.* -import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat - -suspend fun TelegramBot.banChatMember( - chatId: ChatIdentifier, - userId: UserId, - untilDate: TelegramDate? = null, - revokeMessages: Boolean? = null -) = execute(BanChatMember(chatId, userId, untilDate, revokeMessages)) - -suspend fun TelegramBot.banChatMember( - chat: PublicChat, - userId: UserId, - untilDate: TelegramDate? = null, - revokeMessages: Boolean? = null -) = banChatMember(chat.id, userId, untilDate, revokeMessages) - -suspend fun TelegramBot.banChatMember( - chatId: ChatId, - user: User, - untilDate: TelegramDate? = null, - revokeMessages: Boolean? = null -) = banChatMember(chatId, user.id, untilDate, revokeMessages) - -suspend fun TelegramBot.banChatMember( - chat: PublicChat, - user: User, - 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.behaviour_builder.fsm/build.gradle b/tgbotapi.extensions.behaviour_builder.fsm/build.gradle new file mode 100644 index 0000000000..70bda66a94 --- /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.behaviour_builder.fsm") + } + } + } +} + +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..eebed183f7 --- /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 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 new file mode 100644 index 0000000000..80c48eb3ff --- /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 = "${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" + 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/build.gradle b/tgbotapi.extensions.behaviour_builder/build.gradle index fe275f7938..4536301cf5 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 { @@ -39,7 +36,7 @@ kotlin { commonMain { dependencies { implementation kotlin('stdlib') - api project(":tgbotapi.extensions.utils") + api project(":tgbotapi.behaviour_builder") } } } @@ -50,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..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 = "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 = "${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.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 deleted file mode 100644 index 2fb4504b79..0000000000 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt +++ /dev/null @@ -1,128 +0,0 @@ -@file:Suppress("NOTHING_TO_INLINE") - -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.utils.RiskFeature -import kotlinx.coroutines.* -import kotlinx.coroutines.flow.filter - -typealias BehaviourContextReceiver = suspend BehaviourContext.() -> T -typealias BehaviourContextAndTypeReceiver = suspend BehaviourContext.(I) -> T -typealias BehaviourContextAndTwoTypesReceiver = suspend BehaviourContext.(I1, I2) -> T -inline fun BehaviourContextReceiver(noinline block: BehaviourContextReceiver) = block -inline fun BehaviourContextAndTypeReceiver(noinline block: BehaviourContextAndTypeReceiver) = block -inline fun BehaviourContextAndTwoTypesReceiver(noinline block: BehaviourContextAndTwoTypesReceiver) = block -internal inline fun BehaviourContextAndTwoTypesReceiver.toOneType( - i1: I1, -): BehaviourContextAndTypeReceiver = { invoke(this, i1, it) } - -/** - * This class contains all necessary tools for work with bots and especially for [buildBehaviour] - * - * @see DefaultBehaviourContext - */ -interface BehaviourContext : FlowsUpdatesFilter, TelegramBot, CoroutineScope { - val bot: TelegramBot - get() = this - - /** - * Will be used for creating of some subscriptions inside of methods, updates listening and different other things - * in context of working with [CoroutineScope] and coroutines. - */ - val scope: CoroutineScope - get() = this - - /** - * This parameter will be used to subscribe on different types of update - */ - val flowsUpdatesFilter: FlowsUpdatesFilter - get() = this - - fun copy( - bot: TelegramBot = this.bot, - scope: CoroutineScope = this.scope, - flowsUpdatesFilter: FlowsUpdatesFilter = this.flowsUpdatesFilter - ): BehaviourContext -} - -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 { - override fun copy( - bot: TelegramBot, - scope: CoroutineScope, - flowsUpdatesFilter: FlowsUpdatesFilter - ): DefaultBehaviourContext = DefaultBehaviourContext(bot, scope, flowsUpdatesFilter) -} - -fun BehaviourContext( - bot: TelegramBot, - scope: CoroutineScope, - flowsUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter() -) = DefaultBehaviourContext(bot, scope, flowsUpdatesFilter) - -/** - * Creates new one [BehaviourContext], adding subsequent [FlowsUpdatesFilter] in case [newFlowsUpdatesFilterSetUp] is provided and - * [CoroutineScope] as new [BehaviourContext.scope]. You must do all subscription/running of longPolling manually. - * - * @param newFlowsUpdatesFilterSetUp As a parameter receives [FlowsUpdatesFilter] from old [this] [BehaviourContext.flowsUpdatesFilter] - */ -@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?, - stopOnCompletion: Boolean = true, - behaviourContextReceiver: BehaviourContextReceiver -): T { - return copy( - flowsUpdatesFilter = FlowsUpdatesFilter(), - scope = LinkedSupervisorScope() - ).run { - newFlowsUpdatesFilterSetUp ?.let { - it.apply { invoke(this@run, this@doInSubContextWithFlowsUpdatesFilterSetup.flowsUpdatesFilter) } - } - withContext(coroutineContext) { - behaviourContextReceiver().also { if (stopOnCompletion) stop() } - } - } -} - -/** - * Creates new one [BehaviourContext], adding subsequent [FlowsUpdatesFilter] in case [updatesFilter] is provided and - * [CoroutineScope] as new [BehaviourContext.scope] - */ -suspend fun BehaviourContext.doInSubContextWithUpdatesFilter( - updatesFilter: BehaviourContextAndTypeReceiver?, - stopOnCompletion: Boolean = true, - behaviourContextReceiver: BehaviourContextReceiver -): T = doInSubContextWithFlowsUpdatesFilterSetup( - newFlowsUpdatesFilterSetUp = updatesFilter ?.let { - { oldOne -> - weakLaunch { - oldOne.allUpdatesFlow.filter { updatesFilter(it) }.subscribeSafelyWithoutExceptions(this, block = asUpdateReceiver) - } - } - } ?: { oldOne -> - weakLaunch { - oldOne.allUpdatesFlow.subscribeSafelyWithoutExceptions(this, block = asUpdateReceiver) - } - }, - stopOnCompletion, - behaviourContextReceiver -) - -suspend fun BehaviourContext.doInSubContext( - stopOnCompletion: Boolean = true, - behaviourContextReceiver: BehaviourContextReceiver -) = doInSubContextWithUpdatesFilter(updatesFilter = null, stopOnCompletion, behaviourContextReceiver) - -/** - * This method will cancel ALL subsequent contexts, expectations and waiters - */ -fun BehaviourContext.stop() = scope.cancel() 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 deleted file mode 100644 index 6fc9e8317a..0000000000 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/CommandHandling.kt +++ /dev/null @@ -1,233 +0,0 @@ -@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.filters.CommonMessageFilterExcludeMediaGroups -import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByChat -import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMessageMarkerFactory -import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory -import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times -import dev.inmo.tgbotapi.extensions.utils.asBotCommandTextSource -import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams -import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage -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, - requireOnlyCommandInMessage: Boolean = true, - initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -): Job = onText( - 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) - } - }.let { - initialFilter ?.times(it) ?: it - }, - subcontextUpdatesFilter, - markerFactory, - scenarioReceiver -) - -suspend fun BehaviourContext.command( - command: String, - requireOnlyCommandInMessage: Boolean = true, - initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTypeReceiver> -) = command(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) - -suspend inline fun BehaviourContext.onCommand( - commandRegex: Regex, - requireOnlyCommandInMessage: Boolean = true, - noinline initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTypeReceiver> -): Job = command(commandRegex, requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) - -suspend inline fun BehaviourContext.onCommand( - command: String, - requireOnlyCommandInMessage: Boolean = true, - noinline initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTypeReceiver> -): Job = onCommand(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) - -suspend fun BehaviourContext.commandWithArgs( - commandRegex: Regex, - initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTwoTypesReceiver, Array> -) = command( - commandRegex, - requireOnlyCommandInMessage = false, - initialFilter = initialFilter, - subcontextUpdatesFilter = subcontextUpdatesFilter, - 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) -} - -suspend fun BehaviourContext.commandWithArgs( - command: String, - initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - scenarioReceiver: BehaviourContextAndTwoTypesReceiver, Array> -) = commandWithArgs( - command.toRegex(), - initialFilter = initialFilter, - subcontextUpdatesFilter = subcontextUpdatesFilter, - markerFactory = markerFactory, - scenarioReceiver = scenarioReceiver -) - -suspend inline fun BehaviourContext.onCommandWithArgs( - commandRegex: Regex, - noinline initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTwoTypesReceiver, Array> -): Job = commandWithArgs(commandRegex, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) - -suspend inline fun BehaviourContext.onCommandWithArgs( - command: String, - noinline initialFilter: CommonMessageFilter? = CommonMessageFilterExcludeMediaGroups, - noinline subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver, Update> = MessageFilterByChat, - markerFactory: MarkerFactory, Any> = ByChatMessageMarkerFactory, - noinline scenarioReceiver: BehaviourContextAndTwoTypesReceiver, Array> -): Job = onCommandWithArgs(command.toRegex(), initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) diff --git a/tgbotapi.extensions.utils/build.gradle b/tgbotapi.extensions.utils/build.gradle index 07aac2026e..ad0a0d7910 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 { @@ -39,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") } } } @@ -68,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..7fccf82acc 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 = "${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" 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 deleted file mode 100644 index 168c4ca798..0000000000 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/FlowsUpdatesFilter.kt +++ /dev/null @@ -1,21 +0,0 @@ -package dev.inmo.tgbotapi.extensions.utils.extensions - -import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate -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 deleted file mode 100644 index e0cfe38006..0000000000 --- a/tgbotapi.extensions.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt +++ /dev/null @@ -1,30 +0,0 @@ -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 -): 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() } diff --git a/tgbotapi.extensions.utils/README.md b/tgbotapi.utils/README.md similarity index 85% rename from tgbotapi.extensions.utils/README.md rename to tgbotapi.utils/README.md index 3fef81edfe..80a302df3b 100644 --- a/tgbotapi.extensions.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} ``` @@ -49,18 +30,18 @@ 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: ```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.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 98% 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 index 5813d6b84a..ae3d35a63c 100644 --- 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 @@ -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.* @@ -1092,6 +1091,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) @@ -1123,6 +1131,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) @@ -2314,10 +2331,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 @@ -3033,6 +3050,15 @@ inline fun ChatEvent.asChannelEvent(): ChannelEvent? = this as? ChannelEvent @PreviewFeature inline fun ChatEvent.requireChannelEvent(): ChannelEvent = this as ChannelEvent +@PreviewFeature +inline fun ChatEvent.whenPublicChatEvent(block: (PublicChatEvent) -> T) = asPublicChatEvent() ?.let(block) + +@PreviewFeature +inline fun ChatEvent.asPublicChatEvent(): PublicChatEvent? = this as? PublicChatEvent + +@PreviewFeature +inline fun ChatEvent.requirePublicChatEvent(): PublicChatEvent = this as PublicChatEvent + @PreviewFeature inline fun ChatEvent.whenCommonEvent(block: (CommonEvent) -> T) = asCommonEvent() ?.let(block) @@ -3127,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/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.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 new file mode 100644 index 0000000000..202785be46 --- /dev/null +++ b/tgbotapi.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/extensions/FlowsUpdatesFilter.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.extensions.utils.extensions + +import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate +import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate +import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.merge 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 56% 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 index a1f341c16b..9507f7052b 100644 --- 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 @@ -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() +} 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 78% 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 index e51288d803..6746cb2e15 100644 --- 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 @@ -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() 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.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 new file mode 100644 index 0000000000..1d348269b8 --- /dev/null +++ b/tgbotapi.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/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.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 new file mode 100644 index 0000000000..f359d0e5ee --- /dev/null +++ b/tgbotapi.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)) 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.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt b/tgbotapi.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt new file mode 100644 index 0000000000..cffc04184f --- /dev/null +++ b/tgbotapi.utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt @@ -0,0 +1,9 @@ +package dev.inmo.tgbotapi.types.files + +import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper +import java.io.* +import java.net.URL + +fun PathedFile.asStream( + telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper +): InputStream = URL(this.fullUrl(telegramAPIUrlsKeeper)).openStream() diff --git a/tgbotapi/README.md b/tgbotapi/README.md index f28a163a68..ce86e27e09 100644 --- a/tgbotapi/README.md +++ b/tgbotapi/README.md @@ -3,9 +3,11 @@ 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) +* 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 diff --git a/tgbotapi/build.gradle b/tgbotapi/build.gradle index fda252a629..5cd816bf7b 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 { @@ -40,9 +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.api") + api project(":tgbotapi.utils") + api project(":tgbotapi.behaviour_builder") + api project(":tgbotapi.behaviour_builder.fsm") } } }