menu

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package menu implements functionality of a telegram menu.

Index

Constants

This section is empty.

Variables

View Source
var (
	RootViewCallback     = "/"
	CreateButtonCallback = "/create"

	ShapesViewCallback   = "/shape"
	ShapesButtonCallback = fmt.Sprintf("%s/([0-8])", ShapesViewCallback)

	IterViewCallback   = "/iter"
	IterButtonCallback = fmt.Sprintf("%s/([0-9]+)", IterViewCallback)
	IterInputCallback  = "/iter/input"

	RepViewCallback   = "/rep"
	RepButtonCallback = fmt.Sprintf("%s/([1-6])", RepViewCallback)

	AlphaViewCallback   = "/alpha"
	AlphaButtonCallback = fmt.Sprintf("%s/([0-9]+)", AlphaViewCallback)
	AlphaInputCallback  = "/alpha/input"

	ExtViewCallback   = "/ext"
	ExtButtonCallback = fmt.Sprintf("%s/(jpg|png|svg|gif)", ExtViewCallback)

	SizeViewCallback   = "/size"
	SizeButtonCallback = fmt.Sprintf("%s/([0-9]+)", SizeViewCallback)
	SizeInputCallback  = "/size/input"
)

Callbacks that are sent by menu buttons.

View Source
var (
	OtherButtonText string
)

Text of buttons in the menu.

View Source
var ShapeNames map[primitive.Shape]string

ShapeNames contains mapping of shapes to their string representation.

Functions

func InitText

func InitText(p *message.Printer)

InitText initializes all global variables that contain text and also keyboard and view templates.

Types

type Menu struct {
	RootView   View
	ShapesView View
	IterView   View
	RepView    View
	AlphaView  View
	ExtView    View
	SizeView   View
}

Menu represents menu made of View instances.

func New

func New(c primitive.Config) Menu

New initializes instance of Menu.

type View

type View struct {
	Text     string
	Keyboard tg.InlineKeyboardMarkup
}

View represents menu 'window' that is made with the telegram's inline keyboard.

var (
	RootViewTmpl   View
	ShapesViewTmpl View
	IterViewTmpl   View
	RepViewTmpl    View
	AlphaViewTmpl  View
	ExtViewTmpl    View
	SizeViewTmpl   View
)

Templates for the different menu views.

func NewMenuView

func NewMenuView(
	template View,
	selectedCallback string,
	newButtonText ...string,
) View

NewMenuView creates new View from the template. The second parameter specifies callback of the option that is selected in the moment. Selected option will be marked with the special symbol. Optional parameter allows to specify new text for the button.

Jump to

Keyboard shortcuts

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