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
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.InlineKeyboardMarkup
@ -23,7 +24,10 @@ fun slotMachineReplyMarkup(
}
else -> listOf(CallbackDataInlineKeyboardButton("$first$second$third", "$first$second$third"))
}
return InlineKeyboardMarkup(
texts.chunked(2)
)
return inlineKeyboard {
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)
while (leftToClick.isNotEmpty()) {
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)
if (clicked.contains(null)) {
safelyWithoutExceptions { answerCallbackQuery(userClicked, "Ok, next one") }
@ -156,8 +158,8 @@ data class SlotMachineCaptchaProvider(
safelyWithoutExceptions { deleteMessage(sentMessage) }
safelyWithoutExceptions { deleteMessage(sentDice) }
}
} else {
safelyWithoutExceptions { answerCallbackQuery(userClicked, "Nope") }
}
else -> safelyWithoutExceptions { answerCallbackQuery(userClicked, "Nope") }
}
}
authorized.send(user)
@ -378,12 +380,9 @@ data class ExpressionCaptchaProvider(
if (passed == null) {
removeRedundantMessages()
passed = it
if (it) {
safelyWithoutExceptions { restrictChatMember(chat, user, permissions = leftRestrictionsPermissions) }
} else {
if (kickOnUnsuccess) {
banUser(chat, user, leftRestrictionsPermissions)
}
when {
it -> safelyWithoutExceptions { restrictChatMember(chat, user, permissions = leftRestrictionsPermissions) }
kickOnUnsuccess -> banUser(chat, user, leftRestrictionsPermissions)
}
}
}