File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,12 @@ type Keyboard struct {
2020 btnsInRow int
2121}
2222
23- type KeyboardCommands map [BtnLabel ]func (m * tb.Message )
23+ type KeyboardCmd struct {
24+ Label BtnLabel
25+ Handler func (m * tb.Message )
26+ }
27+
28+ type KeyboardCommands []KeyboardCmd
2429
2530func NewKeyboard (b Boter , cmds KeyboardCommands , opts ... KbdOption ) * Keyboard {
2631 kbd := & Keyboard {
@@ -40,10 +45,10 @@ func (k *Keyboard) Markup(lang string) *tb.ReplyMarkup {
4045
4146 p := Printer (lang , k .lang )
4247 var btns []tb.Btn
43- for lbl , h := range k .cmds {
44- btn := m .Text (p .Sprintf (string (lbl )))
48+ for _ , kc := range k .cmds {
49+ btn := m .Text (p .Sprintf (string (kc . Label )))
4550 btns = append (btns , btn )
46- k .b .Handle (& btn , h )
51+ k .b .Handle (& btn , kc . Handler )
4752 }
4853 m .Reply (organizeButtons (btns , k .btnsInRow )... )
4954 return m
You can’t perform that action at this time.
0 commit comments