mirror of
https://github.com/InsanusMokrassar/CaptchaPlaguBotPlugin.git
synced 2024-11-25 11:38:55 +00:00
fixes after update
This commit is contained in:
parent
317db251b9
commit
8017678da8
@ -19,11 +19,14 @@ 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.RestrictionsChatPermissions
|
||||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
|
||||||
import dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedGroupChat
|
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 org.jetbrains.exposed.sql.Database
|
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 enableAutoDeleteCommands = "captcha_auto_delete_commands_on"
|
||||||
private const val disableAutoDeleteCommands = "captcha_auto_delete_commands_off"
|
private const val disableAutoDeleteCommands = "captcha_auto_delete_commands_off"
|
||||||
@ -46,59 +49,61 @@ private val changeCaptchaMethodCommandRegex = Regex(
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
class CaptchaBotPlugin : Plugin {
|
class CaptchaBotPlugin : Plugin {
|
||||||
override suspend fun getCommands(): List<BotCommand> = listOf(
|
// override suspend fun getCommands(): List<BotCommand> = listOf(
|
||||||
BotCommand(
|
// BotCommand(
|
||||||
enableAutoDeleteCommands,
|
// enableAutoDeleteCommands,
|
||||||
"Enable auto removing of commands addressed to captcha plugin"
|
// "Enable auto removing of commands addressed to captcha plugin"
|
||||||
),
|
// ),
|
||||||
BotCommand(
|
// BotCommand(
|
||||||
disableAutoDeleteCommands,
|
// disableAutoDeleteCommands,
|
||||||
"Disable auto removing of commands addressed to captcha plugin"
|
// "Disable auto removing of commands addressed to captcha plugin"
|
||||||
),
|
// ),
|
||||||
BotCommand(
|
// BotCommand(
|
||||||
enableAutoDeleteServiceMessages,
|
// enableAutoDeleteServiceMessages,
|
||||||
"Enable auto removing of users joined messages"
|
// "Enable auto removing of users joined messages"
|
||||||
),
|
// ),
|
||||||
BotCommand(
|
// BotCommand(
|
||||||
disableAutoDeleteServiceMessages,
|
// disableAutoDeleteServiceMessages,
|
||||||
"Disable auto removing of users joined messages"
|
// "Disable auto removing of users joined messages"
|
||||||
),
|
// ),
|
||||||
BotCommand(
|
// BotCommand(
|
||||||
enableSlotMachineCaptcha,
|
// enableSlotMachineCaptcha,
|
||||||
"Change captcha method to slot machine"
|
// "Change captcha method to slot machine"
|
||||||
),
|
// ),
|
||||||
BotCommand(
|
// BotCommand(
|
||||||
enableSimpleCaptcha,
|
// enableSimpleCaptcha,
|
||||||
"Change captcha method to simple button"
|
// "Change captcha method to simple button"
|
||||||
),
|
// ),
|
||||||
BotCommand(
|
// BotCommand(
|
||||||
disableCaptcha,
|
// disableCaptcha,
|
||||||
"Disable captcha for chat"
|
// "Disable captcha for chat"
|
||||||
),
|
// ),
|
||||||
BotCommand(
|
// BotCommand(
|
||||||
enableCaptcha,
|
// enableCaptcha,
|
||||||
"Enable captcha for chat"
|
// "Enable captcha for chat"
|
||||||
),
|
// ),
|
||||||
BotCommand(
|
// BotCommand(
|
||||||
enableExpressionCaptcha,
|
// enableExpressionCaptcha,
|
||||||
"Change captcha method to expressions"
|
// "Change captcha method to expressions"
|
||||||
),
|
// ),
|
||||||
BotCommand(
|
// BotCommand(
|
||||||
enableKickOnUnsuccess,
|
// enableKickOnUnsuccess,
|
||||||
"Not solved captcha users will be kicked from the chat"
|
// "Not solved captcha users will be kicked from the chat"
|
||||||
),
|
// ),
|
||||||
BotCommand(
|
// BotCommand(
|
||||||
disableKickOnUnsuccess,
|
// disableKickOnUnsuccess,
|
||||||
"Not solved captcha users will NOT be kicked from the chat"
|
// "Not solved captcha users will NOT be kicked from the chat"
|
||||||
)
|
// )
|
||||||
)
|
// )
|
||||||
|
|
||||||
|
override fun Module.setupDI(database: Database, params: JsonObject) {
|
||||||
|
single { CaptchaChatsSettingsRepo(database) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun BehaviourContext.setupBotPlugin(koin: Koin) {
|
||||||
|
val repo: CaptchaChatsSettingsRepo by koin.inject()
|
||||||
|
val adminsAPI = koin.adminsPlugin ?.adminsAPI(koin.get())
|
||||||
|
|
||||||
override suspend fun BehaviourContext.invoke(
|
|
||||||
database: Database,
|
|
||||||
params: Map<String, Any>
|
|
||||||
) {
|
|
||||||
val repo = CaptchaChatsSettingsRepo(database)
|
|
||||||
val adminsAPI = params.adminsPlugin ?.adminsAPI(database)
|
|
||||||
suspend fun Chat.settings() = repo.getById(id) ?: repo.create(ChatSettings(id)).first()
|
suspend fun Chat.settings() = repo.getById(id) ?: repo.create(ChatSettings(id)).first()
|
||||||
|
|
||||||
onNewChatMembers(
|
onNewChatMembers(
|
||||||
|
Loading…
Reference in New Issue
Block a user