/
pick_hours.go
35 lines (28 loc) · 1.12 KB
/
pick_hours.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package processor
import (
"context"
"fmt"
tgBotAPI "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"github.com/olezhek28/system-design-party-bot/internal/helper"
"github.com/olezhek28/system-design-party-bot/internal/model"
"github.com/olezhek28/system-design-party-bot/internal/model/command"
"github.com/pkg/errors"
)
func (s *Service) PickHour(ctx context.Context, msg *model.TelegramMessage) (tgBotAPI.MessageConfig, error) {
if len(msg.Arguments) < 7 {
return tgBotAPI.MessageConfig{}, errors.New("no arguments")
}
reply := tgBotAPI.NewMessage(msg.From.ID, fmt.Sprintf("%s И наконец минута\n", model.GetEmoji(model.ThingsEmojis)))
reply.ReplyMarkup = getPickMinuteKeyboard(msg.Arguments)
return reply, nil
}
func getPickMinuteKeyboard(args []string) tgBotAPI.InlineKeyboardMarkup {
var buttonsInfo []*model.TelegramButtonInfo
for _, m := range helper.GetMinutes() {
buttonsInfo = append(buttonsInfo, &model.TelegramButtonInfo{
Text: fmt.Sprintf("%d", m),
Data: fmt.Sprintf("/%s %d %s", command.PickMin, m, helper.SliceToString(args)),
})
}
return helper.BuildKeyboard(buttonsInfo, 3)
}