From 7bd3eb46a2bcc4a206063d9db163a24a339705f9 Mon Sep 17 00:00:00 2001 From: cdle <798731886@qq.com> Date: Thu, 7 Oct 2021 08:45:54 +0800 Subject: [PATCH] update --- im/tg/tg.go | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/im/tg/tg.go b/im/tg/tg.go index 0169ed5..0c33fe8 100644 --- a/im/tg/tg.go +++ b/im/tg/tg.go @@ -64,6 +64,7 @@ func init() { paths = append(paths, core.ExecPath+"/data/images/"+v[1]) s = strings.Replace(s, fmt.Sprintf(`[CQ:image,file=%s]`, v[1]), "", -1) } + s = regexp.MustCompile(`\[CQ:([^\[\]]+)\]`).ReplaceAllString(s, "") { t := []string{} for _, v := range strings.Split(s, "\n") { @@ -80,14 +81,19 @@ func init() { if err == nil { url := regexp.MustCompile("(https.*)").FindString(string(data)) if url != "" { - rsp, err := httplib.Get(url).Response() - if err == nil { - i := &tb.Photo{File: tb.FromReader(rsp.Body)} - if index == 0 { - i.Caption = s - } - is = append(is, i) + // rsp, err := httplib.Get(url).Response() + // if err == nil { + // 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 { + i.Caption = s } + is = append(is, i) } } } @@ -97,7 +103,8 @@ func init() { b.Send(ct, s) } 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(&m.Photo.File,"")