update
This commit is contained in:
+2
-1
@@ -9,4 +9,5 @@ develop/jd_cookie
|
|||||||
jd_wskey
|
jd_wskey
|
||||||
logs/*
|
logs/*
|
||||||
jd_*
|
jd_*
|
||||||
data
|
data
|
||||||
|
sets.conf
|
||||||
@@ -1,14 +1,8 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/astaxie/beego/logs"
|
|
||||||
"github.com/beego/beego/v2/adapter/httplib"
|
|
||||||
"gopkg.in/yaml.v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Yaml struct {
|
type Yaml struct {
|
||||||
@@ -18,33 +12,3 @@ type Yaml struct {
|
|||||||
var ExecPath, _ = filepath.Abs(filepath.Dir(os.Args[0]))
|
var ExecPath, _ = filepath.Abs(filepath.Dir(os.Args[0]))
|
||||||
|
|
||||||
var Config Yaml
|
var Config Yaml
|
||||||
|
|
||||||
func ReadYaml(confDir string, conf interface{}, url string) {
|
|
||||||
path := confDir + "config.yaml"
|
|
||||||
if _, err := os.Stat(confDir); err != nil {
|
|
||||||
os.MkdirAll(confDir, os.ModePerm)
|
|
||||||
}
|
|
||||||
f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0777)
|
|
||||||
if err != nil {
|
|
||||||
logs.Warn(err)
|
|
||||||
}
|
|
||||||
s, _ := ioutil.ReadAll(f)
|
|
||||||
if len(s) == 0 {
|
|
||||||
logs.Info("下载配置%s", url)
|
|
||||||
r, err := httplib.Get("https://ghproxy.com/" + url).Response()
|
|
||||||
if err == nil {
|
|
||||||
io.Copy(f, r.Body)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
f.Close()
|
|
||||||
content, err := ioutil.ReadFile(path)
|
|
||||||
if err != nil {
|
|
||||||
logs.Warn("解析配置文件%s读取错误: %v", path, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if yaml.Unmarshal(content, conf) != nil {
|
|
||||||
logs.Warn("解析配置文件%s出错: %v", path, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
logs.Info("解析配置文件%s", path)
|
|
||||||
}
|
|
||||||
|
|||||||
+16
-2
@@ -1,7 +1,9 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,9 +18,21 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
initStore()
|
initStore()
|
||||||
ReadYaml(ExecPath+"/conf/", &Config, "https://raw.githubusercontent.com/cdle/sillyGirl/main/conf/demo_config.yaml")
|
|
||||||
InitReplies()
|
|
||||||
initToHandleMessage()
|
initToHandleMessage()
|
||||||
|
InitReplies()
|
||||||
|
file, err := os.Open(ExecPath + "/conf/sets.conf")
|
||||||
|
if err == nil {
|
||||||
|
scanner := bufio.NewScanner(file)
|
||||||
|
for scanner.Scan() {
|
||||||
|
line := scanner.Text()
|
||||||
|
if regexp.MustCompile(`^set`).MatchString(line) {
|
||||||
|
Senders <- &Faker{
|
||||||
|
Message: line,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file.Close()
|
||||||
|
}
|
||||||
initSys()
|
initSys()
|
||||||
Duration = time.Duration(sillyGirl.GetInt("duration", 5)) * time.Second
|
Duration = time.Duration(sillyGirl.GetInt("duration", 5)) * time.Second
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ func init() {
|
|||||||
Admin: true,
|
Admin: true,
|
||||||
Cron: "*/5 * * * *",
|
Cron: "*/5 * * * *",
|
||||||
Handle: func(s core.Sender) interface{} {
|
Handle: func(s core.Sender) interface{} {
|
||||||
if s.GetImType() == "fake" && qinglong.Get("autoCronHideDuplicate", "true") == "false" {
|
if s.GetImType() == "fake" && qinglong.GetBool("autoCronHideDuplicate", true) == false {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
w := func(s string) int {
|
w := func(s string) int {
|
||||||
|
|||||||
Reference in New Issue
Block a user