mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-21 23:50:09 +08:00
✨ 增加初始化等待
This commit is contained in:
parent
0770c6e4a1
commit
ca18a323e3
3
main.go
3
main.go
@ -79,6 +79,8 @@ import (
|
|||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
"github.com/wdvxdr1123/ZeroBot/driver"
|
"github.com/wdvxdr1123/ZeroBot/driver"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -156,6 +158,7 @@ func getKanban() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
order.Wait()
|
||||||
printBanner()
|
printBanner()
|
||||||
// 帮助
|
// 帮助
|
||||||
zero.OnFullMatchGroup([]string{"/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true).
|
zero.OnFullMatchGroup([]string{"/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true).
|
||||||
|
|||||||
14
order/init.go
Normal file
14
order/init.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package order
|
||||||
|
|
||||||
|
import "sync"
|
||||||
|
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
|
// DoneOnExit 在退出时执行 Done
|
||||||
|
func DoneOnExit() func() {
|
||||||
|
wg.Add(1)
|
||||||
|
return wg.Done
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait 等待
|
||||||
|
var Wait = wg.Wait
|
||||||
@ -5,6 +5,8 @@ import (
|
|||||||
|
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -19,6 +21,7 @@ var bdb *bilibilipushdb
|
|||||||
// 加载数据库
|
// 加载数据库
|
||||||
func init() {
|
func init() {
|
||||||
go func() {
|
go func() {
|
||||||
|
defer order.DoneOnExit()()
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
_ = os.MkdirAll(dbpath, 0755)
|
_ = os.MkdirAll(dbpath, 0755)
|
||||||
os.RemoveAll(cachePath)
|
os.RemoveAll(cachePath)
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
"github.com/FloatTech/zbputils/file"
|
"github.com/FloatTech/zbputils/file"
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
"github.com/FloatTech/zbputils/sql"
|
"github.com/FloatTech/zbputils/sql"
|
||||||
@ -18,6 +19,7 @@ var db = &sql.Sqlite{DBPath: dbfile}
|
|||||||
// 加载数据库
|
// 加载数据库
|
||||||
func init() {
|
func init() {
|
||||||
go func() {
|
go func() {
|
||||||
|
defer order.DoneOnExit()()
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
// os.RemoveAll(dbpath)
|
// os.RemoveAll(dbpath)
|
||||||
_ = os.MkdirAll(dbpath, 0755)
|
_ = os.MkdirAll(dbpath, 0755)
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
"github.com/FloatTech/zbputils/file"
|
"github.com/FloatTech/zbputils/file"
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
)
|
)
|
||||||
@ -14,6 +15,7 @@ type kimo = map[string]*[]string
|
|||||||
|
|
||||||
func initChatList(postinit func()) {
|
func initChatList(postinit func()) {
|
||||||
go func() {
|
go func() {
|
||||||
|
defer order.DoneOnExit()()
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
_ = os.MkdirAll(dbpath, 0755)
|
_ = os.MkdirAll(dbpath, 0755)
|
||||||
data, err := file.GetLazyData(dbfile, true, true)
|
data, err := file.GetLazyData(dbfile, true, true)
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
"github.com/FloatTech/zbputils/file"
|
"github.com/FloatTech/zbputils/file"
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
"github.com/FloatTech/zbputils/sql"
|
"github.com/FloatTech/zbputils/sql"
|
||||||
@ -20,6 +21,7 @@ var db = &sql.Sqlite{DBPath: dbfile}
|
|||||||
// 加载数据库
|
// 加载数据库
|
||||||
func init() {
|
func init() {
|
||||||
go func() {
|
go func() {
|
||||||
|
defer order.DoneOnExit()()
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
// os.RemoveAll(dbpath)
|
// os.RemoveAll(dbpath)
|
||||||
_ = os.MkdirAll(dbpath, 0755)
|
_ = os.MkdirAll(dbpath, 0755)
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
"github.com/FloatTech/zbputils/file"
|
"github.com/FloatTech/zbputils/file"
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
"github.com/FloatTech/zbputils/sql"
|
"github.com/FloatTech/zbputils/sql"
|
||||||
@ -20,6 +21,7 @@ var db = &sql.Sqlite{DBPath: dbfile}
|
|||||||
// 加载数据库
|
// 加载数据库
|
||||||
func init() {
|
func init() {
|
||||||
go func() {
|
go func() {
|
||||||
|
defer order.DoneOnExit()()
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
// os.RemoveAll(dbpath)
|
// os.RemoveAll(dbpath)
|
||||||
_ = os.MkdirAll(dbpath, 0755)
|
_ = os.MkdirAll(dbpath, 0755)
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
"github.com/FloatTech/zbputils/file"
|
"github.com/FloatTech/zbputils/file"
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
"github.com/FloatTech/zbputils/sql"
|
"github.com/FloatTech/zbputils/sql"
|
||||||
@ -22,6 +23,7 @@ var (
|
|||||||
// 加载数据库
|
// 加载数据库
|
||||||
func init() {
|
func init() {
|
||||||
go func() {
|
go func() {
|
||||||
|
defer order.DoneOnExit()()
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
_ = os.MkdirAll(dbpath, 0755)
|
_ = os.MkdirAll(dbpath, 0755)
|
||||||
_, err := file.GetLazyData(dbfile, false, true)
|
_, err := file.GetLazyData(dbfile, false, true)
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
"github.com/FloatTech/zbputils/file"
|
"github.com/FloatTech/zbputils/file"
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
"github.com/FloatTech/zbputils/sql"
|
"github.com/FloatTech/zbputils/sql"
|
||||||
@ -28,6 +29,7 @@ type text struct {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
go func() {
|
go func() {
|
||||||
|
defer order.DoneOnExit()()
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
err := os.MkdirAll(datapath, 0755)
|
err := os.MkdirAll(datapath, 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
"github.com/FloatTech/zbputils/file"
|
"github.com/FloatTech/zbputils/file"
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
)
|
)
|
||||||
@ -22,6 +23,7 @@ const (
|
|||||||
// 加载数据库
|
// 加载数据库
|
||||||
func init() {
|
func init() {
|
||||||
go func() {
|
go func() {
|
||||||
|
defer order.DoneOnExit()()
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
_ = os.MkdirAll(dbpath, 0755)
|
_ = os.MkdirAll(dbpath, 0755)
|
||||||
_, err := file.GetLazyData(dbfile, false, true)
|
_, err := file.GetLazyData(dbfile, false, true)
|
||||||
|
|||||||
@ -68,6 +68,7 @@ var engine = control.Register("manager", order.PrioManager, &control.Options{
|
|||||||
|
|
||||||
func init() { // 插件主体
|
func init() { // 插件主体
|
||||||
go func() {
|
go func() {
|
||||||
|
defer order.DoneOnExit()()
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
_ = os.MkdirAll(datapath, 0755)
|
_ = os.MkdirAll(datapath, 0755)
|
||||||
clock = timer.NewClock(db)
|
clock = timer.NewClock(db)
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||||
_ "golang.org/x/image/webp" // import webp decoding
|
_ "golang.org/x/image/webp" // import webp decoding
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
"github.com/FloatTech/zbputils/file"
|
"github.com/FloatTech/zbputils/file"
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
"github.com/FloatTech/zbputils/sql"
|
"github.com/FloatTech/zbputils/sql"
|
||||||
@ -29,6 +30,7 @@ var ns = &nsetu{db: &sql.Sqlite{DBPath: dbfile}}
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
go func() {
|
go func() {
|
||||||
|
defer order.DoneOnExit()()
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
err := os.MkdirAll(datapath, 0755)
|
err := os.MkdirAll(datapath, 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
"github.com/FloatTech/zbputils/file"
|
"github.com/FloatTech/zbputils/file"
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
"github.com/FloatTech/zbputils/sql"
|
"github.com/FloatTech/zbputils/sql"
|
||||||
@ -19,11 +20,7 @@ var db = &sql.Sqlite{DBPath: dbfile}
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
go func() {
|
go func() {
|
||||||
defer func() {
|
defer order.DoneOnExit()()
|
||||||
if err := recover(); err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
_ = os.MkdirAll(dbpath, 0755)
|
_ = os.MkdirAll(dbpath, 0755)
|
||||||
_, _ = file.GetLazyData(dbfile, false, true)
|
_, _ = file.GetLazyData(dbfile, false, true)
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import (
|
|||||||
wr "github.com/mroth/weightedrand"
|
wr "github.com/mroth/weightedrand"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
"github.com/FloatTech/zbputils/file"
|
"github.com/FloatTech/zbputils/file"
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
)
|
)
|
||||||
@ -27,6 +28,7 @@ var (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
go func() {
|
go func() {
|
||||||
|
defer order.DoneOnExit()()
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
err := os.MkdirAll(datapath, 0755)
|
err := os.MkdirAll(datapath, 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
"github.com/FloatTech/zbputils/file"
|
"github.com/FloatTech/zbputils/file"
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
"github.com/FloatTech/zbputils/txt2img"
|
"github.com/FloatTech/zbputils/txt2img"
|
||||||
@ -22,6 +23,7 @@ var sdb *scoredb
|
|||||||
// 加载数据库
|
// 加载数据库
|
||||||
func init() {
|
func init() {
|
||||||
go func() {
|
go func() {
|
||||||
|
defer order.DoneOnExit()()
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
_, err := file.GetLazyData(txt2img.BoldFontFile, false, true)
|
_, err := file.GetLazyData(txt2img.BoldFontFile, false, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -55,6 +55,7 @@ func init() { // 插件主体
|
|||||||
_ = os.MkdirAll("data/SetuTime", 0755)
|
_ = os.MkdirAll("data/SetuTime", 0755)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
defer order.DoneOnExit()()
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
// 如果数据库不存在则下载
|
// 如果数据库不存在则下载
|
||||||
_, _ = fileutil.GetLazyData(pool.db.DBPath, false, false)
|
_, _ = fileutil.GetLazyData(pool.db.DBPath, false, false)
|
||||||
|
|||||||
@ -3,20 +3,15 @@ package sleepmanage
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
"github.com/FloatTech/ZeroBot-Plugin/plugin_sleep_manage/model"
|
"github.com/FloatTech/ZeroBot-Plugin/plugin_sleep_manage/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
go func() {
|
go func() {
|
||||||
defer func() {
|
defer order.DoneOnExit()()
|
||||||
if err := recover(); err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
_ = os.MkdirAll(dbpath, 0755)
|
_ = os.MkdirAll(dbpath, 0755)
|
||||||
model.Initialize(dbfile)
|
model.Initialize(dbfile)
|
||||||
|
|||||||
@ -6,11 +6,13 @@ import (
|
|||||||
|
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
"github.com/FloatTech/ZeroBot-Plugin/plugin_vtb_quotation/model"
|
"github.com/FloatTech/ZeroBot-Plugin/plugin_vtb_quotation/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
go func() {
|
go func() {
|
||||||
|
defer order.DoneOnExit()()
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
log.Println("[vtb/cron] 开启vtb数据库日常更新")
|
log.Println("[vtb/cron] 开启vtb数据库日常更新")
|
||||||
vtbDaily()
|
vtbDaily()
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package vtbquotation
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
"github.com/FloatTech/zbputils/file"
|
"github.com/FloatTech/zbputils/file"
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
)
|
)
|
||||||
@ -10,6 +11,7 @@ import (
|
|||||||
// 加载数据库
|
// 加载数据库
|
||||||
func init() {
|
func init() {
|
||||||
go func() {
|
go func() {
|
||||||
|
defer order.DoneOnExit()()
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
_ = os.MkdirAll(dbpath, 0755)
|
_ = os.MkdirAll(dbpath, 0755)
|
||||||
_, _ = file.GetLazyData(dbfile, false, false)
|
_, _ = file.GetLazyData(dbfile, false, false)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user