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

eu.vendeli.tgbot.api.botactions.SetMyCommands.kt Maven / Gradle / Ivy

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

package eu.vendeli.tgbot.api.botactions

import eu.vendeli.tgbot.interfaces.ActionState
import eu.vendeli.tgbot.interfaces.SimpleAction
import eu.vendeli.tgbot.interfaces.TgAction
import eu.vendeli.tgbot.types.bot.BotCommand
import eu.vendeli.tgbot.types.bot.BotCommandScope
import eu.vendeli.tgbot.types.internal.TgMethod
import eu.vendeli.tgbot.utils.builders.BotCommandsBuilder
import eu.vendeli.tgbot.utils.getReturnType

class SetMyCommandsAction(
    commands: List,
    scope: BotCommandScope? = null,
    languageCode: String? = null,
) : SimpleAction, ActionState() {
    override val TgAction.method: TgMethod
        get() = TgMethod("setMyCommands")
    override val TgAction.returnType: Class
        get() = getReturnType()

    init {
        parameters["commands"] = commands
        if (scope != null) parameters["scope"] = scope
        if (languageCode != null) parameters["language_code"] = languageCode
    }
}

fun setMyCommands(languageCode: String? = null, scope: BotCommandScope? = null, vararg command: BotCommand) =
    SetMyCommandsAction(listOf(*command), scope, languageCode)

fun setMyCommands(languageCode: String? = null, scope: BotCommandScope? = null, block: BotCommandsBuilder.() -> Unit) =
    SetMyCommandsAction(BotCommandsBuilder().apply(block).commandsList, scope, languageCode)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy