log middleware
This commit is contained in:
38
main.go
38
main.go
@@ -2,25 +2,39 @@ package main
|
||||
|
||||
import (
|
||||
"kurumibot/database"
|
||||
"kurumibot/database/psql"
|
||||
"kurumibot/laniakea"
|
||||
"kurumibot/plugins"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"kurumibot/laniakea"
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
database.Connect()
|
||||
bot := laniakea.NewBot(&laniakea.BotSettings{
|
||||
Token: os.Getenv("TG_TOKEN"),
|
||||
Debug: true,
|
||||
Prefixes: laniakea.LoadPrefixesFromEnv(),
|
||||
UseRequestLogger: true,
|
||||
LoggerBasePath: "./logs/",
|
||||
})
|
||||
log.Println(os.Getenv("PSQL_NAME"))
|
||||
log.Println(os.Getenv("PREFIXES"))
|
||||
err := godotenv.Load(".env", ".env.production")
|
||||
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.AddMiddleware(plugins.InitLogMiddleware())
|
||||
|
||||
plugins.RegisterEconomy(bot)
|
||||
plugins.RegisterWaifus(bot)
|
||||
plugins.RegisterAdmin(bot)
|
||||
|
||||
Reference in New Issue
Block a user