ZeroBot-Plugin/plugin_cpstory/data.go
himawari 486160fc57
添加cp短打 (#94)
* feat:添加cp短打插件

* feat:匹配中英文标点符号和中文字符
2021-12-26 22:00:02 +08:00

36 lines
704 B
Go

package cpstory
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/CpStory/"
dbfile = dbpath + "cp.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("cp_story", &CpStory{})
if err != nil {
panic(err)
}
n, err := db.Count("cp_story")
if err != nil {
panic(err)
}
log.Printf("[cpstory]读取%d条故事", n)
}()
}