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