mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
42 lines
718 B
Go
42 lines
718 B
Go
package curse
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
sql "github.com/FloatTech/sqlite"
|
|
"github.com/FloatTech/zbputils/file"
|
|
"github.com/FloatTech/zbputils/process"
|
|
|
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
|
)
|
|
|
|
const (
|
|
dbpath = "data/Curse/"
|
|
dbfile = dbpath + "curse.db"
|
|
)
|
|
|
|
var (
|
|
db = &sql.Sqlite{DBPath: dbfile}
|
|
)
|
|
|
|
// 加载数据库
|
|
func init() {
|
|
go func() {
|
|
defer order.DoneOnExit()()
|
|
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, "条骂人语录")
|
|
}()
|
|
}
|