mirror of
https://github.com/InsanusMokrassar/CaptchaPlaguBotPlugin.git
synced 2024-11-25 11:38:55 +00:00
fixes
This commit is contained in:
parent
f1093d6944
commit
d8dbb2512f
@ -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")
|
||||||
|
// }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,18 +146,20 @@ 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()) {
|
|
||||||
clicked[3 - leftToClick.size] = leftToClick.removeAt(0)
|
when {
|
||||||
if (clicked.contains(null)) {
|
userClicked.data == leftToClick.first() -> {
|
||||||
safelyWithoutExceptions { answerCallbackQuery(userClicked, "Ok, next one") }
|
clicked[3 - leftToClick.size] = leftToClick.removeAt(0)
|
||||||
editMessageReplyMarkup(sentDice, slotMachineReplyMarkup(clicked[0], clicked[1], clicked[2]))
|
if (clicked.contains(null)) {
|
||||||
} else {
|
safelyWithoutExceptions { answerCallbackQuery(userClicked, "Ok, next one") }
|
||||||
safelyWithoutExceptions { answerCallbackQuery(userClicked, "Thank you and welcome", showAlert = true) }
|
editMessageReplyMarkup(sentDice, slotMachineReplyMarkup(clicked[0], clicked[1], clicked[2]))
|
||||||
safelyWithoutExceptions { deleteMessage(sentMessage) }
|
} else {
|
||||||
safelyWithoutExceptions { deleteMessage(sentDice) }
|
safelyWithoutExceptions { answerCallbackQuery(userClicked, "Thank you and welcome", showAlert = true) }
|
||||||
|
safelyWithoutExceptions { deleteMessage(sentMessage) }
|
||||||
|
safelyWithoutExceptions { deleteMessage(sentDice) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
else -> safelyWithoutExceptions { answerCallbackQuery(userClicked, "Nope") }
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user