Skip to content

Commit bdc4138

Browse files
committed
fix: fortune
1 parent e231235 commit bdc4138

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

plugin/fortune/fortune.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var (
4343
index = make(map[string]uint8)
4444
// 签文
4545
omikujis []map[string]string
46+
fontdata []byte
4647
)
4748

4849
func init() {
@@ -98,12 +99,13 @@ func init() {
9899
ctx.SendChain(message.Text("ERROR: ", err))
99100
return false
100101
}
101-
fontdata, err := file.GetLazyData("data/Font/sakura.ttf", control.Md5File, true)
102-
if err != nil {
103-
ctx.SendChain(message.Text("ERROR: ", err))
104-
return false
102+
if fontdata == nil {
103+
fontdata, err = file.GetLazyData("data/Font/sakura.ttf", control.Md5File, true)
104+
if err != nil {
105+
ctx.SendChain(message.Text("ERROR: ", err))
106+
return false
107+
}
105108
}
106-
ctx.State["fontdata"] = fontdata
107109
return true
108110
},
109111
)).Limit(ctxext.LimitByGroup).SetBlock(true).
@@ -149,7 +151,7 @@ func init() {
149151
if err != nil {
150152
return err
151153
}
152-
_, err = draw(background, ctx.State["fontdata"].([]byte), title, text, f)
154+
_, err = draw(background, fontdata, title, text, f)
153155
_ = f.Close()
154156
return err
155157
}, ctxext.Send(ctx), ctxext.GetMessage(ctx))

0 commit comments

Comments
 (0)