mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
fix tarot
This commit is contained in:
parent
a0df41b859
commit
cbb4408668
@ -11,6 +11,7 @@ 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"
|
||||
@ -140,23 +141,32 @@ func init() {
|
||||
description = card.ReverseDescription
|
||||
}
|
||||
imgurl := bed + 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
|
||||
imgname := ""
|
||||
imgpath := cache + "/" + imgname + ".png"
|
||||
if p == 1 {
|
||||
imgmsg, err = poolimg(ctx, imgurl, reverse[p][:len(reverse[p])-1]+card.Name, cache)
|
||||
imgname = reverse[p][:len(reverse[p])-1] + card.Name
|
||||
} else {
|
||||
imgmsg, err = poolimg(ctx, imgurl, card.Name, cache)
|
||||
imgname = card.Name
|
||||
}
|
||||
err := pool.SendImageFromPool(imgname, imgpath, func() error {
|
||||
data, err := web.RequestDataWith(web.NewTLS12Client(), imgurl, "GET", "gitcode.net", web.RandUA())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var f *os.File
|
||||
f, err = os.Create(imgpath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
return os.WriteFile(f.Name(), data, 0755)
|
||||
}, ctxext.Send(ctx), ctxext.GetMessage(ctx))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
tarotmsg = append(tarotmsg, imgmsg)
|
||||
tarotmsg = append(tarotmsg, message.Text("\n其释义为: ", description))
|
||||
if id := ctx.Send(tarotmsg).ID(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
process.SleepAbout1sTo2s()
|
||||
ctx.SendChain(message.Text(reasons[rand.Intn(len(reasons))], position[p], "的『", name, "』\n其释义为: ", description))
|
||||
return
|
||||
}
|
||||
msg := make(message.Message, n)
|
||||
@ -214,23 +224,23 @@ func init() {
|
||||
if id := ctx.Send(tarotmsg).ID(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
} else {
|
||||
var build strings.Builder
|
||||
build.WriteString("塔罗牌列表\n大阿尔卡纳:\n")
|
||||
build.WriteString(strings.Join(majorArcanaName[:7], " "))
|
||||
build.WriteString("\n")
|
||||
build.WriteString(strings.Join(majorArcanaName[7:14], " "))
|
||||
build.WriteString("\n")
|
||||
build.WriteString(strings.Join(majorArcanaName[14:22], " "))
|
||||
build.WriteString("\n小阿尔卡纳:\n[圣杯|星币|宝剑|权杖] [0-10|侍从|骑士|王后|国王]")
|
||||
txt := build.String()
|
||||
cardList, err := text.RenderToBase64(txt, text.FontFile, 420, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("没有找到", match, "噢~"), message.Image("base64://"+binary.BytesToString(cardList)))
|
||||
return
|
||||
}
|
||||
var build strings.Builder
|
||||
build.WriteString("塔罗牌列表\n大阿尔卡纳:\n")
|
||||
build.WriteString(strings.Join(majorArcanaName[:7], " "))
|
||||
build.WriteString("\n")
|
||||
build.WriteString(strings.Join(majorArcanaName[7:14], " "))
|
||||
build.WriteString("\n")
|
||||
build.WriteString(strings.Join(majorArcanaName[14:22], " "))
|
||||
build.WriteString("\n小阿尔卡纳:\n[圣杯|星币|宝剑|权杖] [0-10|侍从|骑士|王后|国王]")
|
||||
txt := build.String()
|
||||
cardList, err := text.RenderToBase64(txt, text.FontFile, 420, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("没有找到", match, "噢~"), message.Image("base64://"+binary.BytesToString(cardList)))
|
||||
})
|
||||
engine.OnRegex(`^((塔罗|大阿(尔)?卡纳)|小阿(尔)?卡纳|混合)牌阵\s?(.*)`, getTarot).SetBlock(true).Limit(ctxext.LimitByGroup).Handle(func(ctx *zero.Ctx) {
|
||||
cardType := ctx.State["regex_matched"].([]string)[1]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user