mirror of
https://github.com/InsanusMokrassar/TelegramBotTutorial.git
synced 2024-12-22 06:07:11 +00:00
fixes and improvements
This commit is contained in:
parent
7483988faa
commit
eea5fcc360
@ -5,6 +5,7 @@ import dev.inmo.plagubot.Plugin
|
|||||||
import dev.inmo.plagubot.plugins.commands.full
|
import dev.inmo.plagubot.plugins.commands.full
|
||||||
import dev.inmo.tgbotapi.bot.exceptions.RequestException
|
import dev.inmo.tgbotapi.bot.exceptions.RequestException
|
||||||
import dev.inmo.tgbotapi.extensions.api.answers.answer
|
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.edit.edit
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.reply
|
import dev.inmo.tgbotapi.extensions.api.send.reply
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.send
|
import dev.inmo.tgbotapi.extensions.api.send.send
|
||||||
@ -81,10 +82,13 @@ class WelcomePlugin : Plugin {
|
|||||||
val user = groupMessage.user
|
val user = groupMessage.user
|
||||||
|
|
||||||
if (adminsCacheAPI.isAdmin(groupMessage.chat.id, user.id)) {
|
if (adminsCacheAPI.isAdmin(groupMessage.chat.id, user.id)) {
|
||||||
|
val previousMessage = welcomeTable.get(groupMessage.chat.id)
|
||||||
val sentMessage = send(
|
val sentMessage = send(
|
||||||
user,
|
user,
|
||||||
replyMarkup = flatInlineKeyboard {
|
replyMarkup = flatInlineKeyboard {
|
||||||
dataButton("Unset", unsetData)
|
if (previousMessage != null) {
|
||||||
|
dataButton("Unset", unsetData)
|
||||||
|
}
|
||||||
dataButton("Cancel", cancelData)
|
dataButton("Cancel", cancelData)
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
@ -115,9 +119,7 @@ class WelcomePlugin : Plugin {
|
|||||||
it.data == cancelData && it.message.sameMessage(sentMessage)
|
it.data == cancelData && it.message.sameMessage(sentMessage)
|
||||||
}.first()
|
}.first()
|
||||||
|
|
||||||
edit(
|
edit(sentMessage) {
|
||||||
sentMessage
|
|
||||||
) {
|
|
||||||
regular("You have cancelled change of welcome message for chat ")
|
regular("You have cancelled change of welcome message for chat ")
|
||||||
underline(groupMessage.chat.title)
|
underline(groupMessage.chat.title)
|
||||||
}
|
}
|
||||||
@ -148,6 +150,7 @@ class WelcomePlugin : Plugin {
|
|||||||
underline(groupMessage.chat.title)
|
underline(groupMessage.chat.title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
delete(sentMessage)
|
||||||
},
|
},
|
||||||
parallel {
|
parallel {
|
||||||
while (isActive) {
|
while (isActive) {
|
||||||
|
Loading…
Reference in New Issue
Block a user