This commit is contained in:
InsanusMokrassar 2022-07-31 00:35:05 +06:00
parent f1093d6944
commit d8dbb2512f
2 changed files with 23 additions and 20 deletions

View File

@ -1,6 +1,7 @@
package dev.inmo.plagubot.plugins.captcha package dev.inmo.plagubot.plugins.captcha
import dev.inmo.tgbotapi.extensions.utils.SlotMachineReelImage import dev.inmo.tgbotapi.extensions.utils.SlotMachineReelImage
import dev.inmo.tgbotapi.extensions.utils.types.buttons.*
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -23,7 +24,10 @@ fun slotMachineReplyMarkup(
} }
else -> listOf(CallbackDataInlineKeyboardButton("$first$second$third", "$first$second$third")) else -> listOf(CallbackDataInlineKeyboardButton("$first$second$third", "$first$second$third"))
} }
return InlineKeyboardMarkup( return inlineKeyboard {
texts.chunked(2) texts.chunked(2).forEach { add(it) }
) // row {
// dataButton("Cancel (Admins only)", "cancel")
// }
}
} }

View File

@ -146,7 +146,9 @@ data class SlotMachineCaptchaProvider(
val clicked = arrayOf<String?>(null, null, null) val clicked = arrayOf<String?>(null, null, null)
while (leftToClick.isNotEmpty()) { while (leftToClick.isNotEmpty()) {
val userClicked = waitMessageDataCallbackQuery().filter { it.user.id == user.id && it.message.messageId == sentDice.messageId }.first() val userClicked = waitMessageDataCallbackQuery().filter { it.user.id == user.id && it.message.messageId == sentDice.messageId }.first()
if (userClicked.data == leftToClick.first()) {
when {
userClicked.data == leftToClick.first() -> {
clicked[3 - leftToClick.size] = leftToClick.removeAt(0) clicked[3 - leftToClick.size] = leftToClick.removeAt(0)
if (clicked.contains(null)) { if (clicked.contains(null)) {
safelyWithoutExceptions { answerCallbackQuery(userClicked, "Ok, next one") } safelyWithoutExceptions { answerCallbackQuery(userClicked, "Ok, next one") }
@ -156,8 +158,8 @@ data class SlotMachineCaptchaProvider(
safelyWithoutExceptions { deleteMessage(sentMessage) } safelyWithoutExceptions { deleteMessage(sentMessage) }
safelyWithoutExceptions { deleteMessage(sentDice) } safelyWithoutExceptions { deleteMessage(sentDice) }
} }
} else { }
safelyWithoutExceptions { answerCallbackQuery(userClicked, "Nope") } else -> safelyWithoutExceptions { answerCallbackQuery(userClicked, "Nope") }
} }
} }
authorized.send(user) authorized.send(user)
@ -378,12 +380,9 @@ data class ExpressionCaptchaProvider(
if (passed == null) { if (passed == null) {
removeRedundantMessages() removeRedundantMessages()
passed = it passed = it
if (it) { when {
safelyWithoutExceptions { restrictChatMember(chat, user, permissions = leftRestrictionsPermissions) } it -> safelyWithoutExceptions { restrictChatMember(chat, user, permissions = leftRestrictionsPermissions) }
} else { kickOnUnsuccess -> banUser(chat, user, leftRestrictionsPermissions)
if (kickOnUnsuccess) {
banUser(chat, user, leftRestrictionsPermissions)
}
} }
} }
} }