template

package
v1.0.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LINK  = "open_link"
	PHOTO = "open_photo"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Type string `json:"type"`
	Link string `json:"link,omitempty"`
}

Action - 🌲 action when clicking on a carousel element 🌱 Type - action type. Available: open_link or open_photo 🌳 OpenLink opens a link, OpenPhoto opens a photo of the object 👩‍🌾 Link - link with the type «open_link». Important: not «open_photo».

type Description

type Description string

Description - 🍜 element description.

type Element

type Element struct {
	Title       string            `json:"title"`
	Description string            `json:"description"`
	PhotoID     string            `json:"photo_id"`
	Action      Action            `json:"action"`
	Buttons     *keyboard.Buttons `json:"buttons"`
}

Element 💐 is a carousel object that is displayed horizontally 🌈 Title - element header. Limited to 80 characters 🐰 Description - element description. Limited to 80 characters 🌷 PhotoID - VK photo ID format «#owner_id_#photo_id» 🐇 Action - the action that should happen when you click on the element 🐣 Buttons - pointer to the buttons from the «Keyboard» package, which are arranged vertically.

type Photo

type Photo string

Photo - ⛩️ VK photo ID format «#owner_id_#photo_id».

type PhotoID

type PhotoID string

PhotoID - 🦊 VK photo ID format «#owner_id_#photo_id».

type Template

type Template struct {
	Type     string    `json:"type"`
	Elements []Element `json:"elements"`
}

Template 🍂 presents VK API template objects ☠️ Type specifies the type of template to create. Available Type: «carousel» 🎃 Elements - the list of Element objects arranged horizontally in the carousel.

func New

func New(properties ...any) *Template

New 🌷 is responsible for creating the template 🌈 It takes String - type Template and optional type []Element 🌺 Returns a pointer to the Template object.

func NewCarousel

func NewCarousel(properties ...any) *Template

NewCarousel 🐸 creates a carousel object based on the Template structure 🍄 This is the easiest way to work with carousels 🌷 Does not require manual placement of elements, specifying the type, etc. 🌈 Pre-created elements can be used as arguments 🦌 Always returns a pointer to a Template object 🦋.

func (*Template) Action

func (template *Template) Action(properties ...any) *Template

Action - 🌴 method of creating an action with a template element 🏖️ Accepts the following arguments: 🍹 Action Structure 😎 String - 1: Type, 2: Link 🚎 And the custom types described in the String argument 🦩 Returns the modified pattern by setting the Action to the last element.

func (*Template) Add

func (template *Template) Add(element Element) *Template

Add append an element to the template Elements.

func (*Template) Buttons

func (template *Template) Buttons(properties ...any) *Template

Buttons - 🤡 add buttons to the last created carousel element 🍔 Accepts arguments: * Keyboard.Buttons 🍟 Returns the modified template.

func (*Template) Description

func (template *Template) Description(properties ...any) *Template

func (*Template) Element

func (template *Template) Element(properties ...any) *Template

Element - adding a new element to the template Accepted values: String - 1: Title, 2 - Description, 3 - PhotoID Element - element of the element to be added Action - action when clicking on the Action element keyboard.Buttons - vertical set of buttons *keyboard.Buttons - the same, but via the pointer Also available are custom types which are listed in the String argument Returns modified Template object with a new element.

func (*Template) JSON

func (template *Template) JSON() string

JSON 🍷🧣🍁 turns an object into a JSON format string.

func (*Template) Photo

func (template *Template) Photo(properties ...any) *Template

func (*Template) Title

func (template *Template) Title(properties ...any) *Template

type Title

type Title string

Title - 🍥 element header.

Jump to

Keyboard shortcuts

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