Skip to content

Commit

Permalink
fix: fortune
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Feb 24, 2023
1 parent e231235 commit bdc4138
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions plugin/fortune/fortune.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ var (
index = make(map[string]uint8)
// 签文
omikujis []map[string]string
fontdata []byte
)

func init() {
Expand Down Expand Up @@ -98,12 +99,13 @@ func init() {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
fontdata, err := file.GetLazyData("data/Font/sakura.ttf", control.Md5File, true)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
if fontdata == nil {
fontdata, err = file.GetLazyData("data/Font/sakura.ttf", control.Md5File, true)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return false
}
}
ctx.State["fontdata"] = fontdata
return true
},
)).Limit(ctxext.LimitByGroup).SetBlock(true).
Expand Down Expand Up @@ -149,7 +151,7 @@ func init() {
if err != nil {
return err
}
_, err = draw(background, ctx.State["fontdata"].([]byte), title, text, f)
_, err = draw(background, fontdata, title, text, f)
_ = f.Close()
return err
}, ctxext.Send(ctx), ctxext.GetMessage(ctx))
Expand Down

0 comments on commit bdc4138

Please sign in to comment.