-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
76 lines (66 loc) · 2.13 KB
/
main.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package main
import (
"github.com/stefanitsky/gachinator-telegram-bot/app"
"github.com/stefanitsky/gachinator-telegram-bot/handlers"
"github.com/stefanitsky/gachinator-telegram-bot/menu"
"github.com/stefanitsky/gachinator-telegram-bot/translations"
tele "gopkg.in/telebot.v3"
)
var (
application *app.App
)
func main() {
application = app.NewApp()
defer application.CloseAllConnections()
startHandler := handlers.Handler{
Endpoint: "/start",
HandlerFunc: handlers.StartHandler,
SuccessHandleLog: handlers.SuccessHandleLog{
Message: "user invoked /start command",
EventAction: "cmd-start",
},
ExtraContext: handlers.ExtraContext{"db": application.DB},
}
selectLangHandler := handlers.Handler{
Endpoint: "/lang",
HandlerFunc: handlers.SelectLangHandler,
SuccessHandleLog: handlers.SuccessHandleLog{
Message: "user invoked /lang command",
EventAction: "cmd-lang",
},
ExtraContext: handlers.ExtraContext{"db": application.DB},
}
textHandler := handlers.Handler{
Endpoint: tele.OnText,
HandlerFunc: handlers.OnTextHandler,
SuccessHandleLog: handlers.SuccessHandleLog{
Message: "gachinator is used",
EventAction: "gachinator",
},
ExtraContext: handlers.ExtraContext{"db": application.DB},
}
enChangeLangHandler := handlers.Handler{
Endpoint: &menu.EnBtn,
HandlerFunc: handlers.ChangeLangHandler,
SuccessHandleLog: handlers.SuccessHandleLog{
Message: "language changed to english",
EventAction: "menu-lang-en",
},
ExtraContext: handlers.ExtraContext{"db": application.DB, "lc": translations.English},
}
ruChangeLangHandler := handlers.Handler{
Endpoint: &menu.RuBtn,
HandlerFunc: handlers.ChangeLangHandler,
SuccessHandleLog: handlers.SuccessHandleLog{
Message: "language changed to russian",
EventAction: "menu-lang-ru",
},
ExtraContext: handlers.ExtraContext{"db": application.DB, "lc": translations.Russian},
}
application.AddHandler(startHandler)
application.AddHandler(selectLangHandler)
application.AddHandler(textHandler)
application.AddHandler(enChangeLangHandler)
application.AddHandler(ruChangeLangHandler)
application.Start()
}