Skip to content

Commit 0a9a6dc

Browse files
committed
feat(buttons): add BuildReply method to finalize keyboard with options
1 parent e496cd8 commit 0a9a6dc

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

telegram/buttons.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,27 @@ func (kb *KeyboardBuilder) Build() *ReplyInlineMarkup {
7979
return &ReplyInlineMarkup{Rows: kb.rows}
8080
}
8181

82+
type BuildReplyOptions struct {
83+
ResizeKeyboard bool
84+
OneTime bool
85+
Selective bool
86+
Persistent bool
87+
Placeholder string
88+
}
89+
90+
// BuildReply finalizes the keyboard and returns the reply keyboard markup.
91+
func (kb *KeyboardBuilder) BuildReply(opts ...BuildReplyOptions) *ReplyKeyboardMarkup {
92+
opt := getVariadic(opts, BuildReplyOptions{})
93+
return &ReplyKeyboardMarkup{
94+
Resize: opt.ResizeKeyboard,
95+
SingleUse: opt.OneTime,
96+
Selective: opt.Selective,
97+
Placeholder: opt.Placeholder,
98+
Rows: kb.rows,
99+
Persistent: opt.Persistent,
100+
}
101+
}
102+
82103
func (ButtonBuilder) Text(text string) *KeyboardButtonObj {
83104
return &KeyboardButtonObj{Text: text}
84105
}

0 commit comments

Comments
 (0)