mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
✏️ 修复 vtb 自动下载数据库失败
This commit is contained in:
parent
51d10d3234
commit
fa063a05f7
@ -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)
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user