diff --git a/src/behx/context.go b/src/behx/context.go index 011271d..2300569 100644 --- a/src/behx/context.go +++ b/src/behx/context.go @@ -2,7 +2,7 @@ package behx import ( apix "github.com/go-telegram-bot-api/telegram-bot-api/v5" - "fmt" + //"fmt" ) // The type represents way to interact with user in @@ -20,10 +20,10 @@ func (ctx *Context) handleUpdateChan(updates chan *Update) { for u := range updates { screen := bot.Screens[session.CurrentScreenId] - kbd := bot.Keyboards[screen.KeyboardId] - btns := kbd.buttonMap() - if u.Message != nil { + + kbd := bot.Keyboards[screen.KeyboardId] + btns := kbd.buttonMap() text := u.Message.Text btn, ok := btns[text] @@ -35,11 +35,16 @@ func (ctx *Context) handleUpdateChan(updates chan *Update) { btn.Action.Act(ctx) } else if u.CallbackQuery != nil { cb := apix.NewCallback(u.CallbackQuery.ID, u.CallbackQuery.Data) + data := u.CallbackQuery.Data _, err := bot.Request(cb) if err != nil { panic(err) } + kbd := bot.Keyboards[screen.InlineKeyboardId] + btns := kbd.buttonMap() + btn := btns[data] + btn.Action.Act(ctx) } } } diff --git a/src/cmd/test/main.go b/src/cmd/test/main.go index 1cd1bbb..8c92736 100644 --- a/src/cmd/test/main.go +++ b/src/cmd/test/main.go @@ -47,9 +47,10 @@ var inlineKbd = behx.NewKeyboard( })), ), behx.NewButtonRow( - behx.NewButton("INLINE PRESS ME 3", behx.NewCustomAction(func(c *behx.Context){ - log.Println("INLINE pressed third button!") - })), + behx.NewButton( + "INLINE PRESS ME 3", + behx.ScreenChange("second"), + ), ), )