-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler.go
36 lines (31 loc) · 1.05 KB
/
handler.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
36
package main
import (
tb "gopkg.in/tucnak/telebot.v2"
)
// setupHandlers setup all bot handlers
func setupHandlers() {
// Handle commands
bot.Handle("/start", startCommandHandler)
// Handle buttons
bot.Handle(startMatchBtn, startMatchHandler)
bot.Handle(numCardsBtn4, func(m *tb.Message) {
selectNumCardsHandler(4, m.Sender)
})
bot.Handle(numCardsBtn5, func(m *tb.Message) {
selectNumCardsHandler(5, m.Sender)
})
bot.Handle(selectCardBtn, selectCardHandler)
bot.Handle(addNumberCardBtn, addNumberCardHandler)
bot.Handle(selectNumberCardBtn, selectNumberCardHandler)
bot.Handle(addColorCardBtn, addColorCardHandler)
bot.Handle(selectColorCardBtn, selectColorCardHandler)
bot.Handle(removeInfoBtn, removeInfoCardHandler)
bot.Handle(continueMatchBtn, func(m *tb.Message) {
matches[m.Sender.ID].ShowCards(m.Sender)
})
}
// selectNumCardsHandler setup match cards according to the number of cards entered
func selectNumCardsHandler(numCards int, sender *tb.User) {
matches[sender.ID] = newMatch(bot, numCards)
matches[sender.ID].ShowCards(sender)
}