From e375170567575b2fc585910f47e19f197f655c35 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 18 May 2022 14:27:29 +0600 Subject: [PATCH] removing deprecations --- .../dev/inmo/plagubot/plugins/captcha/Plugin.kt | 6 ++---- .../plugins/captcha/provider/CaptchaProvider.kt | 14 +++++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/dev/inmo/plagubot/plugins/captcha/Plugin.kt b/src/main/kotlin/dev/inmo/plagubot/plugins/captcha/Plugin.kt index 01d7e64..1d6ae09 100644 --- a/src/main/kotlin/dev/inmo/plagubot/plugins/captcha/Plugin.kt +++ b/src/main/kotlin/dev/inmo/plagubot/plugins/captcha/Plugin.kt @@ -18,15 +18,13 @@ import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams import dev.inmo.tgbotapi.extensions.utils.extensions.sourceChat import dev.inmo.tgbotapi.libraries.cache.admins.* import dev.inmo.tgbotapi.types.BotCommand -import dev.inmo.tgbotapi.types.chat.RestrictionsChatPermissions -import dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedGroupChat +import dev.inmo.tgbotapi.types.chat.* import kotlinx.coroutines.* import kotlinx.serialization.Serializable import kotlinx.serialization.json.JsonObject import org.jetbrains.exposed.sql.Database import org.koin.core.Koin 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 disableAutoDeleteCommands = "captcha_auto_delete_commands_off" @@ -132,7 +130,7 @@ class CaptchaBotPlugin : Plugin { } val defaultChatPermissions = (getChat(it.chat) as ExtendedGroupChat).permissions - doInSubContext(stopOnCompletion = false) { + createSubContextAndDoWithUpdatesFilter(stopOnCompletion = false) { launch { settings.captchaProvider.apply { doAction(it.date, chat, newUsers, defaultChatPermissions) } } diff --git a/src/main/kotlin/dev/inmo/plagubot/plugins/captcha/provider/CaptchaProvider.kt b/src/main/kotlin/dev/inmo/plagubot/plugins/captcha/provider/CaptchaProvider.kt index 14d0daa..0c2d90b 100644 --- a/src/main/kotlin/dev/inmo/plagubot/plugins/captcha/provider/CaptchaProvider.kt +++ b/src/main/kotlin/dev/inmo/plagubot/plugins/captcha/provider/CaptchaProvider.kt @@ -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.requests.DeleteMessage 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.chat.ChatPermissions -import dev.inmo.tgbotapi.types.chat.LeftRestrictionsChatPermissions -import dev.inmo.tgbotapi.types.chat.abstracts.* +import dev.inmo.tgbotapi.types.chat.* +import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.types.dice.SlotMachineDiceAnimationType import dev.inmo.tgbotapi.types.message.abstracts.Message +import dev.inmo.tgbotapi.types.message.textsources.mention import kotlinx.coroutines.* import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.toList @@ -94,12 +94,12 @@ data class SlotMachineCaptchaProvider( val authorized = Channel(newUsers.size) val messagesToDelete = Channel(Channel.UNLIMITED) val subContexts = newUsers.map { - doInSubContext(stopOnCompletion = false) { + createSubContextAndDoWithUpdatesFilter (stopOnCompletion = false) { val sentMessage = sendTextMessage( chat, buildEntities { +it.mention(it.firstName) - regular(", ${captchaText}") + regular(", $captchaText") } ).also { messagesToDelete.send(it) } val sentDice = sendDice( @@ -182,7 +182,7 @@ data class SimpleCaptchaProvider( newUsers.mapNotNull { safelyWithoutExceptions { launch { - doInSubContext(stopOnCompletion = false) { + createSubContextAndDoWithUpdatesFilter(stopOnCompletion = false) { val callbackData = uuid4().toString() val sentMessage = sendTextMessage( chat, @@ -294,7 +294,7 @@ data class ExpressionCaptchaProvider( val userBanDateTime = eventDateTime + checkTimeSpan newUsers.map { user -> launch { - doInSubContext { + createSubContextAndDoWithUpdatesFilter { val callbackData = ExpressionBuilder.createExpression( maxPerNumber, operations