55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
package main
|
||
|
||
import (
|
||
"kurumibot/database"
|
||
"kurumibot/laniakea"
|
||
"kurumibot/plugins"
|
||
"log"
|
||
|
||
"github.com/joho/godotenv"
|
||
)
|
||
|
||
func main() {
|
||
err := godotenv.Load(".env", ".env.production", ".env.ai")
|
||
if err != nil {
|
||
log.Println("Error loading .env file")
|
||
}
|
||
|
||
database.ConnectPostgres()
|
||
database.ConnectMongo()
|
||
database.ConnectRedis()
|
||
//err = psql.Migrate()
|
||
//if err != nil {
|
||
// log.Fatalln(err)
|
||
//}
|
||
|
||
bot := laniakea.NewBot(laniakea.LoadSettingsFromEnv())
|
||
dbCtx := &laniakea.DatabaseContext{
|
||
PostgresSQL: database.PostgresDatabase,
|
||
MongoDB: database.MongoClient,
|
||
Redis: database.RedisClient,
|
||
}
|
||
bot = bot.ErrorTemplate("Во время выполнения команды произошла ошибка!\nСообщите об этом разработчику!\n\n%s")
|
||
bot = bot.InitDatabaseContext(dbCtx)
|
||
bot.AddDatabaseLogger(plugins.DatabaseLogger)
|
||
|
||
bot.AddMiddleware(plugins.InitLogMiddleware())
|
||
|
||
plugins.RegisterEconomy(bot)
|
||
plugins.RegisterWaifus(bot)
|
||
plugins.RegisterAdmin(bot)
|
||
plugins.RegisterTestRP(bot)
|
||
|
||
//ctx := context.Background()
|
||
//go func() {
|
||
// select {
|
||
// case <-ctx.Done():
|
||
// {
|
||
// log.Println("done")
|
||
// }
|
||
// }
|
||
//}()
|
||
defer bot.Close()
|
||
bot.Run()
|
||
}
|