interact: add AddMultipleButtons function

This commit is contained in:
Andy Cheng 2022-03-23 12:04:47 +08:00
parent 5eef2a2085
commit e122c12eef
No known key found for this signature in database
GPG Key ID: 936427CF651A9D28
3 changed files with 15 additions and 0 deletions

View File

@ -38,6 +38,9 @@ type Reply interface {
// AddButton adds the button to the reply
AddButton(text string, name, value string)
// AddMultipleButtons adds multiple buttons to the reply
AddMultipleButtons(buttonsForm [][3]string)
// Choose(prompt string, options ...Option)
// Confirm shows the confirm dialog or confirm button in the user interface
// Confirm(prompt string)

View File

@ -68,6 +68,12 @@ func (reply *SlackReply) AddButton(text string, name string, value string) {
})
}
func (reply *SlackReply) AddMultipleButtons(buttonsForm [][3]string) {
for _, buttonForm := range buttonsForm {
reply.AddButton(buttonForm[0], buttonForm[1], buttonForm[2])
}
}
func (reply *SlackReply) build() interface{} {
// you should avoid using this modal view request, because it interrupts the interaction flow
// once we send the modal view request, we can't go back to the channel.

View File

@ -81,6 +81,12 @@ func (r *TelegramReply) AddButton(text string, name string, value string) {
r.set = true
}
func (r *TelegramReply) AddMultipleButtons(buttonsForm [][3]string) {
for _, buttonForm := range buttonsForm {
r.AddButton(buttonForm[0], buttonForm[1], buttonForm[2])
}
}
func (r *TelegramReply) build() {
var rows []telebot.Row
for _, button := range r.buttons {