mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-20 06:20:08 +08:00
fix tarot
This commit is contained in:
parent
494c1b33b4
commit
a0df41b859
@ -41,12 +41,13 @@ type formation struct {
|
|||||||
}
|
}
|
||||||
type cardSet = map[string]card
|
type cardSet = map[string]card
|
||||||
|
|
||||||
var cardMap = make(cardSet, 80)
|
var (
|
||||||
var infoMap = make(map[string]cardInfo, 80)
|
cardMap = make(cardSet, 80)
|
||||||
var formationMap = make(map[string]formation, 10)
|
infoMap = make(map[string]cardInfo, 80)
|
||||||
|
formationMap = make(map[string]formation, 10)
|
||||||
var majorArcanaName = make([]string, 0, 80)
|
majorArcanaName = make([]string, 0, 80)
|
||||||
var formationName = make([]string, 0, 10)
|
formationName = make([]string, 0, 10)
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
engine := control.Register("tarot", &ctrl.Options[*zero.Ctx]{
|
engine := control.Register("tarot", &ctrl.Options[*zero.Ctx]{
|
||||||
@ -313,19 +314,25 @@ func poolimg(ctx *zero.Ctx, imgurl, imgname, cache string) (msg message.MessageS
|
|||||||
imgfile := cache + "/" + imgname + ".png"
|
imgfile := cache + "/" + imgname + ".png"
|
||||||
aimgfile := file.BOTPATH + "/" + imgfile
|
aimgfile := file.BOTPATH + "/" + imgfile
|
||||||
m, err := pool.GetImage(imgname)
|
m, err := pool.GetImage(imgname)
|
||||||
if err != nil {
|
if err == nil {
|
||||||
if file.IsNotExist(aimgfile) {
|
msg = message.Image(m.String())
|
||||||
var f *os.File
|
if ctxext.SendToSelf(ctx)(msg) == 0 {
|
||||||
f, err = os.Create(imgfile)
|
msg = msg.Add("cache", "0")
|
||||||
if err != nil {
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if file.IsNotExist(aimgfile) {
|
||||||
var data []byte
|
var data []byte
|
||||||
data, err = web.RequestDataWith(web.NewTLS12Client(), imgurl, "GET", "gitcode.net", web.RandUA())
|
data, err = web.RequestDataWith(web.NewTLS12Client(), imgurl, "GET", "gitcode.net", web.RandUA())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_ = f.Close()
|
var f *os.File
|
||||||
|
f, err = os.Create(imgfile)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
err = os.WriteFile(f.Name(), data, 0755)
|
err = os.WriteFile(f.Name(), data, 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -334,11 +341,5 @@ func poolimg(ctx *zero.Ctx, imgurl, imgname, cache string) (msg message.MessageS
|
|||||||
m.SetFile(aimgfile)
|
m.SetFile(aimgfile)
|
||||||
_, _ = m.Push(ctxext.SendToSelf(ctx), ctxext.GetMessage(ctx))
|
_, _ = m.Push(ctxext.SendToSelf(ctx), ctxext.GetMessage(ctx))
|
||||||
msg = message.Image("file:///" + aimgfile)
|
msg = message.Image("file:///" + aimgfile)
|
||||||
} else {
|
return
|
||||||
msg = message.Image(m.String())
|
|
||||||
if ctxext.SendToSelf(ctx)(msg) == 0 {
|
|
||||||
msg = msg.Add("cache", "0")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return msg, nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user