ZeroBot-Plugin/plugin_curse/data.go
github-actions[bot] 1c222a36ee 🎨 改进代码样式
2022-01-11 02:08:46 +00:00

39 lines
681 B
Go

package curse
import (
"os"
"github.com/sirupsen/logrus"
"github.com/FloatTech/ZeroBot-Plugin/utils/file"
"github.com/FloatTech/ZeroBot-Plugin/utils/process"
"github.com/FloatTech/ZeroBot-Plugin/utils/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, "条骂人语录")
}()
}