From f38a752fa5aaa97abff8bc2d7fa89576a74481fd Mon Sep 17 00:00:00 2001 From: cdle <798731886@qq.com> Date: Sun, 26 Sep 2021 20:12:06 +0800 Subject: [PATCH] update --- core/init.go | 1 + core/store.go | 4 ---- core/sys.go | 2 ++ core/test.go | 12 ++++++++++++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/core/init.go b/core/init.go index 9b254b1..1eb8f7d 100644 --- a/core/init.go +++ b/core/init.go @@ -41,4 +41,5 @@ func init() { } initSys() Duration = time.Duration(sillyGirl.GetInt("duration", 5)) * time.Second + sillyGirl.Set("started_at", time.Now().Format("2006-01-02 15:04:05")) } diff --git a/core/store.go b/core/store.go index c92bffe..786bf3c 100644 --- a/core/store.go +++ b/core/store.go @@ -2,7 +2,6 @@ package core import ( "fmt" - "os" "strconv" "github.com/boltdb/bolt" @@ -22,9 +21,6 @@ func NewBucket(name string) Bucket { } func initStore() { - if _, err := os.Stat(ExecPath + "/sillyGirl.cache"); err == nil { - os.Rename(ExecPath+"/sillyGirl.cache", "/etc/sillyGirl/sillyGirl.cache") - } var err error db, err = bolt.Open("/etc/sillyGirl/sillyGirl.cache", 0600, nil) if err != nil { diff --git a/core/sys.go b/core/sys.go index d827f01..25d7f10 100644 --- a/core/sys.go +++ b/core/sys.go @@ -8,6 +8,7 @@ import ( "regexp" "runtime" "strings" + "time" "github.com/astaxie/beego/logs" ) @@ -55,6 +56,7 @@ func CompileCode() error { if err != nil { return errors.New("编译失败:" + err.Error() + "。") } + sillyGirl.Set("compiled_at", time.Now().Format("2006-01-02 15:04:05")) return nil } diff --git a/core/test.go b/core/test.go index 293fbd2..376bc55 100644 --- a/core/test.go +++ b/core/test.go @@ -182,6 +182,18 @@ func initSys() { return fmt.Sprint(s.GetUserID()) }, }, + { + Rules: []string{"raw ^compiled_at$"}, + Handle: func(s Sender) interface{} { + return sillyGirl.Get("compiled_at") + }, + }, + { + Rules: []string{"raw ^started_at$"}, + Handle: func(s Sender) interface{} { + return sillyGirl.Get("started_at") + }, + }, }) }