Documentation ¶
Index ¶
- Constants
- type Callback
- type Dialog
- type Menu
- func (f *Menu) Build(lang string) *Menu
- func (f *Menu) CountNodes() int
- func (f *Menu) GetBot() *tb.Bot
- func (f *Menu) GetDialog(id string) (*Dialog, bool)
- func (f *Menu) GetId() string
- func (f *Menu) GetRoot() *Node
- func (f *Menu) HandleBack(e *Node, c *tb.Callback) int
- func (f *Menu) HandleForward(e *Node, c *tb.Callback) int
- func (f *Menu) MoveTo(to tb.Recipient, text, lang string, position *Node) error
- func (f *Menu) NewBackNode(text string) *Node
- func (f *Menu) NewNode(text string, endpoint Callback) *Node
- func (f *Menu) SetCaption(recipient tb.Recipient, text string, params ...interface{}) *Menu
- func (f *Menu) Start(to tb.Recipient, text, lang string) error
- func (f *Menu) StartAt(to tb.Recipient, text, lang string, at *Node) error
- func (f *Menu) Stop(to tb.Recipient, text, lang string) error
- type Node
- func (e *Node) Add(text string, endpoint Callback) *Node
- func (e *Node) AddManySub(elements []*Node) *Node
- func (e *Node) AddSub(text string, endpoint Callback) *Node
- func (e *Node) AddWith(text string, endpoint Callback, elements ...*Node) *Node
- func (e *Node) GetEndpoint() Callback
- func (e *Node) GetFlow() *Menu
- func (e *Node) GetId() string
- func (e *Node) GetLanguage(c *tb.Callback) string
- func (e *Node) GetMarkup(lang string) *tb.ReplyMarkup
- func (e *Node) GetNodes() []*Node
- func (e *Node) GetPath() string
- func (e *Node) GetText() string
- func (e *Node) Previous() *Node
- func (e *Node) SetCaption(c *tb.Callback, text string, params ...interface{}) *Node
- func (e *Node) SetLanguage(c *tb.Callback, lang string) *Node
Constants ¶
const ( Stay = 0 Forward = 1 Back = -1 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dialog ¶
A dialog is an abstract piece that holds a menu message sent by the bot and a language that the interface is displayed
type Menu ¶
type Menu struct {
// contains filtered or unexported fields
}
A flow is essentially a high-level representation of a menu
func NewMenuFlow ¶
Creates a new flow and initializes the specified locale directory Warning! When setting a id treat it gently, like picking a directory name, same rules applies. It will fail without a notice if you put special characters or symbols (except for underscore) in it. Suggested names: flow1, flow_1, MyFlow
func (*Menu) HandleBack ¶
Helper handler for back buttons
func (*Menu) HandleForward ¶
Helper handler for forward buttons
func (*Menu) NewBackNode ¶
Creates a new back button node in the flow that automatically takes a user one page back
func (*Menu) SetCaption ¶
Sets a new caption for the menu The caption will be updated right away Params are automatically placed in the text if provided
func (*Menu) Start ¶
Sends a new instance of a menu to a user with a specified locale Tries to delete the old menu before sending a new one
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
An element of a menu that holds all required information by a page a.k.a a button that holds other buttons for the next page
func (*Node) AddManySub ¶
Adds many new sub nodes Returns the current node
func (*Node) AddWith ¶
Adds a new node with many sub-nodes to the current node Returns the current node
func (*Node) GetLanguage ¶
Gets a language currently used in a dialog by the user
func (*Node) GetMarkup ¶
func (e *Node) GetMarkup(lang string) *tb.ReplyMarkup
Get a markups in a specified language Caution! Menu must be built for the specified language beforehand
func (*Node) SetCaption ¶
Sets a new caption for the flow that will be updated in the next menu iteration params are automatically placed in the text if provided