From 57611764ae610703dc9e4db4c552e6942ae65a21 Mon Sep 17 00:00:00 2001 From: cdle <798731886@qq.com> Date: Fri, 17 Sep 2021 07:10:14 +0800 Subject: [PATCH] update --- core/config.go | 12 ------------ core/init.go | 17 +++++++++++++++++ core/store.go | 2 +- core/test.go | 2 +- 4 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 core/init.go diff --git a/core/config.go b/core/config.go index 7a31caf..e62f3ba 100644 --- a/core/config.go +++ b/core/config.go @@ -21,18 +21,6 @@ var ExecPath, _ = filepath.Abs(filepath.Dir(os.Args[0])) var Config Yaml -func init() { - killp() - for _, arg := range os.Args { - if arg == "-d" { - Daemon() - } - } - ReadYaml(ExecPath+"/conf/", &Config, "https://raw.githubusercontent.com/cdle/sillyGirl/main/conf/demo_config.yaml") - InitReplies() - initToHandleMessage() -} - func ReadYaml(confDir string, conf interface{}, url string) { path := confDir + "config.yaml" if _, err := os.Stat(confDir); err != nil { diff --git a/core/init.go b/core/init.go new file mode 100644 index 0000000..eab7bb3 --- /dev/null +++ b/core/init.go @@ -0,0 +1,17 @@ +package core + +import "os" + +func init() { + initStore() + killp() + for _, arg := range os.Args { + if arg == "-d" { + Daemon() + } + } + ReadYaml(ExecPath+"/conf/", &Config, "https://raw.githubusercontent.com/cdle/sillyGirl/main/conf/demo_config.yaml") + InitReplies() + initToHandleMessage() + initSys() +} diff --git a/core/store.go b/core/store.go index 34b64f3..58a69de 100644 --- a/core/store.go +++ b/core/store.go @@ -20,7 +20,7 @@ func NewBucket(name string) Bucket { return b } -func init() { +func initStore() { var err error db, err = bolt.Open(ExecPath+"/sillyGirl.cache", 0600, nil) if err != nil { diff --git a/core/test.go b/core/test.go index 4aff93a..418f412 100644 --- a/core/test.go +++ b/core/test.go @@ -7,7 +7,7 @@ import ( "github.com/cdle/sillyGirl/im" ) -func init() { +func initSys() { AddCommand("", []Function{ { Rules: []string{"raw ^name$"},