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.apiExtensions project for make requests more look like in the Telegram Bot API and give opportunity to use it's easiertgbotapi.extensions.api...tgbotapi.coreRoot project with API. It is not recommended to use its requests directly and better to use at least tgbotapi.extensions.apitgbotapi.core...tgbotapi.extensions.utilsExtensions project with utils things which will make easier different operationstgbotapi.extensions.utils...tgbotapi.extensions.behaviour_builderExtension project for building bot behaviour via special DSLtgbotapi.extensions.behaviour_builder...tgbotapiHere included all available TelegramBotAPI libraries:tgbotapi.coretgbotapi.extensions.apitgbotapi.extensions.utilstgbotapi.extensions.behaviour_buildertgbotapi...Viewer does not support full SVG 1.1 +tgbotapi.apiExtensions project for make requests more look like in the Telegram Bot API and give opportunity to use it's easiertgbotapi.api...tgbotapi.coreRoot project with API. It is not recommended to use its requests directly and better to use at least tgbotapi.extensions.apitgbotapi.core...tgbotapi.utilsExtensions project with utils things which will make easier different operationstgbotapi.utils...tgbotapi.behaviour_builderExtension project for building bot behaviour via special DSLtgbotapi.behaviour_builder...tgbotapiHere included all available TelegramBotAPI libraries:tgbotapi.coretgbotapi.apitgbotapi.utilstgbotapi.behaviour_buildertgbotapi.behaviour_builder.fsmtgbotapi...tgbotapi.behaviour_builder.fsmExtension project for building bot behaviour via special DSLtgbotapi.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
Extensions project for make requests more look like in the Telegram Bot API and give opportunity to use it's easier
Root project with API. It is not recommended to use its requests directly and better to use at least tgbotapi.extensions.api
Extensions project with utils things which will make easier different operations
Extension project for building bot behaviour via special DSL
Here included all available TelegramBotAPI libraries: