butler/cmd/butler/main.go

43 lines
982 B
Go

package main
import (
"context"
"os"
"github.com/joho/godotenv"
"git.3crabs.ru/VLADIMIR/butler/internal/modules/messenger/telegram"
"git.3crabs.ru/VLADIMIR/butler/internal/modules/storage/postgres"
"git.3crabs.ru/VLADIMIR/butler/internal/services/bot"
"git.3crabs.ru/VLADIMIR/butler/internal/services/bot/bot_all"
"git.3crabs.ru/VLADIMIR/butler/internal/services/listener"
)
func main() {
if err := godotenv.Load(); err != nil {
panic(err)
}
telegarmToken := os.Getenv("TELEGRAM_TOKEN")
messengerTelegram, err := telegram.NewMessengerTelegram(telegarmToken)
if err != nil {
panic(err)
}
postgresUrlConnect := os.Getenv("POSTGRES_URL_CONNECT")
storage, err := postgres.NewStoragePostgres(postgresUrlConnect)
if err != nil {
panic(err)
}
defer storage.Close()
listenerService := listener.NewListener(
messengerTelegram,
[]bot.IBot{
bot_all.NewBotAll(messengerTelegram, storage),
},
)
ctx := context.Background()
listenerService.Run(ctx)
}