-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (33 loc) · 963 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
42
43
package main
import (
"log"
"os"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"github.com/joho/godotenv"
"github.com/kiasaty/phrase-mate/internal/app"
"github.com/kiasaty/phrase-mate/internal/database"
)
func main() {
if err := godotenv.Load(); err != nil {
log.Fatalf("Failed to load the .env file: %v", err)
}
databaseDSN := os.Getenv("DATABASE_DSN")
if databaseDSN == "" {
log.Fatalf("DATABASE_DSN not set in .env file!")
}
databaseClient, err := database.NewDatabaseClient(databaseDSN)
if err != nil {
log.Fatalf("Failed to create the database client: %v", err)
}
botToken := os.Getenv("TELEGRAM_BOT_TOKEN")
if botToken == "" {
log.Fatalf("TELEGRAM_BOT_TOKEN not set in .env file!")
}
bot, err := tgbotapi.NewBotAPI(botToken)
if err != nil {
log.Fatalf("Failed to create Telegram bot: %v", err)
}
config := app.GetDefaultConfig()
app := app.NewApp(databaseClient, bot, config)
app.HandleCommand()
}