update
This commit is contained in:
+13
-1
@@ -1,10 +1,12 @@
|
||||
package qq
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -274,6 +276,16 @@ func start() {
|
||||
bot.SendPrivateMessage(int64(i), int64(qq.GetInt("tempMessageGroupCode")), &message.SendingMessage{Elements: bot.ConvertStringMessage(s, false)})
|
||||
}
|
||||
core.GroupPushs["qq"] = func(i, j int, s string) {
|
||||
bot.SendGroupMessage(int64(i), &message.SendingMessage{Elements: bot.ConvertStringMessage(s, true)}) //&message.AtElement{Target: int64(j)}
|
||||
paths := []string{}
|
||||
for _, v := range regexp.MustCompile(`\[TG:image,file=([^\[\]]+)\]`).FindAllStringSubmatch(s, -1) {
|
||||
paths = append(paths, core.ExecPath+"/data/images/"+v[1])
|
||||
s = strings.Replace(s, fmt.Sprintf(`[TG:image,file=%s]`, v[1]), "", -1)
|
||||
}
|
||||
imgs := []message.IMessageElement{}
|
||||
for _, path := range paths {
|
||||
imgs = append(imgs, &coolq.LocalImageElement{Stream: bytes.NewReader([]byte(path))})
|
||||
}
|
||||
//
|
||||
bot.SendGroupMessage(int64(i), &message.SendingMessage{Elements: append(bot.ConvertStringMessage(s, true), imgs...)}) //&message.AtElement{Target: int64(j)}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-9
@@ -1,7 +1,6 @@
|
||||
package tg
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
@@ -91,6 +90,7 @@ func init() {
|
||||
// is = append(is, i)
|
||||
// }
|
||||
i := &tb.Photo{File: tb.FromURL(url)}
|
||||
|
||||
if index == 0 {
|
||||
i.Caption = s
|
||||
}
|
||||
@@ -104,18 +104,20 @@ func init() {
|
||||
b.Send(ct, s)
|
||||
}
|
||||
b.Handle(tb.OnPhoto, func(m *tb.Message) {
|
||||
data, _ := json.Marshal(m.Photo)
|
||||
filename := fmt.Sprint(time.Now().UnixNano()) + ".image"
|
||||
filepath := core.ExecPath + "/data/images/" + filename
|
||||
if b.Download(&m.Photo.File, filepath) == nil {
|
||||
|
||||
}
|
||||
// data, _ := json.Marshal(m.Photo)
|
||||
// b.Send(m.Chat, )
|
||||
fmt.Println(string(data))
|
||||
// fmt.Println(string(data))
|
||||
// m.
|
||||
// b.Send(m.Chat, m.Caption+" "+m.AlbumID)
|
||||
// b.Download()
|
||||
|
||||
// b.Download(&m.Photo.File,"")
|
||||
// m.Text = fmt.Sprintf(`[CQ:image,url=%s]`, m.Photo.FileURL) + m.Caption
|
||||
// m.Photo.FileReader.
|
||||
// core.NotifyMasters(fmt.Sprintf(`[CQ:image,url=%s]`, m.Photo.FileURL) + m.Caption)
|
||||
// Handler(m)
|
||||
m.Text = fmt.Sprintf(`[TG:image,file=%s]`, filename) + m.Caption
|
||||
core.NotifyMasters(m.Text)
|
||||
Handler(m)
|
||||
// b.Forward(m.Chat, m)
|
||||
})
|
||||
b.Handle(tb.OnText, Handler)
|
||||
|
||||
Reference in New Issue
Block a user