diff --git a/README.md b/README.md index 0c88052daa..69416570b6 100644 --- a/README.md +++ b/README.md @@ -1267,6 +1267,8 @@ print("run[CQ:image,file="+j["img"]+"]") - [x] 今日老婆[@xxx] - [x] 黄油角色[@xxx] + + - [x] 娘化穿越到异世界[@xxx]
diff --git a/data b/data index f1f8cd107c..8d31381a08 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit f1f8cd107cacaf8d8e358d7468f7c9b25adf637a +Subproject commit 8d31381a08234d86b72ca05424b8bb513428fba7 diff --git a/plugin/shindan/shindan.go b/plugin/shindan/shindan.go index 18c1844eac..f71fdd0703 100644 --- a/plugin/shindan/shindan.go +++ b/plugin/shindan/shindan.go @@ -21,13 +21,15 @@ func init() { "- 异世界转生[@xxx]\n" + "- 卖萌[@xxx]\n" + "- 今日老婆[@xxx]\n" + - "- 黄油角色[@xxx]", + "- 黄油角色[@xxx]\n" + + "- 娘化穿越到异世界[@xxx]", }) engine.OnPrefix("异世界转生", number(587874)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic) engine.OnPrefix("今天是什么少女", number(162207)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic) engine.OnPrefix("卖萌", number(360578)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handletxt) engine.OnPrefix("今日老婆", number(1075116)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlecq) engine.OnPrefix("黄油角色", number(1115465)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic) + engine.OnPrefix("娘化穿越到异世界", number(637918)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic) } func handletxt(ctx *zero.Ctx) { diff --git a/plugin/tarot/tarot.go b/plugin/tarot/tarot.go index 45cc944364..ee54ba02fa 100644 --- a/plugin/tarot/tarot.go +++ b/plugin/tarot/tarot.go @@ -10,21 +10,15 @@ import ( "github.com/FloatTech/floatbox/binary" fcext "github.com/FloatTech/floatbox/ctxext" - "github.com/FloatTech/floatbox/file" - "github.com/FloatTech/floatbox/process" - "github.com/FloatTech/floatbox/web" ctrl "github.com/FloatTech/zbpctrl" "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" - "github.com/FloatTech/zbputils/img/pool" "github.com/FloatTech/zbputils/img/text" "github.com/sirupsen/logrus" zero "github.com/wdvxdr1123/ZeroBot" "github.com/wdvxdr1123/ZeroBot/message" ) -const bed = "https://gitcode.net/shudorcl/zbp-tarot/-/raw/master/" - type cardInfo struct { Description string `json:"description"` ReverseDescription string `json:"reverseDescription"` @@ -140,31 +134,14 @@ func init() { if p == 1 { description = card.ReverseDescription } - imgurl := bed + reverse[p] + card.ImgURL - imgname := "" - if p == 1 { - imgname = reverse[p][:len(reverse[p])-1] + name - } else { - imgname = name - } - imgpath := cache + "/" + imgname + ".png" - err := pool.SendImageFromPool(imgpath, func(pth string) error { - data, err := web.RequestDataWith(web.NewTLS12Client(), imgurl, "GET", "gitcode.net", web.RandUA(), nil) - if err != nil { - return err - } - f, err := os.Create(pth) - if err != nil { - return err - } - defer f.Close() - return os.WriteFile(f.Name(), data, 0755) - }, ctxext.Send(ctx)) + imgurl := reverse[p] + card.ImgURL + logrus.Infof("尝试获取图片: " + imgurl) + data, err := engine.GetLazyData(imgurl, true) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return } - process.SleepAbout1sTo2s() + ctx.SendChain(message.ImageBytes(data)) ctx.SendChain(message.Text(reasons[rand.Intn(len(reasons))], position[p], "的『", name, "』\n其释义为: ", description)) return } @@ -185,15 +162,13 @@ func init() { if p == 1 { description = card.ReverseDescription } - imgurl := bed + reverse[p] + card.ImgURL + imgurl := reverse[p] + card.ImgURL tarotmsg := message.Message{message.Text(reasons[rand.Intn(len(reasons))], position[p], "的『", name, "』\n")} var imgmsg message.MessageSegment var err error - if p == 1 { - imgmsg, err = poolimg(imgurl, reverse[p][:len(reverse[p])-1]+name, cache) - } else { - imgmsg, err = poolimg(imgurl, name, cache) - } + logrus.Infof("尝试获取图片: " + imgurl) + data, err := engine.GetLazyData(imgurl, true) + imgmsg = message.ImageBytes(data) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return @@ -211,9 +186,11 @@ func init() { match := ctx.State["regex_matched"].([]string)[1] info, ok := infoMap[match] if ok { - imgurl := bed + info.ImgURL + imgurl := info.ImgURL var tarotmsg message.Message - imgmsg, err := poolimg(imgurl, match, cache) + logrus.Infof("尝试获取图片: " + imgurl) + data, err := engine.GetLazyData(imgurl, true) + imgmsg := message.ImageBytes(data) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return @@ -280,14 +257,12 @@ func init() { description = card.ReverseDescription } var tarotmsg message.Message - imgurl := bed + reverse[p] + card.ImgURL + imgurl := reverse[p] + card.ImgURL var imgmsg message.MessageSegment var err error - if p == 1 { - imgmsg, err = poolimg(imgurl, reverse[p][:len(reverse[p])-1]+name, cache) - } else { - imgmsg, err = poolimg(imgurl, name, cache) - } + logrus.Infof("尝试获取图片: " + imgurl) + data, err := engine.GetLazyData(imgurl, true) + imgmsg = message.ImageBytes(data) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return @@ -318,27 +293,3 @@ func init() { } }) } - -func poolimg(imgurl, imgname, cache string) (msg message.MessageSegment, err error) { - imgfile := cache + "/" + imgname + ".png" - aimgfile := file.BOTPATH + "/" + imgfile - if file.IsNotExist(aimgfile) { - var data []byte - data, err = web.RequestDataWith(web.NewTLS12Client(), imgurl, "GET", "gitcode.net", web.RandUA(), nil) - if err != nil { - return - } - var f *os.File - f, err = os.Create(imgfile) - if err != nil { - return - } - defer f.Close() - err = os.WriteFile(f.Name(), data, 0755) - if err != nil { - return - } - } - msg = message.Image("file:///" + aimgfile) - return -}