1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-07 20:45:53 +08:00

fix env conf load.

This commit is contained in:
Mrs4s 2021-09-15 13:43:39 +08:00
parent bfea93312a
commit 449ae96c8f
No known key found for this signature in database
GPG Key ID: 3186E98FA19CE3A7

View File

@ -161,6 +161,7 @@ func Get() *Config {
os.Exit(0)
}
if hasEnvironmentConf {
// type convert tools
toInt64 := func(str string) int64 {
i, _ := strconv.ParseInt(str, 10, 64)
@ -175,7 +176,9 @@ func Get() *Config {
global.SetAtDefault(&config.Account.ReLogin.Delay, uint(toInt64(os.Getenv("GCQ_RELOGIN_DELAY"))), uint(0))
global.SetAtDefault(&config.Account.ReLogin.MaxTimes, uint(toInt64(os.Getenv("GCQ_RELOGIN_MAX_TIMES"))), uint(0))
dbConf := &LevelDBConfig{Enable: global.EnsureBool(os.Getenv("GCQ_LEVELDB"), true)}
if config.Database == nil {
config.Database = make(map[string]yaml.Node)
}
config.Database["leveldb"] = func() yaml.Node {
n := &yaml.Node{}
_ = n.Encode(dbConf)
@ -232,6 +235,7 @@ func Get() *Config {
_ = node.Encode(rwsConf)
config.Servers = append(config.Servers, map[string]yaml.Node{"ws-reverse": *node})
}
}
})
return config
}