mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-12 10:10:25 +00:00
feat:添加抽象话插件 (#92)
This commit is contained in:
35
plugin_chouxianghua/data.go
Normal file
35
plugin_chouxianghua/data.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package chouxianghua
|
||||
|
||||
import (
|
||||
"github.com/FloatTech/ZeroBot-Plugin/utils/file"
|
||||
"github.com/FloatTech/ZeroBot-Plugin/utils/process"
|
||||
"github.com/FloatTech/ZeroBot-Plugin/utils/sql"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"os"
|
||||
)
|
||||
|
||||
const (
|
||||
dbpath = "data/ChouXiangHua/"
|
||||
dbfile = dbpath + "cxh.db"
|
||||
)
|
||||
|
||||
var db = &sql.Sqlite{DBPath: dbfile}
|
||||
|
||||
// 加载数据库
|
||||
func init() {
|
||||
go func() {
|
||||
process.SleepAbout1sTo2s()
|
||||
// os.RemoveAll(dbpath)
|
||||
_ = os.MkdirAll(dbpath, 0755)
|
||||
_, _ = file.GetLazyData(dbfile, false, true)
|
||||
err := db.Create("pinyin", &Pinyin{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
n, err := db.Count("pinyin")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("[chouxianghua]读取%d条拼音", n)
|
||||
}()
|
||||
}
|
||||
Reference in New Issue
Block a user