This commit is contained in:
cdle
2021-10-07 08:45:54 +08:00
parent cb6a769986
commit 7bd3eb46a2
+12 -5
View File
@@ -64,6 +64,7 @@ func init() {
paths = append(paths, core.ExecPath+"/data/images/"+v[1]) paths = append(paths, core.ExecPath+"/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, "")
{ {
t := []string{} t := []string{}
for _, v := range strings.Split(s, "\n") { for _, v := range strings.Split(s, "\n") {
@@ -80,9 +81,15 @@ func init() {
if err == nil { if err == nil {
url := regexp.MustCompile("(https.*)").FindString(string(data)) url := regexp.MustCompile("(https.*)").FindString(string(data))
if url != "" { if url != "" {
rsp, err := httplib.Get(url).Response() // rsp, err := httplib.Get(url).Response()
if err == nil { // if err == nil {
i := &tb.Photo{File: tb.FromReader(rsp.Body)} // i := &tb.Photo{File: tb.FromReader(rsp.Body)}
// if index == 0 {
// i.Caption = s
// }
// is = append(is, i)
// }
i := &tb.Photo{File: tb.FromURL(url)}
if index == 0 { if index == 0 {
i.Caption = s i.Caption = s
} }
@@ -90,14 +97,14 @@ func init() {
} }
} }
} }
}
b.SendAlbum(ct, is) b.SendAlbum(ct, is)
return return
} }
b.Send(ct, s) b.Send(ct, s)
} }
b.Handle(tb.OnPhoto, func(m *tb.Message) { b.Handle(tb.OnPhoto, func(m *tb.Message) {
b.Send(m.Chat, m.Caption+" "+m.AlbumID) // m.
// b.Send(m.Chat, m.Caption+" "+m.AlbumID)
// b.Download() // b.Download()
// b.Download(&m.Photo.File,"") // b.Download(&m.Photo.File,"")