This commit is contained in:
InsanusMokrassar 2022-09-22 14:28:49 +06:00
parent 226ef5df24
commit c951f074ae
3 changed files with 18 additions and 27 deletions

View File

@ -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]

View File

@ -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

View File

@ -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) {