From 79f3962c65106bdc352486679b9f7e8f3e97c3fe Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 10 Jan 2021 15:01:52 +0600 Subject: [PATCH 1/9] start 0.1.0 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d44a151..9099951 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 0.1.0 + ## 0.0.5 * `Versions` diff --git a/gradle.properties b/gradle.properties index d2a56f9..3048e90 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,4 +16,4 @@ sqlite_version=3.30.1 github_release_plugin_version=2.2.12 group=dev.inmo -version=0.0.5 +version=0.1.0 From bc5737d435908a4049a26884efaab228d325b737 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 10 Jan 2021 15:04:45 +0600 Subject: [PATCH 2/9] update dependencies --- CHANGELOG.md | 4 ++++ bot/src/main/kotlin/dev/inmo/plagubot/App.kt | 6 +++--- gradle.properties | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9099951..0cc245b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.1.0 +* `Versions` + * `tgbotapi`: `0.30.10` -> `0.31.0` + * `microutils`: `0.4.11` -> `0.4.16` + ## 0.0.5 * `Versions` diff --git a/bot/src/main/kotlin/dev/inmo/plagubot/App.kt b/bot/src/main/kotlin/dev/inmo/plagubot/App.kt index 005d811..c32a5fc 100644 --- a/bot/src/main/kotlin/dev/inmo/plagubot/App.kt +++ b/bot/src/main/kotlin/dev/inmo/plagubot/App.kt @@ -3,9 +3,9 @@ package dev.inmo.plagubot import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions import dev.inmo.plagubot.config.Config import dev.inmo.plagubot.config.configSerialFormat +import dev.inmo.tgbotapi.bot.Ktor.telegramBot import dev.inmo.tgbotapi.extensions.api.bot.setMyCommands -import dev.inmo.tgbotapi.extensions.api.telegramBot -import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling +import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling import dev.inmo.tgbotapi.types.botCommandsLimit import kotlinx.coroutines.* import kotlinx.serialization.InternalSerializationApi @@ -17,7 +17,7 @@ suspend inline fun initPlaguBot( ) { val bot = telegramBot(config.botToken) - bot.startGettingFlowsUpdatesByLongPolling(scope = scope) { + bot.longPolling(scope = scope) { val commands = config.plugins.flatMap { it.invoke(bot, config.database.database, this, scope) it.getCommands() diff --git a/gradle.properties b/gradle.properties index 3048e90..f6929dc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,8 +8,8 @@ kotlin_version=1.4.21 kotlin_coroutines_version=1.4.2 kotlin_serialisation_runtime_version=1.0.1 kotlin_exposed_version=0.28.1 -tgbotapi_version=0.30.10 -microutils_version=0.4.11 +tgbotapi_version=0.31.0 +microutils_version=0.4.16 klassindex_version=4.1.0-rc.1 sqlite_version=3.30.1 From 595102fede897a164b0b4be47c853b0aef7b9d03 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 10 Jan 2021 15:21:31 +0600 Subject: [PATCH 3/9] BehaviourContext.invoke --- CHANGELOG.md | 3 +++ bot/src/main/kotlin/dev/inmo/plagubot/App.kt | 11 ++++------- .../main/kotlin/dev/inmo/plagubot/HelloPlugin.kt | 11 ++--------- .../src/main/kotlin/dev/inmo/plagubot/Plugin.kt | 16 ++++++++++++---- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cc245b..5fd2c79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ * `Versions` * `tgbotapi`: `0.30.10` -> `0.31.0` * `microutils`: `0.4.11` -> `0.4.16` +* `Plugin` + * New method `BehaviourContext#invoke` + * Old method `invoke` has been deprecated ## 0.0.5 diff --git a/bot/src/main/kotlin/dev/inmo/plagubot/App.kt b/bot/src/main/kotlin/dev/inmo/plagubot/App.kt index c32a5fc..de2672b 100644 --- a/bot/src/main/kotlin/dev/inmo/plagubot/App.kt +++ b/bot/src/main/kotlin/dev/inmo/plagubot/App.kt @@ -5,6 +5,7 @@ import dev.inmo.plagubot.config.Config import dev.inmo.plagubot.config.configSerialFormat import dev.inmo.tgbotapi.bot.Ktor.telegramBot import dev.inmo.tgbotapi.extensions.api.bot.setMyCommands +import dev.inmo.tgbotapi.extensions.behaviour_builder.buildBehaviour import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling import dev.inmo.tgbotapi.types.botCommandsLimit import kotlinx.coroutines.* @@ -17,9 +18,9 @@ suspend inline fun initPlaguBot( ) { val bot = telegramBot(config.botToken) - bot.longPolling(scope = scope) { + bot.buildBehaviour(scope) { val commands = config.plugins.flatMap { - it.invoke(bot, config.database.database, this, scope) + it.apply { invoke(config.database.database) } it.getCommands() }.let { val futureUnavailable = it.drop(botCommandsLimit.last) @@ -28,11 +29,7 @@ suspend inline fun initPlaguBot( } it.take(botCommandsLimit.last) } - scope.launch { - safelyWithoutExceptions { - bot.setMyCommands(commands) - } - } + safelyWithoutExceptions { setMyCommands(commands) } } } diff --git a/bot/src/main/kotlin/dev/inmo/plagubot/HelloPlugin.kt b/bot/src/main/kotlin/dev/inmo/plagubot/HelloPlugin.kt index 19ef11e..1b66d96 100644 --- a/bot/src/main/kotlin/dev/inmo/plagubot/HelloPlugin.kt +++ b/bot/src/main/kotlin/dev/inmo/plagubot/HelloPlugin.kt @@ -1,8 +1,6 @@ package dev.inmo.plagubot -import dev.inmo.tgbotapi.bot.TelegramBot -import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter -import kotlinx.coroutines.CoroutineScope +import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import org.jetbrains.exposed.sql.Database @@ -12,12 +10,7 @@ import org.jetbrains.exposed.sql.Database data class HelloPlugin( val parameter: String ) : Plugin { - override suspend fun invoke( - bot: TelegramBot, - database: Database, - updatesFilter: FlowsUpdatesFilter, - scope: CoroutineScope - ) { + override suspend fun BehaviourContext.invoke(database: Database) { println(parameter) } } diff --git a/plugin/src/main/kotlin/dev/inmo/plagubot/Plugin.kt b/plugin/src/main/kotlin/dev/inmo/plagubot/Plugin.kt index b37fb75..dbd17b1 100644 --- a/plugin/src/main/kotlin/dev/inmo/plagubot/Plugin.kt +++ b/plugin/src/main/kotlin/dev/inmo/plagubot/Plugin.kt @@ -1,6 +1,7 @@ package dev.inmo.plagubot import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext import dev.inmo.tgbotapi.types.BotCommand import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter import kotlinx.coroutines.CoroutineScope @@ -19,13 +20,20 @@ interface Plugin { */ suspend fun getCommands(): List = emptyList() - /** - * This method (usually) will be invoked just one time in the whole application. - */ + @Deprecated("Override other method with receiver BehaviourContext") suspend operator fun invoke( bot: TelegramBot, database: Database, updatesFilter: FlowsUpdatesFilter, scope: CoroutineScope - ) + ) {} + + /** + * This method (usually) will be invoked just one time in the whole application. + */ + suspend operator fun BehaviourContext.invoke( + database: Database + ) { + invoke(bot, database, flowsUpdatesFilter, scope) + } } From 7258275d0e0833e9796ebf6c6c5290715a5dc1cb Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 16 Feb 2021 23:29:41 +0600 Subject: [PATCH 4/9] start 0.1.1 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fd2c79..5d749c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 0.1.1 + ## 0.1.0 * `Versions` diff --git a/gradle.properties b/gradle.properties index f6929dc..20216a5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,4 +16,4 @@ sqlite_version=3.30.1 github_release_plugin_version=2.2.12 group=dev.inmo -version=0.1.0 +version=0.1.1 From 158b03a9ca4c7ba3eff43055d54f41b1f659795e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 16 Feb 2021 23:32:19 +0600 Subject: [PATCH 5/9] update dependencies --- CHANGELOG.md | 7 +++++++ gradle.properties | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d749c8..59ccfcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ## 0.1.1 +* `Versions` + * `kotlin`: `1.4.21` -> `1.4.30` + * `serialization`: `1.0.1` -> `1.1.0-RC` + * `exposed`: `0.28.1` -> `0.29.1` + * `tgbotapi`: `0.31.0` -> `0.32.5` + * `microutils`: `0.4.16` -> `0.4.25` + ## 0.1.0 * `Versions` diff --git a/gradle.properties b/gradle.properties index 20216a5..0e2cf14 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,12 +4,12 @@ org.gradle.parallel=true kotlin.js.generate.externals=true kotlin.incremental=true -kotlin_version=1.4.21 +kotlin_version=1.4.30 kotlin_coroutines_version=1.4.2 -kotlin_serialisation_runtime_version=1.0.1 -kotlin_exposed_version=0.28.1 -tgbotapi_version=0.31.0 -microutils_version=0.4.16 +kotlin_serialisation_runtime_version=1.1.0-RC +kotlin_exposed_version=0.29.1 +tgbotapi_version=0.32.5 +microutils_version=0.4.25 klassindex_version=4.1.0-rc.1 sqlite_version=3.30.1 From f3c36404215c8f2c0ab325ab9c88ea85f21e5f97 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 16 Feb 2021 23:34:47 +0600 Subject: [PATCH 6/9] update publishing scripts --- bot/pubconf.kpsb | 2 +- bot/publish.gradle | 27 +++++++++++++++++++-------- plugin/pubconf.kpsb | 2 +- plugin/publish.gradle | 27 +++++++++++++++++++-------- 4 files changed, 40 insertions(+), 18 deletions(-) diff --git a/bot/pubconf.kpsb b/bot/pubconf.kpsb index d463863..aac6132 100644 --- a/bot/pubconf.kpsb +++ b/bot/pubconf.kpsb @@ -1 +1 @@ -{"bintrayConfig":{"repo":"PlaguBot","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/PlaguBot","autoPublish":true,"overridePublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/PlaguBot/LICENSE"}],"mavenConfig":{"name":"PlaguBot ${project.name}","description":"","url":"https://github.com/InsanusMokrassar/PlaguBot","vcsUrl":"ssh://git@github.com/InsanusMokrassar/PlaguBot.git","developers":[{"id":"InsanusMokrassar","name":"Aleksei Ovsiannikov","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"JVM"} \ No newline at end of file +{"bintrayConfig":{"repo":"PlaguBot","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/PlaguBot","autoPublish":true,"overridePublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/PlaguBot/LICENSE"}],"mavenConfig":{"name":"PlaguBot Bot","description":"Base PlaguBot project","url":"https://github.com/InsanusMokrassar/PlaguBot","vcsUrl":"ssh://git@github.com/InsanusMokrassar/PlaguBot.git","includeGpgSigning":true,"publishToMavenCentral":true,"developers":[{"id":"InsanusMokrassar","name":"Aleksei Ovsiannikov","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"JVM"} \ No newline at end of file diff --git a/bot/publish.gradle b/bot/publish.gradle index 30acc17..8bc041f 100644 --- a/bot/publish.gradle +++ b/bot/publish.gradle @@ -1,9 +1,6 @@ apply plugin: 'maven-publish' +apply plugin: 'signing' -task sourcesJar(type: Jar) { - from sourceSets.main.allSource - classifier = 'sources' -} task javadocJar(type: Jar) { from javadoc @@ -15,14 +12,13 @@ publishing { maven(MavenPublication) { from components.java - artifact sourcesJar artifact javadocJar pom { resolveStrategy = Closure.DELEGATE_FIRST - description = "" - name = "PlaguBot ${project.name}" + description = "Base PlaguBot project" + name = "PlaguBot Bot" url = "https://github.com/InsanusMokrassar/PlaguBot" scm { @@ -59,8 +55,23 @@ publishing { 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') + } + } + } } } -} \ No newline at end of file +} + +signing { + useGpgCmd() + sign publishing.publications +} diff --git a/plugin/pubconf.kpsb b/plugin/pubconf.kpsb index d463863..433c2f0 100644 --- a/plugin/pubconf.kpsb +++ b/plugin/pubconf.kpsb @@ -1 +1 @@ -{"bintrayConfig":{"repo":"PlaguBot","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/PlaguBot","autoPublish":true,"overridePublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/PlaguBot/LICENSE"}],"mavenConfig":{"name":"PlaguBot ${project.name}","description":"","url":"https://github.com/InsanusMokrassar/PlaguBot","vcsUrl":"ssh://git@github.com/InsanusMokrassar/PlaguBot.git","developers":[{"id":"InsanusMokrassar","name":"Aleksei Ovsiannikov","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"JVM"} \ No newline at end of file +{"bintrayConfig":{"repo":"PlaguBot","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/PlaguBot","autoPublish":true,"overridePublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/PlaguBot/LICENSE"}],"mavenConfig":{"name":"PlaguBot Plugin","description":"Base dependency for whole PlaguBot project","url":"https://github.com/InsanusMokrassar/PlaguBot","vcsUrl":"ssh://git@github.com/InsanusMokrassar/PlaguBot.git","includeGpgSigning":true,"publishToMavenCentral":true,"developers":[{"id":"InsanusMokrassar","name":"Aleksei Ovsiannikov","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"JVM"} \ No newline at end of file diff --git a/plugin/publish.gradle b/plugin/publish.gradle index 30acc17..624cde7 100644 --- a/plugin/publish.gradle +++ b/plugin/publish.gradle @@ -1,9 +1,6 @@ apply plugin: 'maven-publish' +apply plugin: 'signing' -task sourcesJar(type: Jar) { - from sourceSets.main.allSource - classifier = 'sources' -} task javadocJar(type: Jar) { from javadoc @@ -15,14 +12,13 @@ publishing { maven(MavenPublication) { from components.java - artifact sourcesJar artifact javadocJar pom { resolveStrategy = Closure.DELEGATE_FIRST - description = "" - name = "PlaguBot ${project.name}" + description = "Base dependency for whole PlaguBot project" + name = "PlaguBot Plugin" url = "https://github.com/InsanusMokrassar/PlaguBot" scm { @@ -59,8 +55,23 @@ publishing { 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') + } + } + } } } -} \ No newline at end of file +} + +signing { + useGpgCmd() + sign publishing.publications +} From 96f1ff56c073e544f9bdb08f51409c0883e66ac8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 16 Feb 2021 23:35:25 +0600 Subject: [PATCH 7/9] update gradle wrapper version --- 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 be52383..2a56324 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From fc9d668e31436838c85a7f2aae77b24debbc51f2 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 16 Feb 2021 23:37:42 +0600 Subject: [PATCH 8/9] add build workflow --- .github/workflows/build.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ceab9f2 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,16 @@ +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 01aa098125839fdbae00f74840f92c892cca7acd Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 16 Feb 2021 23:42:25 +0600 Subject: [PATCH 9/9] update changelog and gradle.properties --- CHANGELOG.md | 12 +++--------- gradle.properties | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59ccfcb..c049a90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,19 +1,13 @@ # Changelog -## 0.1.1 +## 0.1.0 * `Versions` * `kotlin`: `1.4.21` -> `1.4.30` * `serialization`: `1.0.1` -> `1.1.0-RC` * `exposed`: `0.28.1` -> `0.29.1` - * `tgbotapi`: `0.31.0` -> `0.32.5` - * `microutils`: `0.4.16` -> `0.4.25` - -## 0.1.0 - -* `Versions` - * `tgbotapi`: `0.30.10` -> `0.31.0` - * `microutils`: `0.4.11` -> `0.4.16` + * `tgbotapi`: `0.30.10` -> `0.32.5` + * `microutils`: `0.4.11` -> `0.4.25` * `Plugin` * New method `BehaviourContext#invoke` * Old method `invoke` has been deprecated diff --git a/gradle.properties b/gradle.properties index 0e2cf14..bde1212 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,4 +16,4 @@ sqlite_version=3.30.1 github_release_plugin_version=2.2.12 group=dev.inmo -version=0.1.1 +version=0.1.0