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"
|
||||
"github.com/wdvxdr1123/ZeroBot/driver"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -156,6 +158,7 @@ func getKanban() string {
|
||||
}
|
||||
|
||||
func main() {
|
||||
order.Wait()
|
||||
printBanner()
|
||||
// 帮助
|
||||
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"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -19,6 +21,7 @@ var bdb *bilibilipushdb
|
||||
// 加载数据库
|
||||
func init() {
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
process.SleepAbout1sTo2s()
|
||||
_ = os.MkdirAll(dbpath, 0755)
|
||||
os.RemoveAll(cachePath)
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/FloatTech/zbputils/sql"
|
||||
@ -18,6 +19,7 @@ var db = &sql.Sqlite{DBPath: dbfile}
|
||||
// 加载数据库
|
||||
func init() {
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
process.SleepAbout1sTo2s()
|
||||
// os.RemoveAll(dbpath)
|
||||
_ = os.MkdirAll(dbpath, 0755)
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
)
|
||||
@ -14,6 +15,7 @@ type kimo = map[string]*[]string
|
||||
|
||||
func initChatList(postinit func()) {
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
process.SleepAbout1sTo2s()
|
||||
_ = os.MkdirAll(dbpath, 0755)
|
||||
data, err := file.GetLazyData(dbfile, true, true)
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/FloatTech/zbputils/sql"
|
||||
@ -20,6 +21,7 @@ var db = &sql.Sqlite{DBPath: dbfile}
|
||||
// 加载数据库
|
||||
func init() {
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
process.SleepAbout1sTo2s()
|
||||
// os.RemoveAll(dbpath)
|
||||
_ = os.MkdirAll(dbpath, 0755)
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/FloatTech/zbputils/sql"
|
||||
@ -20,6 +21,7 @@ var db = &sql.Sqlite{DBPath: dbfile}
|
||||
// 加载数据库
|
||||
func init() {
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
process.SleepAbout1sTo2s()
|
||||
// os.RemoveAll(dbpath)
|
||||
_ = os.MkdirAll(dbpath, 0755)
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/FloatTech/zbputils/sql"
|
||||
@ -22,6 +23,7 @@ var (
|
||||
// 加载数据库
|
||||
func init() {
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
process.SleepAbout1sTo2s()
|
||||
_ = os.MkdirAll(dbpath, 0755)
|
||||
_, err := file.GetLazyData(dbfile, false, true)
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/FloatTech/zbputils/sql"
|
||||
@ -28,6 +29,7 @@ type text struct {
|
||||
|
||||
func init() {
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
process.SleepAbout1sTo2s()
|
||||
err := os.MkdirAll(datapath, 0755)
|
||||
if err != nil {
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
)
|
||||
@ -22,6 +23,7 @@ const (
|
||||
// 加载数据库
|
||||
func init() {
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
process.SleepAbout1sTo2s()
|
||||
_ = os.MkdirAll(dbpath, 0755)
|
||||
_, err := file.GetLazyData(dbfile, false, true)
|
||||
|
||||
@ -68,6 +68,7 @@ var engine = control.Register("manager", order.PrioManager, &control.Options{
|
||||
|
||||
func init() { // 插件主体
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
process.SleepAbout1sTo2s()
|
||||
_ = os.MkdirAll(datapath, 0755)
|
||||
clock = timer.NewClock(db)
|
||||
|
||||
@ -13,6 +13,7 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
_ "golang.org/x/image/webp" // import webp decoding
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/FloatTech/zbputils/sql"
|
||||
@ -29,6 +30,7 @@ var ns = &nsetu{db: &sql.Sqlite{DBPath: dbfile}}
|
||||
|
||||
func init() {
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
process.SleepAbout1sTo2s()
|
||||
err := os.MkdirAll(datapath, 0755)
|
||||
if err != nil {
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/FloatTech/zbputils/sql"
|
||||
@ -19,11 +20,7 @@ var db = &sql.Sqlite{DBPath: dbfile}
|
||||
|
||||
func init() {
|
||||
go func() {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}()
|
||||
defer order.DoneOnExit()()
|
||||
process.SleepAbout1sTo2s()
|
||||
_ = os.MkdirAll(dbpath, 0755)
|
||||
_, _ = file.GetLazyData(dbfile, false, true)
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
wr "github.com/mroth/weightedrand"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
)
|
||||
@ -27,6 +28,7 @@ var (
|
||||
|
||||
func init() {
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
process.SleepAbout1sTo2s()
|
||||
err := os.MkdirAll(datapath, 0755)
|
||||
if err != nil {
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/FloatTech/zbputils/txt2img"
|
||||
@ -22,6 +23,7 @@ var sdb *scoredb
|
||||
// 加载数据库
|
||||
func init() {
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
process.SleepAbout1sTo2s()
|
||||
_, err := file.GetLazyData(txt2img.BoldFontFile, false, true)
|
||||
if err != nil {
|
||||
|
||||
@ -55,6 +55,7 @@ func init() { // 插件主体
|
||||
_ = os.MkdirAll("data/SetuTime", 0755)
|
||||
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
process.SleepAbout1sTo2s()
|
||||
// 如果数据库不存在则下载
|
||||
_, _ = fileutil.GetLazyData(pool.db.DBPath, false, false)
|
||||
|
||||
@ -3,20 +3,15 @@ package sleepmanage
|
||||
import (
|
||||
"os"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/ZeroBot-Plugin/plugin_sleep_manage/model"
|
||||
)
|
||||
|
||||
func init() {
|
||||
go func() {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}()
|
||||
defer order.DoneOnExit()()
|
||||
process.SleepAbout1sTo2s()
|
||||
_ = os.MkdirAll(dbpath, 0755)
|
||||
model.Initialize(dbfile)
|
||||
|
||||
@ -6,11 +6,13 @@ import (
|
||||
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/ZeroBot-Plugin/plugin_vtb_quotation/model"
|
||||
)
|
||||
|
||||
func init() {
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
process.SleepAbout1sTo2s()
|
||||
log.Println("[vtb/cron] 开启vtb数据库日常更新")
|
||||
vtbDaily()
|
||||
|
||||
@ -3,6 +3,7 @@ package vtbquotation
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
)
|
||||
@ -10,6 +11,7 @@ import (
|
||||
// 加载数据库
|
||||
func init() {
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
process.SleepAbout1sTo2s()
|
||||
_ = os.MkdirAll(dbpath, 0755)
|
||||
_, _ = file.GetLazyData(dbfile, false, false)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user