All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.vendeli.tgbot.api.chat.SetChatPermissions.kt Maven / Gradle / Ivy

There is a newer version: 6.6.0
Show newest version
@file:Suppress("MatchingDeclarationName")

package eu.vendeli.tgbot.api.chat

import eu.vendeli.tgbot.interfaces.Action
import eu.vendeli.tgbot.interfaces.ActionState
import eu.vendeli.tgbot.interfaces.TgAction
import eu.vendeli.tgbot.types.chat.ChatPermissions
import eu.vendeli.tgbot.types.internal.TgMethod
import eu.vendeli.tgbot.utils.getReturnType

class SetChatPermissionsAction(
    permissions: ChatPermissions,
    useIndependentChatPermissions: Boolean? = null,
) : Action, ActionState() {
    override val TgAction.method: TgMethod
        get() = TgMethod("setChatPermissions")
    override val TgAction.returnType: Class
        get() = getReturnType()

    init {
        parameters["permissions"] = permissions
        if (useIndependentChatPermissions != null)
            parameters["use_independent_chat_permissions"] = useIndependentChatPermissions
    }
}

fun setChatPermissions(
    permissions: ChatPermissions,
    useIndependentChatPermissions: Boolean? = null,
) = SetChatPermissionsAction(permissions, useIndependentChatPermissions)

fun setChatPermissions(
    useIndependentChatPermissions: Boolean? = null,
    permissions: ChatPermissions.() -> Unit,
) = SetChatPermissionsAction(ChatPermissions().apply(permissions), useIndependentChatPermissions)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy