diff --git a/plugin_vtb_quotation/cron.go b/plugin_vtb_quotation/cron.go index a67fb8f5..c5253ba5 100644 --- a/plugin_vtb_quotation/cron.go +++ b/plugin_vtb_quotation/cron.go @@ -28,7 +28,7 @@ func vtbDaily() { } func vtbData() { - db := model.Init(dbpath) + db := model.Init(dbfile) if db != nil { for _, v := range db.GetVtbList() { db.StoreVtb(v) diff --git a/plugin_vtb_quotation/data.go b/plugin_vtb_quotation/data.go index cbf65c7b..703aa3bb 100644 --- a/plugin_vtb_quotation/data.go +++ b/plugin_vtb_quotation/data.go @@ -9,12 +9,13 @@ import ( "github.com/FloatTech/ZeroBot-Plugin/utils/file" ) -const pburl = "https://codechina.csdn.net/u011570312/ZeroBot-Plugin/-/raw/master/" + dbpath +const pburl = "https://codechina.csdn.net/u011570312/ZeroBot-Plugin/-/raw/master/" + dbfile // 加载数据库 func init() { - if !file.IsExist(dbpath) { // 如果没有数据库,则从 url 下载 - f, err := os.Create(dbpath) + _ = os.MkdirAll(dbpath, 0755) + if !file.IsExist(dbfile) { // 如果没有数据库,则从 url 下载 + f, err := os.Create(dbfile) if err != nil { panic(err) } diff --git a/plugin_vtb_quotation/vtb_quotation.go b/plugin_vtb_quotation/vtb_quotation.go index 35b5bd17..e2871d6d 100644 --- a/plugin_vtb_quotation/vtb_quotation.go +++ b/plugin_vtb_quotation/vtb_quotation.go @@ -17,7 +17,8 @@ import ( ) const regStr = ".*/(.*)" -const dbpath = "data/VtbQuotation/vtb.db" +const dbpath = "data/VtbQuotation/" +const dbfile = dbpath + "vtb.db" var engine = control.Register("vtbquotation", &control.Options{ DisableOnDefault: false, @@ -33,7 +34,7 @@ func init() { echo, cancel := ctx.FutureEvent("message", ctx.CheckSession()). // 只复读开启复读模式的人的消息 Repeat() // 不断监听复读 - db, err := model.Open(dbpath) + db, err := model.Open(dbfile) if err != nil { logrus.Errorln(err) return @@ -133,7 +134,7 @@ func init() { }) engine.OnFullMatch("随机vtb").SetBlock(true). Handle(func(ctx *zero.Ctx) { - db, err := model.Open(dbpath) + db, err := model.Open(dbfile) if err != nil { logrus.Errorln(err) return