ZeroBot-Plugin/plugin_curse/data.go
fumiama 0185d0c730 🚚 ⬆️ 📝 🔥 🎨 迁移 ctrl, utils
2022-01-11 11:40:33 +08:00

39 lines
645 B
Go

package curse
import (
"os"
"github.com/sirupsen/logrus"
"github.com/FloatTech/zbputils/file"
"github.com/FloatTech/zbputils/process"
"github.com/FloatTech/zbputils/sql"
)
const (
dbpath = "data/Curse/"
dbfile = dbpath + "curse.db"
)
var (
db = &sql.Sqlite{DBPath: dbfile}
)
// 加载数据库
func init() {
go func() {
process.SleepAbout1sTo2s()
_ = os.MkdirAll(dbpath, 0755)
_, err := file.GetLazyData(dbfile, false, true)
if err != nil {
panic(err)
}
err = db.Create("curse", &curse{})
if err != nil {
panic(err)
}
c, _ := db.Count("curse")
logrus.Infoln("[curse]加载", c, "条骂人语录")
}()
}