update
This commit is contained in:
+2
-1
@@ -13,4 +13,5 @@ dwz
|
||||
replies
|
||||
qinglongs
|
||||
sets.conf
|
||||
_*
|
||||
_*
|
||||
*.exe
|
||||
+5
-1
@@ -5,6 +5,7 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
@@ -14,6 +15,9 @@ import (
|
||||
var c *cron.Cron
|
||||
|
||||
func init() {
|
||||
if runtime.GOOS != "windows" {
|
||||
pname = regexp.MustCompile(`/([^/\s]+)$`).FindStringSubmatch(os.Args[0])[1]
|
||||
}
|
||||
c = cron.New()
|
||||
c.Start()
|
||||
}
|
||||
@@ -26,7 +30,7 @@ type Function struct {
|
||||
Cron string
|
||||
}
|
||||
|
||||
var pname = regexp.MustCompile(`/([^/\s]+)$`).FindStringSubmatch(os.Args[0])[1]
|
||||
var pname = ""
|
||||
|
||||
var name = func() string {
|
||||
return sillyGirl.Get("name", "傻妞")
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
initStore()
|
||||
ReadYaml(ExecPath+"/conf/", &Config, "https://raw.githubusercontent.com/cdle/sillyGirl/main/conf/demo_config.yaml")
|
||||
ReadYaml("conf/", &Config, "https://raw.githubusercontent.com/cdle/sillyGirl/main/conf/demo_config.yaml")
|
||||
InitReplies()
|
||||
initToHandleMessage()
|
||||
file, err := os.Open("/etc/sillyGirl/sets.conf")
|
||||
|
||||
+4
-3
@@ -27,9 +27,10 @@ func init() {
|
||||
var OttoFuncs = map[string]func(string) string{}
|
||||
|
||||
func init123() {
|
||||
files, err := ioutil.ReadDir(ExecPath + "/develop/replies")
|
||||
files, err := ioutil.ReadDir("develop/replies")
|
||||
if err != nil {
|
||||
logs.Warn("打开文件夹%s错误,%v", ExecPath+"/develop/replies", err)
|
||||
os.MkdirAll("develop/replies", os.ModePerm)
|
||||
// logs.Warn("打开文件夹%s错误,%v", "develop/replies", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -114,7 +115,7 @@ func init123() {
|
||||
if v.IsDir() {
|
||||
continue
|
||||
}
|
||||
jr := string(ExecPath + "/develop/replies/" + v.Name())
|
||||
jr := string("develop/replies/" + v.Name())
|
||||
data := ""
|
||||
if strings.Contains(jr, "http") {
|
||||
data, err = httplib.Get(jr).String()
|
||||
|
||||
+6
-4
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strconv"
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
@@ -23,11 +24,12 @@ 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 runtime.GOOS != "windows" {
|
||||
db, err = bolt.Open("/etc/sillyGirl/sillyGirl.cache", 0600, nil)
|
||||
} else {
|
||||
db, err = bolt.Open(`C:\ProgramData\sillyGirl.cache`, 0600, nil)
|
||||
}
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -58,6 +59,9 @@ func initSys() {
|
||||
Cron: "*/1 * * * *",
|
||||
Admin: true,
|
||||
Handle: func(s Sender) interface{} {
|
||||
if runtime.GOOS == "windows" {
|
||||
return "windows系统不支持此命令"
|
||||
}
|
||||
if s.GetImType() == "fake" && !sillyGirl.GetBool("auto_update", true) {
|
||||
return nil
|
||||
}
|
||||
|
||||
+1
-1
@@ -283,7 +283,7 @@ func start() {
|
||||
core.GroupPushs["qq"] = func(i, _ interface{}, s string) {
|
||||
paths := []string{}
|
||||
for _, v := range regexp.MustCompile(`\[TG:image,file=([^\[\]]+)\]`).FindAllStringSubmatch(s, -1) {
|
||||
paths = append(paths, core.ExecPath+"/data/images/"+v[1])
|
||||
paths = append(paths, "data/images/"+v[1])
|
||||
s = strings.Replace(s, fmt.Sprintf(`[TG:image,file=%s]`, v[1]), "", -1)
|
||||
}
|
||||
imgs := []message.IMessageElement{}
|
||||
|
||||
+10
-7
@@ -64,8 +64,7 @@ func init() {
|
||||
Token: token,
|
||||
Poller: &tb.LongPoller{Timeout: 10 * time.Second},
|
||||
// ParseMode: tb.ModeMarkdownV2,
|
||||
URL: tg.Get("url"),
|
||||
|
||||
URL: tg.Get("url"),
|
||||
}
|
||||
if url := tg.Get("http_proxy"); url != "" {
|
||||
client, clientErr := buildClientWithProxy(url)
|
||||
@@ -89,7 +88,7 @@ func init() {
|
||||
paths := []string{}
|
||||
ct := &tb.Chat{ID: core.Int64(i)}
|
||||
for _, v := range regexp.MustCompile(`\[CQ:image,file=([^\[\]]+)\]`).FindAllStringSubmatch(s, -1) {
|
||||
paths = append(paths, core.ExecPath+"/data/images/"+v[1])
|
||||
paths = append(paths, "data/images/"+v[1])
|
||||
s = strings.Replace(s, fmt.Sprintf(`[CQ:image,file=%s]`, v[1]), "", -1)
|
||||
}
|
||||
s = regexp.MustCompile(`\[CQ:([^\[\]]+)\]`).ReplaceAllString(s, "")
|
||||
@@ -133,7 +132,7 @@ func init() {
|
||||
}
|
||||
b.Handle(tb.OnPhoto, func(m *tb.Message) {
|
||||
filename := fmt.Sprint(time.Now().UnixNano()) + ".image"
|
||||
filepath := core.ExecPath + "/data/images/" + filename
|
||||
filepath := "data/images/" + filename
|
||||
if b.Download(&m.Photo.File, filepath) == nil {
|
||||
m.Text = fmt.Sprintf(`[TG:image,file=%s]`, filename) + m.Caption
|
||||
Handler(m)
|
||||
@@ -154,7 +153,7 @@ func init() {
|
||||
// return
|
||||
// }
|
||||
// filename := fmt.Sprint(time.Now().UnixNano()) + ".image"
|
||||
// filepath := core.ExecPath + "/data/images/" + filename
|
||||
// filepath := "data/images/" + filename
|
||||
// f, err := os.Create(filepath)
|
||||
// if err != nil {
|
||||
// return
|
||||
@@ -179,7 +178,11 @@ func (sender *Sender) GetUserID() interface{} {
|
||||
}
|
||||
|
||||
func (sender *Sender) GetChatID() interface{} {
|
||||
return int(sender.Message.Chat.ID)
|
||||
if sender.Message.Private() {
|
||||
return 0
|
||||
} else {
|
||||
return int(sender.Message.Chat.ID)
|
||||
}
|
||||
}
|
||||
|
||||
func (sender *Sender) GetImType() string {
|
||||
@@ -284,7 +287,7 @@ func (sender *Sender) Reply(msgs ...interface{}) (int, error) {
|
||||
sender.Reply(err)
|
||||
return 0, nil
|
||||
} else {
|
||||
rts,err := b.SendAlbum(r, tb.Album{&tb.Photo{File: tb.FromReader(f)}}, options...)
|
||||
rts, err := b.SendAlbum(r, tb.Album{&tb.Photo{File: tb.FromReader(f)}}, options...)
|
||||
if err == nil {
|
||||
rt = &rts[0]
|
||||
}
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ func init() {
|
||||
}
|
||||
for _, v := range regexp.MustCompile(`\[CQ:image,file=([^\[\]]+)\]`).FindAllStringSubmatch(s, -1) {
|
||||
s = strings.Replace(s, fmt.Sprintf(`[CQ:image,file=%s]`, v[1]), "", -1)
|
||||
data, err := os.ReadFile(core.ExecPath + "/data/images/" + v[1])
|
||||
data, err := os.ReadFile("data/images/" + v[1])
|
||||
if err == nil {
|
||||
add := regexp.MustCompile("(https.*)").FindString(string(data))
|
||||
if add != "" {
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ var u2i = core.NewBucket("wxmpu2i")
|
||||
var material = core.NewBucket("wxmpMaterial")
|
||||
|
||||
func init() {
|
||||
file_dir := core.ExecPath + "/logs/wxmp/"
|
||||
file_dir := "logs/wxmp/"
|
||||
os.MkdirAll(file_dir, os.ModePerm)
|
||||
core.Server.Any("/wx/", func(c *gin.Context) {
|
||||
wc := wechat.NewWechat()
|
||||
|
||||
Reference in New Issue
Block a user