1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package tg
- // The type describes behaviour for the bot in personal chats.
- type Behaviour struct {
- Root Component
- Init Action
- //Screens ScreenMap
- }
- // Returns new empty behaviour.
- func NewBehaviour() *Behaviour {
- return &Behaviour{
- }
- }
- // The Action will be called on session creation,
- // not when starting or restarting the bot with the Start Action.
- func (b *Behaviour) SetInit(a Action) *Behaviour {
- b.Init = a
- return b
- }
- /*func (b *Behaviour) SetScreens(screens ScreenMap) *Behaviour {
- b.Screens = screens
- return b
- }
- // Sets the root node of the Behaviour.
- // Mostly used for commands and such stuff.
- func (b *Behaviour) SetRootNode(node *RootNode) *Behaviour {
- b.Screens = node.ScreenMap()
- return b
- }
- */
- // The function sets as the standard root widget CommandWidget
- // and its commands..
- func (b *Behaviour) SetRootWidget(root Component) *Behaviour {
- b.Root = root
- return b
- }
- /*
- // Check whether the screen exists in the behaviour.
- func (beh *Behaviour) PathExist(pth Path) bool {
- _, ok := beh.Screens[pth]
- return ok
- }
- // Returns the screen by it's ID.
- func (beh *Behaviour) GetScreen(pth Path) *Screen {
- if !beh.PathExist(pth) {
- panic(ScreenNotExistErr)
- }
- screen := beh.Screens[pth]
- return screen
- }
- */
|