From c951f074aea5e344f83aeaf2c53835d861880471 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 22 Sep 2022 14:28:49 +0600 Subject: [PATCH] updates --- gradle/libs.versions.toml | 6 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- welcome/src/main/kotlin/WelcomePlugin.kt | 37 +++++++++--------------- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b310e12..9e1d8a6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,9 +1,9 @@ [versions] kotlin = "1.7.10" -plagubot = "2.2.0" -kslog = "0.5.1" -plagubot-commands = "0.3.2" +plagubot = "2.3.3" +kslog = "0.5.2" +plagubot-commands = "0.3.4" [libraries] diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8049c68..ae04661 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-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/welcome/src/main/kotlin/WelcomePlugin.kt b/welcome/src/main/kotlin/WelcomePlugin.kt index 40a45f6..c2386c9 100644 --- a/welcome/src/main/kotlin/WelcomePlugin.kt +++ b/welcome/src/main/kotlin/WelcomePlugin.kt @@ -26,6 +26,8 @@ import dev.inmo.tgbotapi.types.commands.BotCommandScope import dev.inmo.tgbotapi.types.message.abstracts.CommonGroupContentMessage import dev.inmo.tgbotapi.types.message.content.MessageContent import dev.inmo.tgbotapi.types.message.content.TextContent +import dev.inmo.tgbotapi.utils.regular +import dev.inmo.tgbotapi.utils.underline import kotlinx.coroutines.* import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.first @@ -79,17 +81,16 @@ class WelcomePlugin : Plugin { val user = groupMessage.user if (userIsAdmin(user, groupMessage.chat)) { - val sentMessage = sendMessage( + val sentMessage = send( user, - buildEntities { - regular("Ok, send me the message which should be used as welcome message for chat ") - underline(groupMessage.chat.title) - }, replyMarkup = flatInlineKeyboard { dataButton("Unset", unsetData) dataButton("Cancel", cancelData) } - ) + ) { + regular("Ok, send me the message which should be used as welcome message for chat ") + underline(groupMessage.chat.title) + } oneOf( parallel { @@ -97,7 +98,7 @@ class WelcomePlugin : Plugin { it.data == unsetData && it.message.sameMessage(sentMessage) }.first() - val answerEntities = buildEntities { + edit(sentMessage) { if (welcomeTable.unset(groupMessage.chat.id)) { regular("Welcome message has been removed for chat ") underline(groupMessage.chat.title) @@ -107,11 +108,6 @@ class WelcomePlugin : Plugin { } } - edit( - sentMessage, - answerEntities - ) - answer(query) }, parallel { @@ -120,12 +116,11 @@ class WelcomePlugin : Plugin { }.first() edit( - sentMessage, - buildEntities { - regular("You have cancelled change of welcome message for chat ") - underline(groupMessage.chat.title) - } - ) + sentMessage + ) { + regular("You have cancelled change of welcome message for chat ") + underline(groupMessage.chat.title) + } answer(query) }, @@ -142,7 +137,7 @@ class WelcomePlugin : Plugin { ) ) - val entities = buildEntities { + reply(message) { if (success) { regular("Welcome message has been changed for chat ") underline(groupMessage.chat.title) @@ -153,10 +148,6 @@ class WelcomePlugin : Plugin { underline(groupMessage.chat.title) } } - reply( - message, - entities - ) }, parallel { while (isActive) {