removing deprecations

This commit is contained in:
InsanusMokrassar 2022-05-18 14:27:29 +06:00
parent 8017678da8
commit e375170567
2 changed files with 9 additions and 11 deletions

View File

@ -18,15 +18,13 @@ import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams
import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat
import dev.inmo.tgbotapi.libraries.cache.admins.* import dev.inmo.tgbotapi.libraries.cache.admins.*
import dev.inmo.tgbotapi.types.BotCommand import dev.inmo.tgbotapi.types.BotCommand
import dev.inmo.tgbotapi.types.chat.RestrictionsChatPermissions import dev.inmo.tgbotapi.types.chat.*
import dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedGroupChat
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonObject
import org.jetbrains.exposed.sql.Database import org.jetbrains.exposed.sql.Database
import org.koin.core.Koin import org.koin.core.Koin
import org.koin.core.module.Module import org.koin.core.module.Module
import dev.inmo.tgbotapi.types.chat.Chat
private const val enableAutoDeleteCommands = "captcha_auto_delete_commands_on" private const val enableAutoDeleteCommands = "captcha_auto_delete_commands_on"
private const val disableAutoDeleteCommands = "captcha_auto_delete_commands_off" private const val disableAutoDeleteCommands = "captcha_auto_delete_commands_off"
@ -132,7 +130,7 @@ class CaptchaBotPlugin : Plugin {
} }
val defaultChatPermissions = (getChat(it.chat) as ExtendedGroupChat).permissions val defaultChatPermissions = (getChat(it.chat) as ExtendedGroupChat).permissions
doInSubContext(stopOnCompletion = false) { createSubContextAndDoWithUpdatesFilter(stopOnCompletion = false) {
launch { launch {
settings.captchaProvider.apply { doAction(it.date, chat, newUsers, defaultChatPermissions) } settings.captchaProvider.apply { doAction(it.date, chat, newUsers, defaultChatPermissions) }
} }

View File

@ -21,13 +21,13 @@ import dev.inmo.tgbotapi.extensions.utils.shortcuts.executeUnsafe
import dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.requests.DeleteMessage import dev.inmo.tgbotapi.requests.DeleteMessage
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.MessageEntity.textsources.mention
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton
import dev.inmo.tgbotapi.types.chat.ChatPermissions import dev.inmo.tgbotapi.types.chat.ChatPermissions
import dev.inmo.tgbotapi.types.chat.LeftRestrictionsChatPermissions import dev.inmo.tgbotapi.types.chat.*
import dev.inmo.tgbotapi.types.chat.abstracts.* import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.dice.SlotMachineDiceAnimationType import dev.inmo.tgbotapi.types.dice.SlotMachineDiceAnimationType
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.textsources.mention
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.toList import kotlinx.coroutines.channels.toList
@ -94,12 +94,12 @@ data class SlotMachineCaptchaProvider(
val authorized = Channel<User>(newUsers.size) val authorized = Channel<User>(newUsers.size)
val messagesToDelete = Channel<Message>(Channel.UNLIMITED) val messagesToDelete = Channel<Message>(Channel.UNLIMITED)
val subContexts = newUsers.map { val subContexts = newUsers.map {
doInSubContext(stopOnCompletion = false) { createSubContextAndDoWithUpdatesFilter (stopOnCompletion = false) {
val sentMessage = sendTextMessage( val sentMessage = sendTextMessage(
chat, chat,
buildEntities { buildEntities {
+it.mention(it.firstName) +it.mention(it.firstName)
regular(", ${captchaText}") regular(", $captchaText")
} }
).also { messagesToDelete.send(it) } ).also { messagesToDelete.send(it) }
val sentDice = sendDice( val sentDice = sendDice(
@ -182,7 +182,7 @@ data class SimpleCaptchaProvider(
newUsers.mapNotNull { newUsers.mapNotNull {
safelyWithoutExceptions { safelyWithoutExceptions {
launch { launch {
doInSubContext(stopOnCompletion = false) { createSubContextAndDoWithUpdatesFilter(stopOnCompletion = false) {
val callbackData = uuid4().toString() val callbackData = uuid4().toString()
val sentMessage = sendTextMessage( val sentMessage = sendTextMessage(
chat, chat,
@ -294,7 +294,7 @@ data class ExpressionCaptchaProvider(
val userBanDateTime = eventDateTime + checkTimeSpan val userBanDateTime = eventDateTime + checkTimeSpan
newUsers.map { user -> newUsers.map { user ->
launch { launch {
doInSubContext { createSubContextAndDoWithUpdatesFilter {
val callbackData = ExpressionBuilder.createExpression( val callbackData = ExpressionBuilder.createExpression(
maxPerNumber, maxPerNumber,
operations operations