-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (38 loc) · 922 Bytes
/
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
package main
import (
"context"
"log"
"os"
"os/signal"
"syscall"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load(".env")
if err != nil {
log.Fatal("Error loading .env file")
}
store, err := NewPostgresStore()
if err != nil {
log.Printf("[ERROR] failed to connect to db: %v", err)
return
}
defer store.db.Close()
bot, err := NewBot(store)
if err != nil {
log.Printf("[ERROR] failed to create botAPI: %v", err)
return
}
bot.RegisterNewCommand("register", RegisterNewAccount)
bot.RegisterNewCommand("delete", DeleteAccount)
bot.RegisterNewCommand("addTeam", AddTeamToFavourite)
bot.RegisterNewCommand("deleteTeam", DeleteTeamFromFavourite)
bot.RegisterNewCommand("ng", GetNearestGame)
// bot.api.Debug = true
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer cancel()
err = bot.Run(ctx)
if err != nil {
log.Fatal(err)
}
}