com.github.stormbit.vksdk.objects.keyboard.ButtonsBuilder.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vk-bot-sdk-kotlin Show documentation
Show all versions of vk-bot-sdk-kotlin Show documentation
The Kotlin library for working with VK api
The newest version!
package com.github.stormbit.vksdk.objects.keyboard
import com.github.stormbit.vksdk.objects.models.Keyboard
import com.github.stormbit.vksdk.objects.models.Keyboard.Button.*
import com.github.stormbit.vksdk.objects.models.MessagePayload
import com.github.stormbit.vksdk.vkapi.ContextDsl
import java.io.Serializable
import java.util.*
@Suppress("unused")
@ContextDsl
class ButtonsBuilder : Serializable {
private var buttons = ArrayList()
fun primaryButton(label: String, payload: MessagePayload = MessagePayload(""), type: Action.Type = Action.Type.TEXT): ButtonsBuilder {
addButton(label, payload, ButtonColor.PRIMARY, type)
return this
}
fun defaultButton(label: String, payload: MessagePayload = MessagePayload(""), type: Action.Type = Action.Type.TEXT): ButtonsBuilder {
addButton(label, payload, ButtonColor.DEFAULT, type)
return this
}
fun positiveButton(label: String, payload: MessagePayload = MessagePayload(""), type: Action.Type = Action.Type.TEXT): ButtonsBuilder {
addButton(label, payload, ButtonColor.POSITIVE, type)
return this
}
fun negativeButton(label: String, payload: MessagePayload = MessagePayload(""), type: Action.Type = Action.Type.TEXT): ButtonsBuilder {
addButton(label, payload, ButtonColor.NEGATIVE, type)
return this
}
private fun addButton(label: String, payload: MessagePayload, color: ButtonColor, type: Action.Type) {
buttons.add(Keyboard.Button(
color = color,
action = Action(
type = type,
label = label,
payload = payload
)
))
}
fun getButtons(): ArrayList {
return buttons
}
fun setButtons(buttons: ArrayList) {
this.buttons = buttons
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy