2023-08-10 15:49:25 +03:00
|
|
|
package tx
|
2023-07-09 01:28:59 +03:00
|
|
|
|
|
|
|
// Implementing the intereface lets you
|
|
|
|
// provide behaviour for the buttons etc.
|
|
|
|
type Action interface {
|
2023-07-12 00:33:51 +03:00
|
|
|
Act(*Context)
|
2023-07-09 01:28:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Customized action for the bot.
|
2023-08-10 15:49:25 +03:00
|
|
|
type ActionFunc func(*Context)
|
2023-07-09 01:28:59 +03:00
|
|
|
|
|
|
|
// The type implements changing screen to the underlying ScreenId
|
|
|
|
type ScreenChange ScreenId
|
|
|
|
|
|
|
|
func (sc ScreenChange) Act(c *Context) {
|
2023-08-10 15:49:25 +03:00
|
|
|
if !c.B.ScreenExist(ScreenId(sc)) {
|
|
|
|
panic(ScreenNotExistErr)
|
|
|
|
}
|
2023-07-12 14:06:05 +03:00
|
|
|
err := c.ChangeScreen(ScreenId(sc))
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2023-07-09 01:28:59 +03:00
|
|
|
}
|
|
|
|
|
2023-08-10 15:49:25 +03:00
|
|
|
func (af ActionFunc) Act(c *Context) {
|
|
|
|
af(c)
|
2023-07-09 01:28:59 +03:00
|
|
|
}
|