keyboard

package
v0.0.0-...-3c8687b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxButtonsOnLine = 5
	MaxDefaultLines  = 10
	MaxInlineLines   = 6
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Type    string         `json:"type"`
	Payload vkapi.JSONData `json:"payload,omitempty"`
	Label   string         `json:"label,omitempty"`
	Link    string         `json:"link,omitempty"`
	Hash    string         `json:"hash,omitempty"`
	AppID   int            `json:"app_id,omitempty"`
	OwnerID int            `json:"owner_id,omitempty"`
}

Action type.

type Button

type Button struct {
	Color  Color  `json:"color,omitempty"`
	Action Action `json:"action"`
}

Button type.

type Color

type Color string

Color type.

const (
	// Blue
	ColorPrimary Color = "primary"
	// White
	ColorSecondary Color = "secondary"
	// Red
	ColorNegative Color = "negative"
	// Green
	ColorPositive Color = "positive"
)

type Keyboard

type Keyboard struct {
	Buttons [][]Button `json:"buttons"`
	OneTime bool       `json:"one_time"`
	Inline  bool       `json:"inline"`
}

Keyboard struct.

func Empty

func Empty() *Keyboard

Empty creates empty keyboard to remove an existing.

func New

func New(oneTime bool, inline bool) *Keyboard

New creates new keyboard.

func (*Keyboard) AddCallback

func (k *Keyboard) AddCallback(label string, color Color, payload vkapi.JSONData) bool

AddCallback adds a callback text button to the last row.

func (*Keyboard) AddLocation

func (k *Keyboard) AddLocation(payload vkapi.JSONData) bool

AddLocation adds a location button to the last row.

func (*Keyboard) AddOpenApp

func (k *Keyboard) AddOpenApp(appID, ownerID int, hash string) bool

AddOpenApp adds a button with link to the vkapp to the last row.

func (k *Keyboard) AddOpenLink(label string, link string) bool

AddOpenLink adds a button with external link to the last row.

func (*Keyboard) AddText

func (k *Keyboard) AddText(label string, color Color, payload vkapi.JSONData) bool

AddText adds a text button to the last row.

func (*Keyboard) AddVkPay

func (k *Keyboard) AddVkPay(hash string) bool

AddVkPay adds a VKPay button to the last row.

func (*Keyboard) Data

func (k *Keyboard) Data() vkapi.JSONData

Data converts the keyboard into a sandable object.

func (*Keyboard) NextRow

func (k *Keyboard) NextRow() bool

NextRow adds line of buttons.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL