From bdc4138d78a4c8d8dd51f3c996f79e82fbb61b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Fri, 24 Feb 2023 11:29:15 +0800 Subject: [PATCH] fix: fortune --- plugin/fortune/fortune.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugin/fortune/fortune.go b/plugin/fortune/fortune.go index 517a4251..30f367e5 100644 --- a/plugin/fortune/fortune.go +++ b/plugin/fortune/fortune.go @@ -43,6 +43,7 @@ var ( index = make(map[string]uint8) // 签文 omikujis []map[string]string + fontdata []byte ) func init() { @@ -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). @@ -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))