diff --git a/plugin_purechat/data.go b/plugin_purechat/data.go new file mode 100644 index 00000000..0226ab28 --- /dev/null +++ b/plugin_purechat/data.go @@ -0,0 +1,36 @@ +package purechat + +import ( + "encoding/json" + "os" + + "github.com/sirupsen/logrus" + + "github.com/FloatTech/zbputils/file" + "github.com/FloatTech/zbputils/process" + + "github.com/FloatTech/ZeroBot-Plugin/order" +) + +type kimogo = map[string]*[]string + +func initPureChatList(postinit func()) { + go func() { + defer order.DoneOnExit()() + process.SleepAbout1sTo2s() + _ = os.MkdirAll(dbpath, 0755) + data, err := file.GetLazyData(dbfile, true, true) + if err != nil { + panic(err) + } + err = json.Unmarshal(data, &kimogomap) + if err != nil { + panic(err) + } + for k := range kimogomap { + chatList = append(chatList, k) + } + logrus.Infoln("[purechat]加载", len(chatList), "条kimoi") + postinit() + }() +}