mirror of
https://github.com/InsanusMokrassar/CaptchaPlaguBotPlugin.git
synced 2024-11-25 11:38:55 +00:00
fixes in captcha related to expression
This commit is contained in:
parent
c84cff9ddc
commit
7dead36cd9
@ -8,6 +8,7 @@ import dev.inmo.plagubot.plugins.captcha.slotMachineReplyMarkup
|
|||||||
import dev.inmo.tgbotapi.extensions.api.answers.answerCallbackQuery
|
import dev.inmo.tgbotapi.extensions.api.answers.answerCallbackQuery
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.members.*
|
import dev.inmo.tgbotapi.extensions.api.chat.members.*
|
||||||
import dev.inmo.tgbotapi.extensions.api.deleteMessage
|
import dev.inmo.tgbotapi.extensions.api.deleteMessage
|
||||||
|
import dev.inmo.tgbotapi.extensions.api.edit.edit
|
||||||
import dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup
|
import dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.*
|
import dev.inmo.tgbotapi.extensions.api.send.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
@ -397,9 +398,11 @@ data class ExpressionCaptchaProvider(
|
|||||||
bold(callbackData.second)
|
bold(callbackData.second)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun removeRedundantMessages() {
|
suspend fun removeRedundantMessages(removeSentMessage: Boolean = true) {
|
||||||
safelyWithoutExceptions {
|
safelyWithoutExceptions {
|
||||||
deleteMessage(sentMessage)
|
if (removeSentMessage) {
|
||||||
|
deleteMessage(sentMessage)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,18 +411,29 @@ data class ExpressionCaptchaProvider(
|
|||||||
val callback: suspend (Boolean) -> Unit = {
|
val callback: suspend (Boolean) -> Unit = {
|
||||||
passedMutex.withLock {
|
passedMutex.withLock {
|
||||||
if (passed == null) {
|
if (passed == null) {
|
||||||
removeRedundantMessages()
|
|
||||||
passed = it
|
passed = it
|
||||||
when {
|
runCatchingSafely<Unit> {
|
||||||
it -> safelyWithoutExceptions {
|
when {
|
||||||
restrictChatMember(
|
it -> {
|
||||||
chat,
|
removeRedundantMessages()
|
||||||
user,
|
safelyWithoutExceptions {
|
||||||
permissions = leftRestrictionsPermissions
|
restrictChatMember(
|
||||||
)
|
chat,
|
||||||
|
user,
|
||||||
|
permissions = leftRestrictionsPermissions
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
removeRedundantMessages(removeSentMessage = false)
|
||||||
|
edit(sentMessage) {
|
||||||
|
+"User " + mention(user) + underline("didn't passed") + "captcha"
|
||||||
|
}
|
||||||
|
if (kickOnUnsuccess) {
|
||||||
|
banUser(chat, user, leftRestrictionsPermissions)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kickOnUnsuccess -> banUser(chat, user, leftRestrictionsPermissions)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user