From ae6993efba1326c382ea19c1c3ad6d044ff73b2b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 28 Jun 2024 13:09:37 +0600 Subject: [PATCH 1/3] start 0.6.0 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a46206..ebfe7b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # PlaguPoster +## 0.6.0 + ## 0.5.6 * `Ratings`: diff --git a/gradle.properties b/gradle.properties index 1d1336f..86a3bf5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,4 +10,4 @@ android.enableJetifier=true # Project data group=dev.inmo -version=0.5.6 +version=0.6.0 From e3958aff3f18c75d22f4790e70fa478af32330ea Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 28 Jun 2024 13:24:13 +0600 Subject: [PATCH 2/3] update dependencies --- CHANGELOG.md | 2 ++ gradle.properties | 1 - gradle/libs.versions.toml | 12 ++++++------ gradle/wrapper/gradle-wrapper.properties | 2 +- .../src/commonMain/kotlin/buttons/RootButtons.kt | 4 ++-- ratings/source/src/jvmMain/kotlin/Plugin.kt | 12 +++++++++--- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebfe7b0..d4a8923 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 0.6.0 +* Dependencies update + ## 0.5.6 * `Ratings`: diff --git a/gradle.properties b/gradle.properties index 86a3bf5..e265d68 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,4 @@ kotlin.code.style=official -org.gradle.jvmargs=-Xmx1024m org.gradle.parallel=true kotlin.js.generate.externals=true kotlin.incremental=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 42528c0..229ab2b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,12 +3,12 @@ kotlin = "1.9.23" kotlin-serialization = "1.6.3" -plagubot = "8.3.0" -tgbotapi = "12.0.1" -microutils = "0.20.45" -kslog = "1.3.3" -krontab = "2.2.9" -plagubot-plugins = "0.18.3" +plagubot = "8.4.0" +tgbotapi = "15.0.0" +microutils = "0.21.1" +kslog = "1.3.4" +krontab = "2.3.0" +plagubot-plugins = "0.19.0" dokka = "1.9.20" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e411586..48c0a02 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-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/ratings/source/src/commonMain/kotlin/buttons/RootButtons.kt b/ratings/source/src/commonMain/kotlin/buttons/RootButtons.kt index ccba53c..337033f 100644 --- a/ratings/source/src/commonMain/kotlin/buttons/RootButtons.kt +++ b/ratings/source/src/commonMain/kotlin/buttons/RootButtons.kt @@ -122,7 +122,7 @@ suspend fun BehaviourContext.includeRootNavigationButtonsHandler( edit( it.message, - onPageUpdate(SimplePagination(page, size), args.drop(3).toTypedArray()) ?: return@runCatchingSafely + replyMarkup = onPageUpdate(SimplePagination(page, size), args.drop(3).toTypedArray()) ?: return@runCatchingSafely ) } @@ -155,7 +155,7 @@ suspend fun BehaviourContext.includeRootNavigationButtonsHandler( if (prefix == RootButtonsShowRatingData) { runCatchingSafely { val rating = ratingRaw.toDoubleOrNull() ?: return@runCatchingSafely - edit(it.message, ratingsRepo.buildRatingButtons(postsRepo, Rating(rating))) + edit(it.message, replyMarkup = ratingsRepo.buildRatingButtons(postsRepo, Rating(rating))) } answer(it) diff --git a/ratings/source/src/jvmMain/kotlin/Plugin.kt b/ratings/source/src/jvmMain/kotlin/Plugin.kt index c855b64..38ac0ce 100644 --- a/ratings/source/src/jvmMain/kotlin/Plugin.kt +++ b/ratings/source/src/jvmMain/kotlin/Plugin.kt @@ -28,6 +28,7 @@ import dev.inmo.plaguposter.ratings.utils.postsByRatings import dev.inmo.tgbotapi.extensions.api.answers.answer import dev.inmo.tgbotapi.extensions.api.delete import dev.inmo.tgbotapi.extensions.api.edit.edit +import dev.inmo.tgbotapi.extensions.api.send.polls.sendRegularPoll import dev.inmo.tgbotapi.extensions.api.send.reply import dev.inmo.tgbotapi.extensions.api.send.send import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext @@ -41,7 +42,10 @@ import dev.inmo.tgbotapi.types.ReplyParameters import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton import dev.inmo.tgbotapi.types.message.textsources.bold import dev.inmo.tgbotapi.types.message.textsources.regular +import dev.inmo.tgbotapi.types.polls.InputPollOption +import dev.inmo.tgbotapi.types.polls.PollOption import dev.inmo.tgbotapi.utils.buildEntities +import dev.inmo.tgbotapi.utils.extensions.makeSourceString import kotlinx.coroutines.delay import kotlinx.coroutines.flow.first import kotlinx.serialization.Serializable @@ -112,7 +116,7 @@ object Plugin : Plugin { onPollUpdates (markerFactory = { it.id }) { poll -> val postId = pollsToPostsIdsRepo.get(poll.id) ?: return@onPollUpdates val newRating = poll.options.sumOf { - (variantsTransformer(it.text) ?.double ?.times(it.votes)) ?: 0.0 + (variantsTransformer(it.textSources.makeSourceString()) ?.double ?.times(it.votes)) ?: 0.0 } ratingsRepo.set(postId, Rating(newRating)) } @@ -129,7 +133,9 @@ object Plugin : Plugin { val sent = send( content.chatId, config.ratingOfferText, - config.variants.keys.toList(), + options = config.variants.map { + InputPollOption(it.key) + }, replyParameters = ReplyParameters(content.chatId, content.messageId) ) pollsToPostsIdsRepo.set(sent.content.poll.id, postId) @@ -265,7 +271,7 @@ object Plugin : Plugin { onMessageDataCallbackQuery("ratings_interactive", initialFilter = { it.message.chat.id in chatConfig.allSourceChatIds }) { edit( it.message, - ratingsRepo.buildRootButtons() + replyMarkup = ratingsRepo.buildRootButtons() ) } From ad967c002a3644daeafdc78e72a6727e55947552 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 28 Jun 2024 13:28:12 +0600 Subject: [PATCH 3/3] update github ci/cd scripts --- .github/workflows/build_and_publish.yml | 1 + .github/workflows/docker-publish.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/build_and_publish.yml b/.github/workflows/build_and_publish.yml index 76e4cbb..79a178e 100644 --- a/.github/workflows/build_and_publish.yml +++ b/.github/workflows/build_and_publish.yml @@ -14,6 +14,7 @@ jobs: java-version: 17 - name: Rewrite version run: | + printf "\norg.gradle.jvmargs=-Xmx1g -Xms500m\nkotlin.daemon.jvmargs=-Xmx1g -Xms500m\norg.gradle.daemon=false" >> gradle.properties branch="`echo "${{ github.ref }}" | grep -o "[^/]*$"`" cat gradle.properties | sed -e "s/^version=\([0-9\.]*\)/version=\1-branch_$branch-build${{ github.run_number }}/" > gradle.properties.tmp rm gradle.properties diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 46f6769..308edcd 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -16,6 +16,7 @@ jobs: java-version: 17 - name: Rewrite version run: | + printf "\norg.gradle.jvmargs=-Xmx1g -Xms500m\nkotlin.daemon.jvmargs=-Xmx1g -Xms500m\norg.gradle.daemon=false" >> gradle.properties branch="`echo "${{ github.ref }}" | grep -o "[^/]*$"`" if [[ "$branch" != "master" ]]; then cat gradle.properties | sed -e "s/^version=\([0-9\.]*\)/version=\1-branch_$branch-build${{ github.run_number }}/" > gradle.properties.tmp