feat: set dir for storages

This commit is contained in:
krau
2025-02-25 16:17:20 +08:00
parent d6f8603656
commit 9e776b22fb
18 changed files with 443 additions and 189 deletions

View File

@@ -1,20 +1,24 @@
package cmd
import (
"fmt"
"os"
"os/signal"
"path/filepath"
"syscall"
"github.com/krau/SaveAny-Bot/bootstrap"
"github.com/krau/SaveAny-Bot/bot"
"github.com/krau/SaveAny-Bot/common"
"github.com/krau/SaveAny-Bot/config"
"github.com/krau/SaveAny-Bot/core"
"github.com/krau/SaveAny-Bot/dao"
"github.com/krau/SaveAny-Bot/logger"
"github.com/krau/SaveAny-Bot/storage"
"github.com/spf13/cobra"
)
func Run(_ *cobra.Command, _ []string) {
bootstrap.InitAll()
InitAll()
core.Run()
quit := make(chan os.Signal, 1)
@@ -49,3 +53,16 @@ func Run(_ *cobra.Command, _ []string) {
}
}
}
func InitAll() {
if err := config.Init(); err != nil {
fmt.Println("加载配置文件失败: ", err)
os.Exit(1)
}
logger.InitLogger()
logger.L.Info("正在启动 SaveAny-Bot...")
dao.Init()
storage.LoadStorages()
common.Init()
bot.Init()
}