From 0d9f18f346a4f3a4efebcc6ddbb59c5c26786b58 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 17 Feb 2021 22:29:29 +0600 Subject: [PATCH 01/37] DiceAnimationType class casts --- CHANGELOG.md | 2 ++ .../tgbotapi/extensions/utils/ClassCasts.kt | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab5ff7585e..fe015b81ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ * `Core`: * New variable `LeftRestrictionsChatPermissions` +* `Extensions Utils`: + * `DiceAnimationType` class casts * `Behaviour Builder`: * Now `doInSubContextWithUpdatesFilter` and `doInSubContext` will automatically subscribe on updates of parent `BehaviourContext` diff --git a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt index b4b2716992..5e27c2c544 100644 --- a/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt +++ b/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/ClassCasts.kt @@ -28,6 +28,7 @@ import dev.inmo.tgbotapi.types.buttons.* import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.* import dev.inmo.tgbotapi.types.chat.abstracts.* import dev.inmo.tgbotapi.types.chat.abstracts.extended.* +import dev.inmo.tgbotapi.types.dice.* import dev.inmo.tgbotapi.types.files.* import dev.inmo.tgbotapi.types.files.abstracts.* import dev.inmo.tgbotapi.types.message.* @@ -1216,3 +1217,31 @@ inline fun TextSource.requireURLTextSource(): URLTextSource = this as URLTextSou inline fun TextSource.asUnderlineTextSource(): UnderlineTextSource? = this as? UnderlineTextSource @PreviewFeature inline fun TextSource.requireUnderlineTextSource(): UnderlineTextSource = this as UnderlineTextSource +@PreviewFeature +inline fun DiceAnimationType.asBasketballDiceAnimationType(): BasketballDiceAnimationType? = this as? BasketballDiceAnimationType +@PreviewFeature +inline fun DiceAnimationType.requireBasketballDiceAnimationType(): BasketballDiceAnimationType = this as BasketballDiceAnimationType +@PreviewFeature +inline fun DiceAnimationType.asBowlingDiceAnimationType(): BowlingDiceAnimationType? = this as? BowlingDiceAnimationType +@PreviewFeature +inline fun DiceAnimationType.requireBowlingDiceAnimationType(): BowlingDiceAnimationType = this as BowlingDiceAnimationType +@PreviewFeature +inline fun DiceAnimationType.asCubeDiceAnimationType(): CubeDiceAnimationType? = this as? CubeDiceAnimationType +@PreviewFeature +inline fun DiceAnimationType.requireCubeDiceAnimationType(): CubeDiceAnimationType = this as CubeDiceAnimationType +@PreviewFeature +inline fun DiceAnimationType.asCustomDiceAnimationType(): CustomDiceAnimationType? = this as? CustomDiceAnimationType +@PreviewFeature +inline fun DiceAnimationType.requireCustomDiceAnimationType(): CustomDiceAnimationType = this as CustomDiceAnimationType +@PreviewFeature +inline fun DiceAnimationType.asDartsDiceAnimationType(): DartsDiceAnimationType? = this as? DartsDiceAnimationType +@PreviewFeature +inline fun DiceAnimationType.requireDartsDiceAnimationType(): DartsDiceAnimationType = this as DartsDiceAnimationType +@PreviewFeature +inline fun DiceAnimationType.asFootballDiceAnimationType(): FootballDiceAnimationType? = this as? FootballDiceAnimationType +@PreviewFeature +inline fun DiceAnimationType.requireFootballDiceAnimationType(): FootballDiceAnimationType = this as FootballDiceAnimationType +@PreviewFeature +inline fun DiceAnimationType.asSlotMachineDiceAnimationType(): SlotMachineDiceAnimationType? = this as? SlotMachineDiceAnimationType +@PreviewFeature +inline fun DiceAnimationType.requireSlotMachineDiceAnimationType(): SlotMachineDiceAnimationType = this as SlotMachineDiceAnimationType From 563d78460381afe3e723f877a0e1241d1e9c0a99 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 18 Feb 2021 00:28:36 +0600 Subject: [PATCH 02/37] RestrictionsChatPermissions --- CHANGELOG.md | 2 +- .../dev/inmo/tgbotapi/types/chat/ChatPermissions.kt | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe015b81ff..8c7f009416 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## 0.32.7 * `Core`: - * New variable `LeftRestrictionsChatPermissions` + * New variable `LeftRestrictionsChatPermissions` and `RestrictionsChatPermissions` * `Extensions Utils`: * `DiceAnimationType` class casts * `Behaviour Builder`: diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatPermissions.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatPermissions.kt index bb9a9f4e2d..67091d9bd4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatPermissions.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatPermissions.kt @@ -34,3 +34,14 @@ val LeftRestrictionsChatPermissions = ChatPermissions( canInviteUsers = true, canPinMessages = true, ) + +val RestrictionsChatPermissions = ChatPermissions( + canSendMessages = false, + canSendMediaMessages = false, + canSendPolls = false, + canSendOtherMessages = false, + canAddWebPagePreviews = false, + canChangeInfo = false, + canInviteUsers = false, + canPinMessages = false, +) From 63337b8285ecc2e4952847bbb0c67d9083617007 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 21 Feb 2021 21:13:23 +0600 Subject: [PATCH 03/37] start 0.32.8 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c7f009416..edb3b056c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 0.32.8 + ## 0.32.7 * `Core`: diff --git a/gradle.properties b/gradle.properties index f7cb21ef35..aab19d1221 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,6 +17,6 @@ micro_utils_version=0.4.25 javax_activation_version=1.1.1 library_group=dev.inmo -library_version=0.32.7 +library_version=0.32.8 github_release_plugin_version=2.2.12 From 104653ac41e9ff38bb00df5b07340067b434591e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 21 Feb 2021 21:15:40 +0600 Subject: [PATCH 04/37] update serialization --- CHANGELOG.md | 4 ++++ gradle.properties | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index edb3b056c8..50709a82fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.32.8 +* `Common`: + * `Version`: + * `Serialization`: `1.1.0-RC` -> `1.1.0` + ## 0.32.7 * `Core`: diff --git a/gradle.properties b/gradle.properties index aab19d1221..e3a4df9669 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ kotlin.incremental.js=true kotlin_version=1.4.30 kotlin_coroutines_version=1.4.2 -kotlin_serialisation_runtime_version=1.1.0-RC +kotlin_serialisation_runtime_version=1.1.0 klock_version=2.0.6 uuid_version=0.2.3 ktor_version=1.5.1 From a98d5d9abd04882c9eb26ab4232d230ec6e7dbb4 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 21 Feb 2021 22:50:47 +0600 Subject: [PATCH 05/37] update micro_utils --- CHANGELOG.md | 1 + gradle.properties | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50709a82fe..165721083a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * `Common`: * `Version`: * `Serialization`: `1.1.0-RC` -> `1.1.0` + * `MicroUtils`: `0.4.25` -> `0.4.26` ## 0.32.7 diff --git a/gradle.properties b/gradle.properties index e3a4df9669..c35ef1e510 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ klock_version=2.0.6 uuid_version=0.2.3 ktor_version=1.5.1 -micro_utils_version=0.4.25 +micro_utils_version=0.4.26 javax_activation_version=1.1.1 From 69b5a16b1789d2ca920dfdda5ad2a8de9626d56a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 23 Feb 2021 09:53:45 +0600 Subject: [PATCH 06/37] Update gradle-wrapper.properties --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9fccb7a76d..68ca99ac45 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip From 1efd4dce6e04fd46c7c965e0437c51527ca4b4fe Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 28 Feb 2021 22:21:57 +0600 Subject: [PATCH 07/37] start 0.32.9 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 165721083a..e3617c44ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 0.32.9 + ## 0.32.8 * `Common`: diff --git a/gradle.properties b/gradle.properties index c35ef1e510..4ecf6b821f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,6 +17,6 @@ micro_utils_version=0.4.26 javax_activation_version=1.1.1 library_group=dev.inmo -library_version=0.32.8 +library_version=0.32.9 github_release_plugin_version=2.2.12 From fc2f177e38928b367596f78183b258c337bfab1a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 28 Feb 2021 22:24:34 +0600 Subject: [PATCH 08/37] update dependencies --- CHANGELOG.md | 6 ++++++ gradle.properties | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3617c44ed..7459b3e77d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## 0.32.9 +* `Common`: + * `Version`: + * `Kotlin`: `1.4.30` -> `1.4.31` + * `Ktor`: `1.5.1` -> `1.5.2` + * `MicroUtils`: `0.4.26` -> `0.4.27` + ## 0.32.8 * `Common`: diff --git a/gradle.properties b/gradle.properties index 4ecf6b821f..4ec54c15f5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,14 +5,14 @@ kotlin.js.generate.externals=true kotlin.incremental=true kotlin.incremental.js=true -kotlin_version=1.4.30 +kotlin_version=1.4.31 kotlin_coroutines_version=1.4.2 kotlin_serialisation_runtime_version=1.1.0 klock_version=2.0.6 uuid_version=0.2.3 -ktor_version=1.5.1 +ktor_version=1.5.2 -micro_utils_version=0.4.26 +micro_utils_version=0.4.27 javax_activation_version=1.1.1 From 1287852334e434858f439a5fd8c914c4c079fada Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 2 Mar 2021 15:26:52 +0600 Subject: [PATCH 09/37] update microutils version --- CHANGELOG.md | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7459b3e77d..16095b6155 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ * `Version`: * `Kotlin`: `1.4.30` -> `1.4.31` * `Ktor`: `1.5.1` -> `1.5.2` - * `MicroUtils`: `0.4.26` -> `0.4.27` + * `MicroUtils`: `0.4.26` -> `0.4.28` ## 0.32.8 diff --git a/gradle.properties b/gradle.properties index 4ec54c15f5..2eec9e9a09 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ klock_version=2.0.6 uuid_version=0.2.3 ktor_version=1.5.2 -micro_utils_version=0.4.27 +micro_utils_version=0.4.28 javax_activation_version=1.1.1 From ff24b9f35bcee8e2d678ea4643ad99b80c0dd625 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 2 Mar 2021 15:54:13 +0600 Subject: [PATCH 10/37] add workflow for packages publication --- .github/workflows/packages_publishing.yml | 24 +++++++++++++++++++ tgbotapi.core/mpp_publish_template.kpsb | 2 +- tgbotapi.core/publish.gradle | 12 ++++------ .../mpp_publish_template.kpsb | 2 +- tgbotapi.extensions.api/publish.gradle | 12 ++++------ .../mpp_publish_template.kpsb | 2 +- .../publish.gradle | 12 ++++------ .../mpp_publish_template.kpsb | 2 +- tgbotapi.extensions.utils/publish.gradle | 12 ++++------ 9 files changed, 44 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/packages_publishing.yml diff --git a/.github/workflows/packages_publishing.yml b/.github/workflows/packages_publishing.yml new file mode 100644 index 0000000000..544406eff7 --- /dev/null +++ b/.github/workflows/packages_publishing.yml @@ -0,0 +1,24 @@ + +name: Publish package to GitHub Packages +on: [push] +jobs: + publishing: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Rewrite version + run: | + branch="`echo "${{ github.ref }}" | grep -o "[^/]*$"`" + 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 and publish + run: ./gradlew clean build publishAllPublicationsToGithubPackagesRepository -x signJsPublication -x signJvmPublication -x signKotlinMultiplatformPublication -x signMetadataPublication + env: + GITHUBPACKAGES_USER: ${{ github.actor }} + GITHUBPACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }} + SONATYPE_USER: "plug" + SONATYPE_PASSWORD: "plug" diff --git a/tgbotapi.core/mpp_publish_template.kpsb b/tgbotapi.core/mpp_publish_template.kpsb index 3ab5711efd..30b9e6fab3 100644 --- a/tgbotapi.core/mpp_publish_template.kpsb +++ b/tgbotapi.core/mpp_publish_template.kpsb @@ -1 +1 @@ -{"bintrayConfig":{"repo":"TelegramBotAPI","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI","autoPublish":true,"overridePublish":true},"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 Core","description":"Library for Object-Oriented and type-safe work with Telegram Bot API","url":"https://insanusmokrassar.github.io/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"publishToMavenCentral":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]}} \ No newline at end of file +{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Core","description":"Library for Object-Oriented and type-safe work with Telegram Bot API","url":"https://insanusmokrassar.github.io/TelegramBotAPI","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.core/publish.gradle b/tgbotapi.core/publish.gradle index 4da193013f..d22ef4a7d7 100644 --- a/tgbotapi.core/publish.gradle +++ b/tgbotapi.core/publish.gradle @@ -38,17 +38,15 @@ publishing { } } - repositories { maven { - name = "bintray" - url = uri("https://api.bintray.com/maven/${project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')}/TelegramBotAPI/${project.name}/;publish=1;override=1") + name = "GithubPackages" + url = uri("https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI") credentials { - username = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') - password = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') + username = project.hasProperty('GITHUBPACKAGE_USER') ? project.property('GITHUBPACKAGE_USER') : System.getenv('GITHUBPACKAGE_USER') + password = project.hasProperty('GITHUBPACKAGE_PASSWORD') ? project.property('GITHUBPACKAGE_PASSWORD') : System.getenv('GITHUBPACKAGE_PASSWORD') } } - maven { name = "sonatype" url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") @@ -57,9 +55,7 @@ publishing { password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD') } } - } - } } diff --git a/tgbotapi.extensions.api/mpp_publish_template.kpsb b/tgbotapi.extensions.api/mpp_publish_template.kpsb index 11162eaf0c..a0b4d37d9d 100644 --- a/tgbotapi.extensions.api/mpp_publish_template.kpsb +++ b/tgbotapi.extensions.api/mpp_publish_template.kpsb @@ -1 +1 @@ -{"bintrayConfig":{"repo":"TelegramBotAPI","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI","autoPublish":true,"overridePublish":true},"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,"publishToMavenCentral":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]}} \ No newline at end of file +{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API 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.extensions.api/publish.gradle b/tgbotapi.extensions.api/publish.gradle index 373e5538f1..f9b84ef8f3 100644 --- a/tgbotapi.extensions.api/publish.gradle +++ b/tgbotapi.extensions.api/publish.gradle @@ -38,17 +38,15 @@ publishing { } } - repositories { maven { - name = "bintray" - url = uri("https://api.bintray.com/maven/${project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')}/TelegramBotAPI/${project.name}/;publish=1;override=1") + name = "GithubPackages" + url = uri("https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI") credentials { - username = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') - password = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') + 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') } } - maven { name = "sonatype" url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") @@ -57,9 +55,7 @@ publishing { password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD') } } - } - } } diff --git a/tgbotapi.extensions.behaviour_builder/mpp_publish_template.kpsb b/tgbotapi.extensions.behaviour_builder/mpp_publish_template.kpsb index b1cec57fa3..21548e829f 100644 --- a/tgbotapi.extensions.behaviour_builder/mpp_publish_template.kpsb +++ b/tgbotapi.extensions.behaviour_builder/mpp_publish_template.kpsb @@ -1 +1 @@ -{"bintrayConfig":{"repo":"TelegramBotAPI","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI","autoPublish":true,"overridePublish":true},"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,"publishToMavenCentral":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]}} \ No newline at end of file +{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API 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.extensions.behaviour_builder/publish.gradle b/tgbotapi.extensions.behaviour_builder/publish.gradle index 0ffbe9a1e4..3950b86841 100644 --- a/tgbotapi.extensions.behaviour_builder/publish.gradle +++ b/tgbotapi.extensions.behaviour_builder/publish.gradle @@ -38,17 +38,15 @@ publishing { } } - repositories { maven { - name = "bintray" - url = uri("https://api.bintray.com/maven/${project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')}/TelegramBotAPI/${project.name}/;publish=1;override=1") + name = "GithubPackages" + url = uri("https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI") credentials { - username = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') - password = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') + 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') } } - maven { name = "sonatype" url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") @@ -57,9 +55,7 @@ publishing { password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD') } } - } - } } diff --git a/tgbotapi.extensions.utils/mpp_publish_template.kpsb b/tgbotapi.extensions.utils/mpp_publish_template.kpsb index 4bca81cb8c..b9cb0896cd 100644 --- a/tgbotapi.extensions.utils/mpp_publish_template.kpsb +++ b/tgbotapi.extensions.utils/mpp_publish_template.kpsb @@ -1 +1 @@ -{"bintrayConfig":{"repo":"TelegramBotAPI","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI","autoPublish":true,"overridePublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Utility Extensions","description":"Util extensions for more useful work with updates and other things","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-utils","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"publishToMavenCentral":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]}} \ No newline at end of file +{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Utility Extensions","description":"Util extensions for more useful work with updates and other things","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-utils","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}]}} \ No newline at end of file diff --git a/tgbotapi.extensions.utils/publish.gradle b/tgbotapi.extensions.utils/publish.gradle index d164628dc6..e5cafcb846 100644 --- a/tgbotapi.extensions.utils/publish.gradle +++ b/tgbotapi.extensions.utils/publish.gradle @@ -38,17 +38,15 @@ publishing { } } - repositories { maven { - name = "bintray" - url = uri("https://api.bintray.com/maven/${project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')}/TelegramBotAPI/${project.name}/;publish=1;override=1") + name = "GithubPackages" + url = uri("https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI") credentials { - username = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') - password = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') + 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') } } - maven { name = "sonatype" url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") @@ -57,9 +55,7 @@ publishing { password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD') } } - } - } } From ffed2b80a5eb8c2a3376f8fbdcf956ade47bd5d1 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 2 Mar 2021 16:45:13 +0600 Subject: [PATCH 11/37] update publish scripts to avoid useless repos --- .github/workflows/packages_publishing.yml | 2 -- tgbotapi.core/publish.gradle | 28 +++++++++++-------- tgbotapi.extensions.api/publish.gradle | 28 +++++++++++-------- .../publish.gradle | 28 +++++++++++-------- tgbotapi.extensions.utils/publish.gradle | 28 +++++++++++-------- tgbotapi/publish.gradle | 19 ------------- 6 files changed, 64 insertions(+), 69 deletions(-) diff --git a/.github/workflows/packages_publishing.yml b/.github/workflows/packages_publishing.yml index 544406eff7..df0458887c 100644 --- a/.github/workflows/packages_publishing.yml +++ b/.github/workflows/packages_publishing.yml @@ -20,5 +20,3 @@ jobs: env: GITHUBPACKAGES_USER: ${{ github.actor }} GITHUBPACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - SONATYPE_USER: "plug" - SONATYPE_PASSWORD: "plug" diff --git a/tgbotapi.core/publish.gradle b/tgbotapi.core/publish.gradle index d22ef4a7d7..b15d7993ab 100644 --- a/tgbotapi.core/publish.gradle +++ b/tgbotapi.core/publish.gradle @@ -39,20 +39,24 @@ publishing { } } repositories { - maven { - name = "GithubPackages" - url = uri("https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI") - credentials { - username = project.hasProperty('GITHUBPACKAGE_USER') ? project.property('GITHUBPACKAGE_USER') : System.getenv('GITHUBPACKAGE_USER') - password = project.hasProperty('GITHUBPACKAGE_PASSWORD') ? project.property('GITHUBPACKAGE_PASSWORD') : System.getenv('GITHUBPACKAGE_PASSWORD') + 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') + } } } - 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') + 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') + } } } } diff --git a/tgbotapi.extensions.api/publish.gradle b/tgbotapi.extensions.api/publish.gradle index f9b84ef8f3..3d4d7407f8 100644 --- a/tgbotapi.extensions.api/publish.gradle +++ b/tgbotapi.extensions.api/publish.gradle @@ -39,20 +39,24 @@ publishing { } } repositories { - 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('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') + } } } - 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') + 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') + } } } } diff --git a/tgbotapi.extensions.behaviour_builder/publish.gradle b/tgbotapi.extensions.behaviour_builder/publish.gradle index 3950b86841..5af61a71f8 100644 --- a/tgbotapi.extensions.behaviour_builder/publish.gradle +++ b/tgbotapi.extensions.behaviour_builder/publish.gradle @@ -39,20 +39,24 @@ publishing { } } repositories { - 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('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') + } } } - 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') + 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') + } } } } diff --git a/tgbotapi.extensions.utils/publish.gradle b/tgbotapi.extensions.utils/publish.gradle index e5cafcb846..8cd9a87e46 100644 --- a/tgbotapi.extensions.utils/publish.gradle +++ b/tgbotapi.extensions.utils/publish.gradle @@ -39,20 +39,24 @@ publishing { } } repositories { - 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('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') + } } } - 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') + 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') + } } } } diff --git a/tgbotapi/publish.gradle b/tgbotapi/publish.gradle index 37804a0141..ff2fa9eb74 100644 --- a/tgbotapi/publish.gradle +++ b/tgbotapi/publish.gradle @@ -38,28 +38,9 @@ publishing { } } - repositories { - maven { - name = "bintray" - url = uri("https://api.bintray.com/maven/${project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')}/TelegramBotAPI/${project.name}/;publish=1;override=1") - credentials { - username = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') - password = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY') - } - } - - 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') - } - } } - } } From a835b1dcbbe5118a05f1a5f4e49211f18e810e1c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 3 Mar 2021 01:33:50 +0600 Subject: [PATCH 12/37] Update mpp_publish_template.kpsb --- tgbotapi/mpp_publish_template.kpsb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgbotapi/mpp_publish_template.kpsb b/tgbotapi/mpp_publish_template.kpsb index e4f257f9fa..dfa43517d9 100644 --- a/tgbotapi/mpp_publish_template.kpsb +++ b/tgbotapi/mpp_publish_template.kpsb @@ -1 +1 @@ -{"bintrayConfig":{"repo":"TelegramBotAPI","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI","autoPublish":true,"overridePublish":true},"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","description":"This project just include all subproject of TelegramBotAPI","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"publishToMavenCentral":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]}} \ No newline at end of file +{"bintrayConfig":{"repo":"TelegramBotAPI","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI","autoPublish":true,"overridePublish":true},"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","description":"This project just include all subproject of TelegramBotAPI","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"publishToMavenCentral":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]}}{"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","description":"This project just include all subproject of TelegramBotAPI","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI","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/"}]}} From a3bff3f24d33498dff81802b91ca5a10994f13a6 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 3 Mar 2021 01:37:38 +0600 Subject: [PATCH 13/37] Update publish.gradle --- tgbotapi/publish.gradle | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tgbotapi/publish.gradle b/tgbotapi/publish.gradle index ff2fa9eb74..9c91d01447 100644 --- a/tgbotapi/publish.gradle +++ b/tgbotapi/publish.gradle @@ -39,7 +39,26 @@ publishing { } } 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') + } + } + } } } } From d184ce7a0f89354311c4b358cdbce7b4c33cc744 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 3 Mar 2021 01:39:18 +0600 Subject: [PATCH 14/37] Update mpp_publish_template.kpsb --- tgbotapi/mpp_publish_template.kpsb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgbotapi/mpp_publish_template.kpsb b/tgbotapi/mpp_publish_template.kpsb index dfa43517d9..d750a5847e 100644 --- a/tgbotapi/mpp_publish_template.kpsb +++ b/tgbotapi/mpp_publish_template.kpsb @@ -1 +1 @@ -{"bintrayConfig":{"repo":"TelegramBotAPI","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI","autoPublish":true,"overridePublish":true},"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","description":"This project just include all subproject of TelegramBotAPI","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"publishToMavenCentral":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]}}{"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","description":"This project just include all subproject of TelegramBotAPI","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","includeGpgSigning":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}]}} +{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API","description":"This project just include all subproject of TelegramBotAPI","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI","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/"}]}} From c5513365c25d14053bc548ed57fe13a20f0e0edd Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 3 Mar 2021 22:31:29 +0600 Subject: [PATCH 15/37] Update gradle.properties --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 2eec9e9a09..07767190a1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ kotlin.incremental=true kotlin.incremental.js=true kotlin_version=1.4.31 -kotlin_coroutines_version=1.4.2 +kotlin_coroutines_version=1.4.3 kotlin_serialisation_runtime_version=1.1.0 klock_version=2.0.6 uuid_version=0.2.3 From c521a5f9a44c2bb88a7acb1153c809145933a1cd Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 3 Mar 2021 22:32:44 +0600 Subject: [PATCH 16/37] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16095b6155..b7c298b0f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * `Kotlin`: `1.4.30` -> `1.4.31` * `Ktor`: `1.5.1` -> `1.5.2` * `MicroUtils`: `0.4.26` -> `0.4.28` + * `Coroutines`: `1.4.2` -> `1.4.3` ## 0.32.8 From 367cfff2cb1ad91a3fdfef8e2f6ba8cab9badcb1 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 16:45:13 +0600 Subject: [PATCH 17/37] start 0.32.10 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7c298b0f2..65581c5194 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # TelegramBotAPI changelog +## 0.32.10 + ## 0.32.9 * `Common`: diff --git a/gradle.properties b/gradle.properties index 07767190a1..ac7f563099 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,6 +17,6 @@ micro_utils_version=0.4.28 javax_activation_version=1.1.1 library_group=dev.inmo -library_version=0.32.9 +library_version=0.32.10 github_release_plugin_version=2.2.12 From baf4c74b6974441e6b5f1805bcec5d2426a73464 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 16:46:08 +0600 Subject: [PATCH 18/37] update micro_utils --- CHANGELOG.md | 4 ++++ gradle.properties | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65581c5194..0b33ac4743 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.32.10 +* `Common`: + * `Version`: + * `MicroUtils`: `0.4.28` -> `0.4.29` + ## 0.32.9 * `Common`: diff --git a/gradle.properties b/gradle.properties index ac7f563099..fa30cc70d3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ klock_version=2.0.6 uuid_version=0.2.3 ktor_version=1.5.2 -micro_utils_version=0.4.28 +micro_utils_version=0.4.29 javax_activation_version=1.1.1 From 61b720c61fc9c847891526106fd52fbf120b509c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 16:54:32 +0600 Subject: [PATCH 19/37] fix of content waiters and expecters --- CHANGELOG.md | 2 ++ .../extensions/behaviour_builder/expectations/WaitContent.kt | 2 +- .../behaviour_builder/triggers_handling/ContentTriggers.kt | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b33ac4743..b96231b661 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ * `Common`: * `Version`: * `MicroUtils`: `0.4.28` -> `0.4.29` +* `Behaviour Builder`: + * Now content triggers and expectaters will wait for channel posts too ## 0.32.9 diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt index fe5cdbf153..67b3746a09 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitContent.kt @@ -31,7 +31,7 @@ private suspend fun BehaviourContext.waitCommonMessage( (it as CommonMessage).mapper() } ?.let { return@expectFlow it } } - it.asMessageUpdate() ?.data ?.asCommonMessage() ?.mapper().let(::listOfNotNull) + it.asBaseSentMessageUpdate() ?.data ?.asCommonMessage() ?.mapper().let(::listOfNotNull) }.toList().toList() private suspend inline fun BehaviourContext.waitContent( diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt index 591686026e..493b58f0ee 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/ContentTriggers.kt @@ -36,7 +36,7 @@ internal suspend inline fun BehaviourContext.onCont return@expectFlow it } } - it.asMessageUpdate() ?.data ?.asCommonMessage() ?.let { message -> + it.asBaseSentMessageUpdate() ?.data ?.asCommonMessage() ?.let { message -> if (message.content is T) { val adaptedMessage = message as CommonMessage if (additionalFilter == null || additionalFilter(adaptedMessage)) adaptedMessage else null From 7639b15dc6c01a2586a3a8d6952cb19282346948 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 19:19:15 +0600 Subject: [PATCH 20/37] voice chats functionality included --- .../chat/members/PromoteChatMember.kt | 4 +++- .../ChatMember/AdministratorChatMemberImpl.kt | 2 ++ .../types/ChatMember/CreatorChatMember.kt | 2 ++ .../abstracts/AdministratorChatMember.kt | 1 + .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 2 ++ .../ChatEvents/abstracts/VoiceChatEvent.kt | 3 +++ .../ChatEvents/voice/VoiceChatEnded.kt | 18 ++++++++++++++ .../voice/VoiceChatParticipantsInvited.kt | 13 ++++++++++ .../ChatEvents/voice/VoiceChatStarted.kt | 7 ++++++ .../inmo/tgbotapi/types/message/RawMessage.kt | 9 +++++++ .../api/chat/members/PromoteChatMember.kt | 24 ++++++++++++------- 11 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatEnded.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatParticipantsInvited.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatStarted.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/PromoteChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/PromoteChatMember.kt index b878b0cd6a..74e17ee623 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/PromoteChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/PromoteChatMember.kt @@ -31,7 +31,9 @@ data class PromoteChatMember( @SerialName(canPinMessagesField) private val canPinMessages: Boolean? = null, @SerialName(canPromoteMembersField) - private val canPromoteMembers: Boolean? = null + private val canPromoteMembers: Boolean? = null, + @SerialName(canManageVoiceChatsField) + private val canManageVoiceChats: Boolean? = null ) : ChatMemberRequest, UntilDate { override fun method(): String = "promoteChatMember" override val resultDeserializer: DeserializationStrategy diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/AdministratorChatMemberImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/AdministratorChatMemberImpl.kt index dd16ba76de..109f9b27cc 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/AdministratorChatMemberImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/AdministratorChatMemberImpl.kt @@ -26,6 +26,8 @@ data class AdministratorChatMemberImpl( override val canPinMessages: Boolean = false, @SerialName(canPromoteMembersField) override val canPromoteMembers: Boolean = false, + @SerialName(canManageVoiceChatsField) + override val canManageVoiceChats: Boolean = false, @SerialName(isAnonymousField) override val isAnonymous: Boolean = false, @SerialName(customTitleField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/CreatorChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/CreatorChatMember.kt index 014ac9c952..a47dafd111 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/CreatorChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/CreatorChatMember.kt @@ -30,6 +30,8 @@ data class CreatorChatMember( override val canPinMessages: Boolean = true @Transient override val canPromoteMembers: Boolean = true + @Transient + override val canManageVoiceChats: Boolean = true @SerialName(statusField) @Required private val type: String = "creator" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt index 7a7c9d0944..db02e9d67c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt @@ -13,6 +13,7 @@ interface AdministratorChatMember : SpecialRightsChatMember { val canRemoveMessages: Boolean val canRestrictMembers: Boolean val canPromoteMembers: Boolean + val canManageVoiceChats: Boolean val isAnonymous: Boolean val customTitle: String? } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 819fb35587..bb9f787337 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -239,6 +239,7 @@ const val canInviteUsersField = "can_invite_users" const val canRestrictMembersField = "can_restrict_members" const val canPinMessagesField = "can_pin_messages" const val canPromoteMembersField = "can_promote_members" +const val canManageVoiceChatsField = "can_manage_voice_chats" const val pngStickerField = "png_sticker" const val tgsStickerField = "tgs_sticker" @@ -331,6 +332,7 @@ const val telegramPaymentChargeIdField = "telegram_payment_charge_id" const val providerPaymentChargeIdField = "provider_payment_charge_id" const val providerTokenField = "provider_token" const val providerDataField = "provider_data" +const val usersField = "users" const val requireNameField = "need_name" const val requirePhoneNumberField = "need_phone_number" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt new file mode 100644 index 0000000000..54bb629cde --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/VoiceChatEvent.kt @@ -0,0 +1,3 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts + +interface VoiceChatEvent : SupergroupEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatEnded.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatEnded.kt new file mode 100644 index 0000000000..3969e603fd --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatEnded.kt @@ -0,0 +1,18 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.voice + +import com.soywiz.klock.TimeSpan +import com.soywiz.klock.seconds +import dev.inmo.tgbotapi.types.Seconds +import dev.inmo.tgbotapi.types.durationField +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VoiceChatEvent +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class VoiceChatEnded( + @SerialName(durationField) + val duration: Seconds +) : VoiceChatEvent { + val timeSpan: TimeSpan + get() = TimeSpan(duration.seconds.milliseconds) +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatParticipantsInvited.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatParticipantsInvited.kt new file mode 100644 index 0000000000..44bddaac29 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatParticipantsInvited.kt @@ -0,0 +1,13 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.voice + +import dev.inmo.tgbotapi.types.User +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VoiceChatEvent +import dev.inmo.tgbotapi.types.usersField +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +class VoiceChatParticipantsInvited( + @SerialName(usersField) + val users: List = emptyList() +) : VoiceChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatStarted.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatStarted.kt new file mode 100644 index 0000000000..9b72796ac1 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatStarted.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents.voice + +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VoiceChatEvent +import kotlinx.serialization.Serializable + +@Serializable +object VoiceChatStarted : VoiceChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt index e10f88de8b..d3b204c2ba 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt @@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.games.RawGame import dev.inmo.tgbotapi.types.location.Location 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.Message import dev.inmo.tgbotapi.types.message.abstracts.UnknownMessageType import dev.inmo.tgbotapi.types.message.content.* @@ -81,6 +82,11 @@ internal data class RawMessage( private val dice: Dice? = null, private val successful_payment: SuccessfulPayment? = null, + // Voice Chat Service Messages + private val voice_chat_started: VoiceChatStarted? = null, + private val voice_chat_ended: VoiceChatEnded? = null, + private val voice_chat_participants_invited: VoiceChatParticipantsInvited? = null, + // login property private val connected_website: String? = null, @@ -172,6 +178,9 @@ internal data class RawMessage( left_chat_member != null -> LeftChatMember(left_chat_member) new_chat_title != null -> NewChatTitle(new_chat_title) new_chat_photo != null -> NewChatPhoto(new_chat_photo.toList()) + voice_chat_started != null -> voice_chat_started + voice_chat_ended != null -> voice_chat_ended + voice_chat_participants_invited != null -> voice_chat_participants_invited delete_chat_photo -> DeleteChatPhoto() group_chat_created -> GroupChatCreated( migrate_to_chat_id diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt index e3f1dc9721..fe05c89a8d 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt @@ -17,7 +17,8 @@ suspend fun TelegramBot.promoteChatMember( canInviteUsers: Boolean? = null, canRestrictMembers: Boolean? = null, canPinMessages: Boolean? = null, - canPromoteMembers: Boolean? = null + canPromoteMembers: Boolean? = null, + canManageVoiceChats: Boolean? = null ) = execute( PromoteChatMember( chatId, @@ -31,7 +32,8 @@ suspend fun TelegramBot.promoteChatMember( canInviteUsers, canRestrictMembers, canPinMessages, - canPromoteMembers + canPromoteMembers, + canManageVoiceChats ) ) @@ -47,7 +49,8 @@ suspend fun TelegramBot.promoteChatMember( canInviteUsers: Boolean? = null, canRestrictMembers: Boolean? = null, canPinMessages: Boolean? = null, - canPromoteMembers: Boolean? = null + canPromoteMembers: Boolean? = null, + canManageVoiceChats: Boolean? ) = promoteChatMember( chat.id, userId, @@ -60,7 +63,8 @@ suspend fun TelegramBot.promoteChatMember( canInviteUsers, canRestrictMembers, canPinMessages, - canPromoteMembers + canPromoteMembers, + canManageVoiceChats ) suspend fun TelegramBot.promoteChatMember( @@ -75,7 +79,8 @@ suspend fun TelegramBot.promoteChatMember( canInviteUsers: Boolean? = null, canRestrictMembers: Boolean? = null, canPinMessages: Boolean? = null, - canPromoteMembers: Boolean? = null + canPromoteMembers: Boolean? = null, + canManageVoiceChats: Boolean? ) = promoteChatMember( chatId, user.id, @@ -88,7 +93,8 @@ suspend fun TelegramBot.promoteChatMember( canInviteUsers, canRestrictMembers, canPinMessages, - canPromoteMembers + canPromoteMembers, + canManageVoiceChats ) suspend fun TelegramBot.promoteChatMember( @@ -103,7 +109,8 @@ suspend fun TelegramBot.promoteChatMember( canInviteUsers: Boolean? = null, canRestrictMembers: Boolean? = null, canPinMessages: Boolean? = null, - canPromoteMembers: Boolean? = null + canPromoteMembers: Boolean? = null, + canManageVoiceChats: Boolean? ) = promoteChatMember( chat.id, user.id, @@ -116,5 +123,6 @@ suspend fun TelegramBot.promoteChatMember( canInviteUsers, canRestrictMembers, canPinMessages, - canPromoteMembers + canPromoteMembers, + canManageVoiceChats ) From 53524abcbb32b14f87897deca296c373ede1a6b2 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 19:26:30 +0600 Subject: [PATCH 21/37] include canManageChat --- .../chat/members/PromoteChatMember.kt | 4 +++- .../ChatMember/AdministratorChatMemberImpl.kt | 2 ++ .../types/ChatMember/CreatorChatMember.kt | 2 ++ .../abstracts/AdministratorChatMember.kt | 1 + .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../api/chat/members/PromoteChatMember.kt | 24 ++++++++++++------- 6 files changed, 25 insertions(+), 9 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/PromoteChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/PromoteChatMember.kt index 74e17ee623..91e18f7381 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/PromoteChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/PromoteChatMember.kt @@ -33,7 +33,9 @@ data class PromoteChatMember( @SerialName(canPromoteMembersField) private val canPromoteMembers: Boolean? = null, @SerialName(canManageVoiceChatsField) - private val canManageVoiceChats: Boolean? = null + private val canManageVoiceChats: Boolean? = null, + @SerialName(canManageChatField) + private val canManageChat: Boolean? = null ) : ChatMemberRequest, UntilDate { override fun method(): String = "promoteChatMember" override val resultDeserializer: DeserializationStrategy diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/AdministratorChatMemberImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/AdministratorChatMemberImpl.kt index 109f9b27cc..b3bfd4cd18 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/AdministratorChatMemberImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/AdministratorChatMemberImpl.kt @@ -28,6 +28,8 @@ data class AdministratorChatMemberImpl( override val canPromoteMembers: Boolean = false, @SerialName(canManageVoiceChatsField) override val canManageVoiceChats: Boolean = false, + @SerialName(canManageChatField) + override val canManageChat: Boolean = false, @SerialName(isAnonymousField) override val isAnonymous: Boolean = false, @SerialName(customTitleField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/CreatorChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/CreatorChatMember.kt index a47dafd111..8344c7bb22 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/CreatorChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/CreatorChatMember.kt @@ -32,6 +32,8 @@ data class CreatorChatMember( override val canPromoteMembers: Boolean = true @Transient override val canManageVoiceChats: Boolean = true + @Transient + override val canManageChat: Boolean = true @SerialName(statusField) @Required private val type: String = "creator" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt index db02e9d67c..ab6e9056f6 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt @@ -14,6 +14,7 @@ interface AdministratorChatMember : SpecialRightsChatMember { val canRestrictMembers: Boolean val canPromoteMembers: Boolean val canManageVoiceChats: Boolean + val canManageChat: Boolean val isAnonymous: Boolean val customTitle: String? } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index bb9f787337..50a9dacdc3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -240,6 +240,7 @@ const val canRestrictMembersField = "can_restrict_members" const val canPinMessagesField = "can_pin_messages" const val canPromoteMembersField = "can_promote_members" const val canManageVoiceChatsField = "can_manage_voice_chats" +const val canManageChatField = "can_manage_chat" const val pngStickerField = "png_sticker" const val tgsStickerField = "tgs_sticker" diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt index fe05c89a8d..865fc0ee80 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/PromoteChatMember.kt @@ -18,7 +18,8 @@ suspend fun TelegramBot.promoteChatMember( canRestrictMembers: Boolean? = null, canPinMessages: Boolean? = null, canPromoteMembers: Boolean? = null, - canManageVoiceChats: Boolean? = null + canManageVoiceChats: Boolean? = null, + canManageChat: Boolean? ) = execute( PromoteChatMember( chatId, @@ -33,7 +34,8 @@ suspend fun TelegramBot.promoteChatMember( canRestrictMembers, canPinMessages, canPromoteMembers, - canManageVoiceChats + canManageVoiceChats, + canManageChat ) ) @@ -50,7 +52,8 @@ suspend fun TelegramBot.promoteChatMember( canRestrictMembers: Boolean? = null, canPinMessages: Boolean? = null, canPromoteMembers: Boolean? = null, - canManageVoiceChats: Boolean? + canManageVoiceChats: Boolean? = null, + canManageChat: Boolean? = null ) = promoteChatMember( chat.id, userId, @@ -64,7 +67,8 @@ suspend fun TelegramBot.promoteChatMember( canRestrictMembers, canPinMessages, canPromoteMembers, - canManageVoiceChats + canManageVoiceChats, + canManageChat ) suspend fun TelegramBot.promoteChatMember( @@ -80,7 +84,8 @@ suspend fun TelegramBot.promoteChatMember( canRestrictMembers: Boolean? = null, canPinMessages: Boolean? = null, canPromoteMembers: Boolean? = null, - canManageVoiceChats: Boolean? + canManageVoiceChats: Boolean? = null, + canManageChat: Boolean? = null ) = promoteChatMember( chatId, user.id, @@ -94,7 +99,8 @@ suspend fun TelegramBot.promoteChatMember( canRestrictMembers, canPinMessages, canPromoteMembers, - canManageVoiceChats + canManageVoiceChats, + canManageChat ) suspend fun TelegramBot.promoteChatMember( @@ -110,7 +116,8 @@ suspend fun TelegramBot.promoteChatMember( canRestrictMembers: Boolean? = null, canPinMessages: Boolean? = null, canPromoteMembers: Boolean? = null, - canManageVoiceChats: Boolean? + canManageVoiceChats: Boolean? = null, + canManageChat: Boolean? = null ) = promoteChatMember( chat.id, user.id, @@ -124,5 +131,6 @@ suspend fun TelegramBot.promoteChatMember( canRestrictMembers, canPinMessages, canPromoteMembers, - canManageVoiceChats + canManageVoiceChats, + canManageChat ) From 9902b00e85804e0cff03ec53672fbfcae6718a8f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 19:33:05 +0600 Subject: [PATCH 22/37] include revokeMessages in kickChatMember --- .../requests/chat/members/KickChatMember.kt | 4 +++- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../api/chat/members/KickChatMember.kt | 20 +++++++++++-------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/KickChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/KickChatMember.kt index 6074de0d79..58d62c3359 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/KickChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/members/KickChatMember.kt @@ -13,7 +13,9 @@ data class KickChatMember( @SerialName(userIdField) override val userId: UserId, @SerialName(untilDateField) - override val untilDate: TelegramDate? = null + override val untilDate: TelegramDate? = null, + @SerialName(revokeMessagesField) + val revokeMessages: Boolean? = null ) : ChatMemberRequest, UntilDate { override fun method(): String = "kickChatMember" override val resultDeserializer: DeserializationStrategy diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 50a9dacdc3..8eaef26cfb 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -162,6 +162,7 @@ const val optionIdsField = "option_ids" const val ipAddressField = "ip_address" const val linkedChatIdField = "linked_chat_id" const val horizontalAccuracyField = "horizontal_accuracy" +const val revokeMessagesField = "revoke_messages" const val requestContactField = "request_contact" const val requestLocationField = "request_location" diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/KickChatMember.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/KickChatMember.kt index 4fb0049d5c..f924443d8b 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/KickChatMember.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/members/KickChatMember.kt @@ -8,23 +8,27 @@ import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat suspend fun TelegramBot.kickChatMember( chatId: ChatIdentifier, userId: UserId, - untilDate: TelegramDate? = null -) = execute(KickChatMember(chatId, userId, untilDate)) + untilDate: TelegramDate? = null, + revokeMessages: Boolean? = null +) = execute(KickChatMember(chatId, userId, untilDate, revokeMessages)) suspend fun TelegramBot.kickChatMember( chat: PublicChat, userId: UserId, - untilDate: TelegramDate? = null -) = kickChatMember(chat.id, userId, untilDate) + untilDate: TelegramDate? = null, + revokeMessages: Boolean? = null +) = kickChatMember(chat.id, userId, untilDate, revokeMessages) suspend fun TelegramBot.kickChatMember( chatId: ChatId, user: User, - untilDate: TelegramDate? = null -) = kickChatMember(chatId, user.id, untilDate) + untilDate: TelegramDate? = null, + revokeMessages: Boolean? = null +) = kickChatMember(chatId, user.id, untilDate, revokeMessages) suspend fun TelegramBot.kickChatMember( chat: PublicChat, user: User, - untilDate: TelegramDate? = null -) = kickChatMember(chat.id, user.id, untilDate) + untilDate: TelegramDate? = null, + revokeMessages: Boolean? = null +) = kickChatMember(chat.id, user.id, untilDate, revokeMessages) From 86e506c33d75dbd3d130921c728ef4e191dd0e23 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 19:45:19 +0600 Subject: [PATCH 23/37] include message_auto_delete_timer_change --- .../ChatEvents/MessageAutoDeleteTimerChanged.kt | 10 ++++++++++ .../dev/inmo/tgbotapi/types/message/RawMessage.kt | 4 ++++ 2 files changed, 14 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt new file mode 100644 index 0000000000..b87f4718bc --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt @@ -0,0 +1,10 @@ +package dev.inmo.tgbotapi.types.message.ChatEvents + +import dev.inmo.tgbotapi.types.Seconds +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent +import kotlinx.serialization.Serializable + +@Serializable +data class MessageAutoDeleteTimerChanged( + val newAutoDeleteTime: Seconds // TODO:: check that it is seconds +) : ChatEvent diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt index d3b204c2ba..2d3ebdc703 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt @@ -87,6 +87,9 @@ internal data class RawMessage( private val voice_chat_ended: VoiceChatEnded? = null, private val voice_chat_participants_invited: VoiceChatParticipantsInvited? = null, + // AutoDelete Message time changed + private val message_auto_delete_timer_changed: MessageAutoDeleteTimerChanged? = null, + // login property private val connected_website: String? = null, @@ -179,6 +182,7 @@ internal data class RawMessage( new_chat_title != null -> NewChatTitle(new_chat_title) new_chat_photo != null -> NewChatPhoto(new_chat_photo.toList()) voice_chat_started != null -> voice_chat_started + message_auto_delete_timer_changed != null -> message_auto_delete_timer_changed voice_chat_ended != null -> voice_chat_ended voice_chat_participants_invited != null -> voice_chat_participants_invited delete_chat_photo -> DeleteChatPhoto() From ded501d9634cd86c8bacd5b289354a95219124ba Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 19:52:46 +0600 Subject: [PATCH 24/37] remove regular build --- .github/workflows/regular-build.yml | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 .github/workflows/regular-build.yml diff --git a/.github/workflows/regular-build.yml b/.github/workflows/regular-build.yml deleted file mode 100644 index ceab9f2734..0000000000 --- a/.github/workflows/regular-build.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Build - -on: [push] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - name: Build with Gradle - run: ./gradlew build From 696822db02b83bef3111c7025013544f6a7fa674 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 20:04:44 +0600 Subject: [PATCH 25/37] add behaviour builder events updates --- .../expectations/WaitEventAction.kt | 34 +++++++++++++++++++ .../triggers_handling/EventTriggers.kt | 26 ++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt index 0093fa5111..e792af6007 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt @@ -8,6 +8,7 @@ import dev.inmo.tgbotapi.extensions.utils.asMessageUpdate import dev.inmo.tgbotapi.requests.abstracts.Request 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 kotlinx.coroutines.flow.toList @@ -63,6 +64,39 @@ suspend fun BehaviourContext.waitChatEvents( count: Int = 1, filter: EventMessageToEventMapper? = null ) = waitEvents(count, initRequest, errorFactory, filter) + +suspend fun BehaviourContext.waitVoiceChatEvents( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: EventMessageToEventMapper? = null +) = waitEvents(count, initRequest, errorFactory, filter) +suspend fun BehaviourContext.waitVoiceChatStartedEvents( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: EventMessageToEventMapper? = null +) = waitEvents(count, initRequest, errorFactory, filter) +suspend fun BehaviourContext.waitVoiceChatEndedEvents( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: EventMessageToEventMapper? = null +) = waitEvents(count, initRequest, errorFactory, filter) +suspend fun BehaviourContext.waitVoiceChatParticipantsInvitedEvents( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: EventMessageToEventMapper? = null +) = waitEvents(count, initRequest, errorFactory, filter) + +suspend fun BehaviourContext.waitMessageAutoDeleteTimerChangedEvents( + initRequest: Request<*>? = null, + errorFactory: NullableRequestBuilder<*> = { null }, + count: Int = 1, + filter: EventMessageToEventMapper? = null +) = waitEvents(count, initRequest, errorFactory, filter) + suspend fun BehaviourContext.waitCommonEvents( initRequest: Request<*>? = null, errorFactory: NullableRequestBuilder<*> = { null }, diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt index d5b9404550..7e7a8b8a27 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt @@ -8,6 +8,7 @@ import dev.inmo.tgbotapi.extensions.utils.* import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat 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 internal suspend inline fun BehaviourContext.onEvent( @@ -43,6 +44,31 @@ suspend fun BehaviourContext.onChatEvent( additionalFilter: (suspend (ChatEventMessage) -> Boolean)? = null, scenarioReceiver: BehaviourContextAndTypeReceiver> ) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver) +suspend fun BehaviourContext.onVoiceChatEvent( + includeFilterByChatInBehaviourSubContext: Boolean = true, + additionalFilter: (suspend (ChatEventMessage) -> Boolean)? = null, + scenarioReceiver: BehaviourContextAndTypeReceiver> +) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver) +suspend fun BehaviourContext.onVoiceChatStartedEvent( + includeFilterByChatInBehaviourSubContext: Boolean = true, + additionalFilter: (suspend (ChatEventMessage) -> Boolean)? = null, + scenarioReceiver: BehaviourContextAndTypeReceiver> +) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver) +suspend fun BehaviourContext.onVoiceChatEndedEvent( + includeFilterByChatInBehaviourSubContext: Boolean = true, + additionalFilter: (suspend (ChatEventMessage) -> Boolean)? = null, + scenarioReceiver: BehaviourContextAndTypeReceiver> +) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver) +suspend fun BehaviourContext.onVoiceChatParticipantsInvitedEvent( + includeFilterByChatInBehaviourSubContext: Boolean = true, + additionalFilter: (suspend (ChatEventMessage) -> Boolean)? = null, + scenarioReceiver: BehaviourContextAndTypeReceiver> +) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver) +suspend fun BehaviourContext.onMessageAutoDeleteTimerChangedEvent( + includeFilterByChatInBehaviourSubContext: Boolean = true, + additionalFilter: (suspend (ChatEventMessage) -> Boolean)? = null, + scenarioReceiver: BehaviourContextAndTypeReceiver> +) = onEvent(includeFilterByChatInBehaviourSubContext, additionalFilter, scenarioReceiver) suspend fun BehaviourContext.onCommonEvent( includeFilterByChatInBehaviourSubContext: Boolean = true, additionalFilter: (suspend (ChatEventMessage) -> Boolean)? = null, From 2a1e6246418388ee233fb58d694e532634d173c5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 20:23:03 +0600 Subject: [PATCH 26/37] VoiceChatParticipantsInvited type now is data class --- .../message/ChatEvents/voice/VoiceChatParticipantsInvited.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatParticipantsInvited.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatParticipantsInvited.kt index 44bddaac29..3df3f3d711 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatParticipantsInvited.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/voice/VoiceChatParticipantsInvited.kt @@ -7,7 +7,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -class VoiceChatParticipantsInvited( +data class VoiceChatParticipantsInvited( @SerialName(usersField) val users: List = emptyList() ) : VoiceChatEvent From 8daadcff95b92ca3efd59d16dc98755e33f2720c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 21:35:53 +0600 Subject: [PATCH 27/37] now MessageAutoDeleteTimerChanged implementing ChannelEvent and GroupEvent --- .../message/ChatEvents/MessageAutoDeleteTimerChanged.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt index b87f4718bc..3efc8f9893 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt @@ -1,10 +1,11 @@ package dev.inmo.tgbotapi.types.message.ChatEvents import dev.inmo.tgbotapi.types.Seconds -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent import kotlinx.serialization.Serializable @Serializable data class MessageAutoDeleteTimerChanged( val newAutoDeleteTime: Seconds // TODO:: check that it is seconds -) : ChatEvent +) : ChannelEvent, GroupEvent From 8bb60bea341384fe90d1b667bcc05c67f2b2a279 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 21:37:25 +0600 Subject: [PATCH 28/37] now MessageAutoDeleteTimerChanged implementing ChannelEvent and GroupEvent --- .../message/ChatEvents/MessageAutoDeleteTimerChanged.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt index 3efc8f9893..e54c53fdd3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt @@ -1,11 +1,10 @@ package dev.inmo.tgbotapi.types.message.ChatEvents import dev.inmo.tgbotapi.types.Seconds -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent -import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent +import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* import kotlinx.serialization.Serializable @Serializable data class MessageAutoDeleteTimerChanged( val newAutoDeleteTime: Seconds // TODO:: check that it is seconds -) : ChannelEvent, GroupEvent +) : ChannelEvent, GroupEvent, SupergroupEvent From bc21a680bc9e0736edfb6776f24e4db4341d0966 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 22:00:17 +0600 Subject: [PATCH 29/37] fixes for MessageAutoDeleteTimerChanged --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../ChatEvents/MessageAutoDeleteTimerChanged.kt | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 8eaef26cfb..ff8adabedd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -163,6 +163,7 @@ const val ipAddressField = "ip_address" const val linkedChatIdField = "linked_chat_id" const val horizontalAccuracyField = "horizontal_accuracy" const val revokeMessagesField = "revoke_messages" +const val messageAutoDeleteTimeField = "message_auto_delete_time" const val requestContactField = "request_contact" const val requestLocationField = "request_location" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt index e54c53fdd3..adbce62869 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt @@ -1,10 +1,23 @@ package dev.inmo.tgbotapi.types.message.ChatEvents +import com.soywiz.klock.hours import dev.inmo.tgbotapi.types.Seconds import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* +import dev.inmo.tgbotapi.types.messageAutoDeleteTimeField +import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable +private val seconds24Hours: Seconds = 60 * 60 * 24 +private val seconds7Days: Seconds = seconds24Hours * 7 + @Serializable data class MessageAutoDeleteTimerChanged( + @SerialName(messageAutoDeleteTimeField) val newAutoDeleteTime: Seconds // TODO:: check that it is seconds ) : ChannelEvent, GroupEvent, SupergroupEvent + +val MessageAutoDeleteTimerChanged.is24Hours + get() = newAutoDeleteTime == seconds24Hours + +val MessageAutoDeleteTimerChanged.is7Days + get() = newAutoDeleteTime == seconds7Days From 838f62aa840c6d60db882a962f7c721d29d16aff Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 22:06:20 +0600 Subject: [PATCH 30/37] shortcuts seconds24Hours and seconds7Days are consts for now --- .../types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt index adbce62869..189b5d56af 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt @@ -7,8 +7,8 @@ import dev.inmo.tgbotapi.types.messageAutoDeleteTimeField import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -private val seconds24Hours: Seconds = 60 * 60 * 24 -private val seconds7Days: Seconds = seconds24Hours * 7 +private const val seconds24Hours: Seconds = 60 * 60 * 24 +private const val seconds7Days: Seconds = seconds24Hours * 7 @Serializable data class MessageAutoDeleteTimerChanged( From 0faca5838c5169ffe933ebc9b6961d7dc687ea21 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 22:14:16 +0600 Subject: [PATCH 31/37] fixes in events builder behaviours --- .../behaviour_builder/expectations/WaitEventAction.kt | 5 ++--- .../behaviour_builder/triggers_handling/EventTriggers.kt | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt index e792af6007..308c5dbd39 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/WaitEventAction.kt @@ -3,8 +3,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext -import dev.inmo.tgbotapi.extensions.utils.asChatEventMessage -import dev.inmo.tgbotapi.extensions.utils.asMessageUpdate +import dev.inmo.tgbotapi.extensions.utils.* import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* @@ -24,7 +23,7 @@ private suspend fun BehaviourContext.waitEventMessages( count, errorFactory ) { - it.asMessageUpdate() ?.data ?.asChatEventMessage() ?.mapper().let(::listOfNotNull) + it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.mapper().let(::listOfNotNull) }.toList().toList() diff --git a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt index 7e7a8b8a27..fdea3f9a0a 100644 --- a/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt +++ b/tgbotapi.extensions.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handling/EventTriggers.kt @@ -16,7 +16,7 @@ internal suspend inline fun BehaviourContext.onEvent( noinline additionalFilter: (suspend (ChatEventMessage) -> Boolean)? = null, noinline scenarioReceiver: BehaviourContextAndTypeReceiver> ) = flowsUpdatesFilter.expectFlow(bot) { - it.asMessageUpdate() ?.data ?.asChatEventMessage() ?.let { message -> + it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.let { message -> if (message.chatEvent is T) { val adaptedMessage = message as ChatEventMessage if (additionalFilter == null || additionalFilter(adaptedMessage)) adaptedMessage else null From 233d893b5a91e02ef734ad63ea4b6002b14152bc Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Mar 2021 22:33:05 +0600 Subject: [PATCH 32/37] add isOff extension for MessageAutoDeleteTimerChanged --- .../types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt index 189b5d56af..fdd7e264d1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/ChatEvents/MessageAutoDeleteTimerChanged.kt @@ -16,6 +16,9 @@ data class MessageAutoDeleteTimerChanged( val newAutoDeleteTime: Seconds // TODO:: check that it is seconds ) : ChannelEvent, GroupEvent, SupergroupEvent +val MessageAutoDeleteTimerChanged.isOff + get() = newAutoDeleteTime == 0 + val MessageAutoDeleteTimerChanged.is24Hours get() = newAutoDeleteTime == seconds24Hours From 40d702a3118264d66165d4140430c837a84c63eb Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 10 Mar 2021 22:46:56 +0600 Subject: [PATCH 33/37] add representations of all chat invite link functionality --- .../chat/abstracts/ChatInviteLinkRequest.kt | 20 +++ .../chat/invite_links/CreateChatInviteLink.kt | 31 ++++ .../chat/invite_links/EditChatInviteLink.kt | 35 +++++ .../chat/invite_links/RevokeChatInviteLink.kt | 20 +++ .../dev/inmo/tgbotapi/types/ChatInviteLink.kt | 133 ++++++++++++++++++ .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 9 ++ 6 files changed, 248 insertions(+) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/abstracts/ChatInviteLinkRequest.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/EditChatInviteLink.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/RevokeChatInviteLink.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/abstracts/ChatInviteLinkRequest.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/abstracts/ChatInviteLinkRequest.kt new file mode 100644 index 0000000000..afbcbd72f8 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/abstracts/ChatInviteLinkRequest.kt @@ -0,0 +1,20 @@ +package dev.inmo.tgbotapi.requests.chat.abstracts + +import com.soywiz.klock.DateTime +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import kotlinx.serialization.DeserializationStrategy + +interface ChatInviteLinkRequest : SimpleRequest { + val chatId: ChatId + + override val resultDeserializer: DeserializationStrategy + get() = BotInviteLink.serializer() +} +interface KnownChatInviteLinkRequest : ChatInviteLinkRequest { + val inviteLink: String +} +interface EditChatInviteLinkRequest : ChatInviteLinkRequest { + val expireDate: DateTime? + val membersLimit: MembersLimit? +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink.kt new file mode 100644 index 0000000000..32ff101b0e --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink.kt @@ -0,0 +1,31 @@ +package dev.inmo.tgbotapi.requests.chat.invite_links + +import com.soywiz.klock.* +import dev.inmo.tgbotapi.requests.chat.abstracts.EditChatInviteLinkRequest +import dev.inmo.tgbotapi.types.* +import kotlinx.serialization.* + +@Serializable +data class CreateChatInviteLink( + @SerialName(chatIdField) + override val chatId: ChatId, + @SerialName(expireDateField) + private val expirationUnixTimeStamp: UnixTimeStamp? = null, + @SerialName(memberLimitField) + override val membersLimit: MembersLimit? = null +) : EditChatInviteLinkRequest { + override val expireDate: DateTime? + get() = expirationUnixTimeStamp ?.seconds ?.let { DateTime(it.milliseconds) } + override val requestSerializer: SerializationStrategy<*> + get() = serializer() + + override fun method(): String = "createChatInviteLink" +} + +fun CreateChatInviteLink( + chatId: ChatId, + expireDate: DateTime, + membersLimit: MembersLimit? = null +): CreateChatInviteLink = CreateChatInviteLink( + chatId, expireDate.unixMillisDouble.milliseconds.seconds.toLong(), membersLimit +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/EditChatInviteLink.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/EditChatInviteLink.kt new file mode 100644 index 0000000000..2e6c7e2bce --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/EditChatInviteLink.kt @@ -0,0 +1,35 @@ +package dev.inmo.tgbotapi.requests.chat.invite_links + +import com.soywiz.klock.* +import dev.inmo.tgbotapi.requests.chat.abstracts.EditChatInviteLinkRequest +import dev.inmo.tgbotapi.requests.chat.abstracts.KnownChatInviteLinkRequest +import dev.inmo.tgbotapi.types.* +import kotlinx.serialization.* + +@Serializable +data class EditChatInviteLink( + @SerialName(chatIdField) + override val chatId: ChatId, + @SerialName(inviteLinkField) + override val inviteLink: String, + @SerialName(expireDateField) + private val expirationUnixTimeStamp: UnixTimeStamp? = null, + @SerialName(memberLimitField) + override val membersLimit: MembersLimit? = null +) : EditChatInviteLinkRequest, KnownChatInviteLinkRequest { + override val expireDate: DateTime? + get() = expirationUnixTimeStamp ?.seconds ?.let { DateTime(it.milliseconds) } + override val requestSerializer: SerializationStrategy<*> + get() = serializer() + + override fun method(): String = "editChatInviteLink" +} + +fun EditChatInviteLink( + chatId: ChatId, + inviteLink: String, + expireDate: DateTime, + membersLimit: MembersLimit? = null +): EditChatInviteLink = EditChatInviteLink( + chatId, inviteLink, expireDate.unixMillisDouble.milliseconds.seconds.toLong(), membersLimit +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/RevokeChatInviteLink.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/RevokeChatInviteLink.kt new file mode 100644 index 0000000000..9d14035c37 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/RevokeChatInviteLink.kt @@ -0,0 +1,20 @@ +package dev.inmo.tgbotapi.requests.chat.invite_links + +import com.soywiz.klock.* +import dev.inmo.tgbotapi.requests.chat.abstracts.EditChatInviteLinkRequest +import dev.inmo.tgbotapi.requests.chat.abstracts.KnownChatInviteLinkRequest +import dev.inmo.tgbotapi.types.* +import kotlinx.serialization.* + +@Serializable +data class RevokeChatInviteLink( + @SerialName(chatIdField) + override val chatId: ChatId, + @SerialName(inviteLinkField) + override val inviteLink: String +) : KnownChatInviteLinkRequest { + override val requestSerializer: SerializationStrategy<*> + get() = serializer() + + override fun method(): String = "revokeChatInviteLink" +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt new file mode 100644 index 0000000000..cba15be9b9 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt @@ -0,0 +1,133 @@ +package dev.inmo.tgbotapi.types + +import com.soywiz.klock.* +import kotlinx.serialization.* +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder +import kotlinx.serialization.json.JsonObject + +@Serializable +private data class RawChatInviteLink( + @SerialName(inviteLinkField) + val inviteLink: String, + @SerialName(creatorField) + val creator: User, + @SerialName(isPrimaryField) + val isPrimary: Boolean, + @SerialName(isRevokedField) + val isRevoked: Boolean, + @SerialName(expireDateField) + val expirationDateTime: UnixTimeStamp? = null, + @SerialName(memberLimitField) + val membersLimit: MembersLimit ?= null +) + +private fun ChatInviteLink.toRawChatInviteLink() = RawChatInviteLink( + inviteLink, + creator, + isPrimary, + isRevoked, + expirationDateTime ?.unixMillis ?.milliseconds ?.seconds ?.toLong(), + membersLimit +) + +@Serializable(ChatInviteLinkSerializer::class) +sealed class ChatInviteLink { + abstract val inviteLink: String + abstract val creator: User + abstract val isPrimary: Boolean + abstract val isRevoked: Boolean + abstract val expirationDateTime: DateTime? + abstract val membersLimit: MembersLimit? +} + +@Serializable +data class BotInviteLink( + @SerialName(inviteLinkField) + override val inviteLink: String, + @SerialName(creatorField) + override val creator: Bot, + @SerialName(isRevokedField) + override val isRevoked: Boolean = false, + @SerialName(expireDateField) + private val expireDate: UnixTimeStamp? = null, + @SerialName(memberLimitField) + override val membersLimit: MembersLimit? = null +) : ChatInviteLink() { + override val isPrimary: Boolean + get() = false + override val expirationDateTime: DateTime? + get() { + return DateTime(expireDate ?.seconds ?.milliseconds ?: return null) + } +} + +@Serializable +data class PrimaryInviteLink( + @SerialName(inviteLinkField) + override val inviteLink: String, + @SerialName(creatorField) + override val creator: User, + @SerialName(isRevokedField) + override val isRevoked: Boolean = false, + @SerialName(expireDateField) + private val expireDate: UnixTimeStamp? = null, + @SerialName(memberLimitField) + override val membersLimit: MembersLimit? = null +) : ChatInviteLink() { + override val isPrimary: Boolean + get() = true + override val expirationDateTime: DateTime? + get() { + return DateTime(expireDate ?.seconds ?.milliseconds ?: return null) + } +} + +@Serializable +data class CommonInviteLink( + @SerialName(inviteLinkField) + override val inviteLink: String, + @SerialName(creatorField) + override val creator: User, + @SerialName(isRevokedField) + override val isRevoked: Boolean = false, + @SerialName(expireDateField) + private val expireDate: UnixTimeStamp? = null, + @SerialName(memberLimitField) + override val membersLimit: MembersLimit? = null +) : ChatInviteLink() { + override val isPrimary: Boolean + get() = false + override val expirationDateTime: DateTime? + get() { + return DateTime(expireDate ?.seconds ?.milliseconds ?: return null) + } +} + +@Serializer(ChatInviteLink::class) +object ChatInviteLinkSerializer : KSerializer { + override val descriptor: SerialDescriptor + get() = RawChatInviteLink.serializer().descriptor + + override fun deserialize(decoder: Decoder): ChatInviteLink { + val deserializedRaw = RawChatInviteLink.serializer().deserialize(decoder) + return deserializedRaw.run { + when { + creator is Bot -> BotInviteLink( + inviteLink, creator, isRevoked, expirationDateTime, membersLimit + ) + deserializedRaw.isPrimary -> PrimaryInviteLink( + inviteLink, creator, isRevoked, expirationDateTime, membersLimit + ) + else -> CommonInviteLink( + inviteLink, creator, isRevoked, expirationDateTime, membersLimit + ) + } + } + } + + override fun serialize(encoder: Encoder, value: ChatInviteLink) { + RawChatInviteLink.serializer().serialize(encoder, value.toRawChatInviteLink()) + } +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index ff8adabedd..74d2f356b0 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -26,10 +26,12 @@ typealias FoursquareId = String typealias FoursquareType = String typealias GooglePlaceId = String typealias GooglePlaceType = String +typealias MembersLimit = Int typealias Seconds = Int typealias MilliSeconds = Long typealias LongSeconds = Long +typealias UnixTimeStamp = LongSeconds typealias Meters = Float typealias Degrees = Int @@ -76,6 +78,8 @@ val explanationLimit = 0 .. 200 val openPeriodPollSecondsLimit = 5 .. 600 +val membersLimit = 1 .. 99999 + // Made as lazy for correct work in K/JS val telegramInlineModeGifPermittedMimeTypes by lazy { listOf( @@ -164,6 +168,10 @@ const val linkedChatIdField = "linked_chat_id" const val horizontalAccuracyField = "horizontal_accuracy" const val revokeMessagesField = "revoke_messages" const val messageAutoDeleteTimeField = "message_auto_delete_time" +const val isPrimaryField = "is_primary" +const val isRevokedField = "is_revoked" +const val expireDateField = "expire_date" +const val memberLimitField = "member_limit" const val requestContactField = "request_contact" const val requestLocationField = "request_location" @@ -296,6 +304,7 @@ const val payField = "pay" const val permissionsField = "permissions" const val typeField = "type" const val valueField = "value" +const val creatorField = "creator" const val pointField = "point" const val xShiftField = "x_shift" From aba62ba930d713d4afca478168c46cec1f3a629c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 11 Mar 2021 16:00:47 +0600 Subject: [PATCH 34/37] chatmember serializers are public --- CHANGELOG.md | 4 +++- .../types/ChatMember/abstracts/AdministratorChatMember.kt | 4 +++- .../inmo/tgbotapi/types/ChatMember/abstracts/ChatMember.kt | 4 +++- .../commonMain/kotlin/dev/inmo/tgbotapi/utils/Annotations.kt | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b96231b661..355c8a83e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,10 @@ * `Common`: * `Version`: * `MicroUtils`: `0.4.28` -> `0.4.29` +* `Core`: + * `AdministratorChatMemberSerializer` and `ChatMemberSerializer` has changed their visibility: they are public for now * `Behaviour Builder`: - * Now content triggers and expectaters will wait for channel posts too + * Now content triggers and expectators will wait for channel posts too ## 0.32.9 diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt index ab6e9056f6..cd05b4e9c9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/AdministratorChatMember.kt @@ -1,5 +1,6 @@ package dev.inmo.tgbotapi.types.ChatMember.abstracts +import dev.inmo.tgbotapi.utils.RiskFeature import kotlinx.serialization.* import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder @@ -20,7 +21,8 @@ interface AdministratorChatMember : SpecialRightsChatMember { } @Serializer(AdministratorChatMember::class) -internal object AdministratorChatMemberSerializer : KSerializer { +@RiskFeature +object AdministratorChatMemberSerializer : KSerializer { override val descriptor: SerialDescriptor = ChatMemberSerializer.descriptor override fun deserialize(decoder: Decoder): AdministratorChatMember = ChatMemberSerializer.deserialize(decoder) as AdministratorChatMember diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatMember.kt index 8f4b9a88d1..d7c3f9b0ce 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMember/abstracts/ChatMember.kt @@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.types.ChatMember.abstracts import dev.inmo.tgbotapi.types.ChatMember.* import dev.inmo.tgbotapi.types.User import dev.inmo.tgbotapi.types.statusField +import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import kotlinx.serialization.* import kotlinx.serialization.descriptors.SerialDescriptor @@ -17,7 +18,8 @@ interface ChatMember { } @Serializer(ChatMember::class) -internal object ChatMemberSerializer : KSerializer { +@RiskFeature +object ChatMemberSerializer : KSerializer { override val descriptor: SerialDescriptor = JsonObject.serializer().descriptor override fun deserialize(decoder: Decoder): ChatMember { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Annotations.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Annotations.kt index 2d516c712a..421b12ba5b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Annotations.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/Annotations.kt @@ -35,4 +35,4 @@ const val lowLevelRiskFeatureMessage = "This method is low-level and not recomme AnnotationTarget.TYPEALIAS, AnnotationTarget.TYPE_PARAMETER ) -annotation class RiskFeature(val message: String) +annotation class RiskFeature(val message: String = lowLevelRiskFeatureMessage) From 9ad5bfbc572437d0eacc9332989ffbc76253e261 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 11 Mar 2021 16:36:01 +0600 Subject: [PATCH 35/37] remove BotInviteChatLink --- .../dev/inmo/tgbotapi/types/ChatInviteLink.kt | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt index cba15be9b9..46a46759d8 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt @@ -5,7 +5,6 @@ import kotlinx.serialization.* import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder -import kotlinx.serialization.json.JsonObject @Serializable private data class RawChatInviteLink( @@ -42,27 +41,6 @@ sealed class ChatInviteLink { abstract val membersLimit: MembersLimit? } -@Serializable -data class BotInviteLink( - @SerialName(inviteLinkField) - override val inviteLink: String, - @SerialName(creatorField) - override val creator: Bot, - @SerialName(isRevokedField) - override val isRevoked: Boolean = false, - @SerialName(expireDateField) - private val expireDate: UnixTimeStamp? = null, - @SerialName(memberLimitField) - override val membersLimit: MembersLimit? = null -) : ChatInviteLink() { - override val isPrimary: Boolean - get() = false - override val expirationDateTime: DateTime? - get() { - return DateTime(expireDate ?.seconds ?.milliseconds ?: return null) - } -} - @Serializable data class PrimaryInviteLink( @SerialName(inviteLinkField) @@ -114,9 +92,6 @@ object ChatInviteLinkSerializer : KSerializer { val deserializedRaw = RawChatInviteLink.serializer().deserialize(decoder) return deserializedRaw.run { when { - creator is Bot -> BotInviteLink( - inviteLink, creator, isRevoked, expirationDateTime, membersLimit - ) deserializedRaw.isPrimary -> PrimaryInviteLink( inviteLink, creator, isRevoked, expirationDateTime, membersLimit ) From e7265829d1c62d68305814d2f69508360d32cef8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 11 Mar 2021 20:17:08 +0600 Subject: [PATCH 36/37] include ChatMemberUpdated functionality --- .../dev/inmo/tgbotapi/types/ChatInviteLink.kt | 16 +++++--------- .../inmo/tgbotapi/types/ChatMemberUpdated.kt | 22 +++++++++++++++++++ .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 2 ++ .../dev/inmo/tgbotapi/types/UpdateTypes.kt | 6 ++++- .../update/CommonChatMemberUpdatedUpdate.kt | 10 +++++++++ .../types/update/MyChatMemberUpdatedUpdate.kt | 10 +++++++++ .../inmo/tgbotapi/types/update/RawUpdate.kt | 9 +++++--- .../abstracts/ChatMemberUpdatedUpdate.kt | 7 ++++++ 8 files changed, 68 insertions(+), 14 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMemberUpdated.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/CommonChatMemberUpdatedUpdate.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MyChatMemberUpdatedUpdate.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/abstracts/ChatMemberUpdatedUpdate.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt index 46a46759d8..fe6a0d094c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt @@ -17,7 +17,7 @@ private data class RawChatInviteLink( @SerialName(isRevokedField) val isRevoked: Boolean, @SerialName(expireDateField) - val expirationDateTime: UnixTimeStamp? = null, + val expirationDateTime: TelegramDate? = null, @SerialName(memberLimitField) val membersLimit: MembersLimit ?= null ) @@ -27,7 +27,7 @@ private fun ChatInviteLink.toRawChatInviteLink() = RawChatInviteLink( creator, isPrimary, isRevoked, - expirationDateTime ?.unixMillis ?.milliseconds ?.seconds ?.toLong(), + expirationDateTime ?.toTelegramDate(), membersLimit ) @@ -50,16 +50,14 @@ data class PrimaryInviteLink( @SerialName(isRevokedField) override val isRevoked: Boolean = false, @SerialName(expireDateField) - private val expireDate: UnixTimeStamp? = null, + private val expireDate: TelegramDate? = null, @SerialName(memberLimitField) override val membersLimit: MembersLimit? = null ) : ChatInviteLink() { override val isPrimary: Boolean get() = true override val expirationDateTime: DateTime? - get() { - return DateTime(expireDate ?.seconds ?.milliseconds ?: return null) - } + get() = expireDate ?.asDate } @Serializable @@ -71,16 +69,14 @@ data class CommonInviteLink( @SerialName(isRevokedField) override val isRevoked: Boolean = false, @SerialName(expireDateField) - private val expireDate: UnixTimeStamp? = null, + private val expireDate: TelegramDate? = null, @SerialName(memberLimitField) override val membersLimit: MembersLimit? = null ) : ChatInviteLink() { override val isPrimary: Boolean get() = false override val expirationDateTime: DateTime? - get() { - return DateTime(expireDate ?.seconds ?.milliseconds ?: return null) - } + get() = expireDate ?.asDate } @Serializer(ChatInviteLink::class) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMemberUpdated.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMemberUpdated.kt new file mode 100644 index 0000000000..856e113ac0 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatMemberUpdated.kt @@ -0,0 +1,22 @@ +package dev.inmo.tgbotapi.types + +import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember +import dev.inmo.tgbotapi.types.chat.abstracts.Chat +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ChatMemberUpdated( + @SerialName(chatField) + val chat: Chat, + @SerialName(fromField) + val user: User, + @SerialName(dateField) + val date: TelegramDate, + @SerialName(oldChatMemberField) + val oldChatMemberState: ChatMember, + @SerialName(newChatMemberField) + val newChatMemberState: ChatMember, + @SerialName(inviteLinkField) + val inviteLink: ChatInviteLink? = null +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 74d2f356b0..8fc47f2a24 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -253,6 +253,8 @@ const val canManageVoiceChatsField = "can_manage_voice_chats" const val canManageChatField = "can_manage_chat" const val pngStickerField = "png_sticker" const val tgsStickerField = "tgs_sticker" +const val oldChatMemberField = "old_chat_member" +const val newChatMemberField = "new_chat_member" const val okField = "ok" const val captionField = "caption" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UpdateTypes.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UpdateTypes.kt index 0c2be08534..1606ea6ed4 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UpdateTypes.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/UpdateTypes.kt @@ -11,6 +11,8 @@ const val UPDATE_SHIPPING_QUERY = "shipping_query" const val UPDATE_PRE_CHECKOUT_QUERY = "pre_checkout_query" const val UPDATE_POLL = "poll" const val UPDATE_POLL_ANSWER = "poll_answer" +const val MY_CHAT_MEMBER = "my_chat_member" +const val CHAT_MEMBER = "chat_member" val ALL_UPDATES_LIST = listOf( UPDATE_MESSAGE, @@ -23,5 +25,7 @@ val ALL_UPDATES_LIST = listOf( UPDATE_SHIPPING_QUERY, UPDATE_PRE_CHECKOUT_QUERY, UPDATE_POLL, - UPDATE_POLL_ANSWER + UPDATE_POLL_ANSWER, + MY_CHAT_MEMBER, + CHAT_MEMBER ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/CommonChatMemberUpdatedUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/CommonChatMemberUpdatedUpdate.kt new file mode 100644 index 0000000000..4811ebaa74 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/CommonChatMemberUpdatedUpdate.kt @@ -0,0 +1,10 @@ +package dev.inmo.tgbotapi.types.update + +import dev.inmo.tgbotapi.types.ChatMemberUpdated +import dev.inmo.tgbotapi.types.UpdateIdentifier +import dev.inmo.tgbotapi.types.update.abstracts.ChatMemberUpdatedUpdate + +data class CommonChatMemberUpdatedUpdate( + override val updateId: UpdateIdentifier, + override val data: ChatMemberUpdated +) : ChatMemberUpdatedUpdate diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MyChatMemberUpdatedUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MyChatMemberUpdatedUpdate.kt new file mode 100644 index 0000000000..3dabbbb017 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/MyChatMemberUpdatedUpdate.kt @@ -0,0 +1,10 @@ +package dev.inmo.tgbotapi.types.update + +import dev.inmo.tgbotapi.types.ChatMemberUpdated +import dev.inmo.tgbotapi.types.UpdateIdentifier +import dev.inmo.tgbotapi.types.update.abstracts.ChatMemberUpdatedUpdate + +data class MyChatMemberUpdatedUpdate( + override val updateId: UpdateIdentifier, + override val data: ChatMemberUpdated +) : ChatMemberUpdatedUpdate diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/RawUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/RawUpdate.kt index 60080dac74..87e46b45d3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/RawUpdate.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/RawUpdate.kt @@ -1,9 +1,9 @@ package dev.inmo.tgbotapi.types.update +import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.CallbackQuery.RawCallbackQuery import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.RawChosenInlineResult import dev.inmo.tgbotapi.types.InlineQueries.query.RawInlineQuery -import dev.inmo.tgbotapi.types.UpdateIdentifier import dev.inmo.tgbotapi.types.message.abstracts.* import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery import dev.inmo.tgbotapi.types.payments.ShippingQuery @@ -11,7 +11,6 @@ import dev.inmo.tgbotapi.types.polls.Poll import dev.inmo.tgbotapi.types.polls.PollAnswer import dev.inmo.tgbotapi.types.update.abstracts.UnknownUpdate import dev.inmo.tgbotapi.types.update.abstracts.Update -import dev.inmo.tgbotapi.types.updateIdField import kotlinx.serialization.* import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.jsonObject @@ -34,7 +33,9 @@ internal data class RawUpdate constructor( private val shipping_query: ShippingQuery? = null, private val pre_checkout_query: PreCheckoutQuery? = null, private val poll: Poll? = null, - private val poll_answer: PollAnswer? = null + private val poll_answer: PollAnswer? = null, + private val my_chat_member: ChatMemberUpdated? = null, + private val chat_member: ChatMemberUpdated? = null ) { private var initedUpdate: Update? = null /** @@ -58,6 +59,8 @@ internal data class RawUpdate constructor( pre_checkout_query != null -> PreCheckoutQueryUpdate(updateId, pre_checkout_query) poll != null -> PollUpdate(updateId, poll) poll_answer != null -> PollAnswerUpdate(updateId, poll_answer) + my_chat_member != null -> MyChatMemberUpdatedUpdate(updateId, my_chat_member) + chat_member != null -> CommonChatMemberUpdatedUpdate(updateId, chat_member) else -> UnknownUpdate( updateId, raw.toString(), diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/abstracts/ChatMemberUpdatedUpdate.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/abstracts/ChatMemberUpdatedUpdate.kt new file mode 100644 index 0000000000..44c11da4d3 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/update/abstracts/ChatMemberUpdatedUpdate.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.types.update.abstracts + +import dev.inmo.tgbotapi.types.ChatMemberUpdated + +interface ChatMemberUpdatedUpdate : Update { + override val data: ChatMemberUpdated +} From 66f7801b3263a770603b66fa760fabf0f3136ac8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 11 Mar 2021 20:39:33 +0600 Subject: [PATCH 37/37] fix ChatInviteLinkRequest --- .../requests/chat/abstracts/ChatInviteLinkRequest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/abstracts/ChatInviteLinkRequest.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/abstracts/ChatInviteLinkRequest.kt index afbcbd72f8..a56d8c5523 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/abstracts/ChatInviteLinkRequest.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/abstracts/ChatInviteLinkRequest.kt @@ -5,11 +5,11 @@ import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest import dev.inmo.tgbotapi.types.* import kotlinx.serialization.DeserializationStrategy -interface ChatInviteLinkRequest : SimpleRequest { +interface ChatInviteLinkRequest : SimpleRequest { val chatId: ChatId - override val resultDeserializer: DeserializationStrategy - get() = BotInviteLink.serializer() + override val resultDeserializer: DeserializationStrategy + get() = CommonInviteLink.serializer() } interface KnownChatInviteLinkRequest : ChatInviteLinkRequest { val inviteLink: String