Skip to content

Commit 369364b

Browse files
author
Syfaro
committed
Merge pull request #44 from jqs7/master
simplify append loop
2 parents ab63d49 + b98d5c9 commit 369364b

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

helpers.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,8 @@ func NewEditMessageCaption(chatID int64, messageID int, caption string) EditMess
421421
func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup InlineKeyboardMarkup) EditMessageReplyMarkupConfig {
422422
return EditMessageReplyMarkupConfig{
423423
BaseEdit: BaseEdit{
424-
ChatID: chatID,
425-
MessageID: messageID,
424+
ChatID: chatID,
425+
MessageID: messageID,
426426
ReplyMarkup: &replyMarkup,
427427
},
428428
}
@@ -466,9 +466,7 @@ func NewKeyboardButtonLocation(text string) KeyboardButton {
466466
func NewKeyboardButtonRow(buttons ...KeyboardButton) []KeyboardButton {
467467
var row []KeyboardButton
468468

469-
for _, button := range buttons {
470-
row = append(row, button)
471-
}
469+
row = append(row, buttons...)
472470

473471
return row
474472
}
@@ -477,9 +475,7 @@ func NewKeyboardButtonRow(buttons ...KeyboardButton) []KeyboardButton {
477475
func NewReplyKeyboard(rows ...[]KeyboardButton) ReplyKeyboardMarkup {
478476
var keyboard [][]KeyboardButton
479477

480-
for _, row := range rows {
481-
keyboard = append(keyboard, row)
482-
}
478+
keyboard = append(keyboard, rows...)
483479

484480
return ReplyKeyboardMarkup{
485481
ResizeKeyboard: true,
@@ -518,9 +514,7 @@ func NewInlineKeyboardButtonSwitch(text, sw string) InlineKeyboardButton {
518514
func NewInlineKeyboardRow(buttons ...InlineKeyboardButton) []InlineKeyboardButton {
519515
var row []InlineKeyboardButton
520516

521-
for _, button := range buttons {
522-
row = append(row, button)
523-
}
517+
row = append(row, buttons...)
524518

525519
return row
526520
}
@@ -529,9 +523,7 @@ func NewInlineKeyboardRow(buttons ...InlineKeyboardButton) []InlineKeyboardButto
529523
func NewInlineKeyboardMarkup(rows ...[]InlineKeyboardButton) InlineKeyboardMarkup {
530524
var keyboard [][]InlineKeyboardButton
531525

532-
for _, row := range rows {
533-
keyboard = append(keyboard, row)
534-
}
526+
keyboard = append(keyboard, rows...)
535527

536528
return InlineKeyboardMarkup{
537529
InlineKeyboard: keyboard,

0 commit comments

Comments
 (0)