This commit is contained in:
cdle
2021-10-19 22:43:05 +08:00
parent 852665999e
commit e797ce1c74
10 changed files with 35 additions and 20 deletions
+1 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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()