This commit is contained in:
cdle
2021-09-26 20:12:06 +08:00
parent 2127e79e98
commit f38a752fa5
4 changed files with 15 additions and 4 deletions
+1
View File
@@ -41,4 +41,5 @@ func init() {
} }
initSys() initSys()
Duration = time.Duration(sillyGirl.GetInt("duration", 5)) * time.Second Duration = time.Duration(sillyGirl.GetInt("duration", 5)) * time.Second
sillyGirl.Set("started_at", time.Now().Format("2006-01-02 15:04:05"))
} }
-4
View File
@@ -2,7 +2,6 @@ package core
import ( import (
"fmt" "fmt"
"os"
"strconv" "strconv"
"github.com/boltdb/bolt" "github.com/boltdb/bolt"
@@ -22,9 +21,6 @@ func NewBucket(name string) Bucket {
} }
func initStore() { func initStore() {
if _, err := os.Stat(ExecPath + "/sillyGirl.cache"); err == nil {
os.Rename(ExecPath+"/sillyGirl.cache", "/etc/sillyGirl/sillyGirl.cache")
}
var err error var err error
db, err = bolt.Open("/etc/sillyGirl/sillyGirl.cache", 0600, nil) db, err = bolt.Open("/etc/sillyGirl/sillyGirl.cache", 0600, nil)
if err != nil { if err != nil {
+2
View File
@@ -8,6 +8,7 @@ import (
"regexp" "regexp"
"runtime" "runtime"
"strings" "strings"
"time"
"github.com/astaxie/beego/logs" "github.com/astaxie/beego/logs"
) )
@@ -55,6 +56,7 @@ func CompileCode() error {
if err != nil { if err != nil {
return errors.New("编译失败:" + err.Error() + "。") return errors.New("编译失败:" + err.Error() + "。")
} }
sillyGirl.Set("compiled_at", time.Now().Format("2006-01-02 15:04:05"))
return nil return nil
} }
+12
View File
@@ -182,6 +182,18 @@ func initSys() {
return fmt.Sprint(s.GetUserID()) 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")
},
},
}) })
} }