🔥 🎨 统一 cron

This commit is contained in:
fumiama 2022-02-23 16:52:40 +08:00
parent 8c40293fed
commit dc348f8500
5 changed files with 25 additions and 21 deletions

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.17
require ( require (
github.com/FloatTech/AnimeAPI v1.3.0-beta8.0.20220222140454-0d15c275f385 github.com/FloatTech/AnimeAPI v1.3.0-beta8.0.20220222140454-0d15c275f385
github.com/FloatTech/sqlite v0.2.0 github.com/FloatTech/sqlite v0.2.0
github.com/FloatTech/zbputils v1.3.0-beta8.0.20220222140356-fceefeb900dc github.com/FloatTech/zbputils v1.3.0-beta8.0.20220223084851-30900a9dfa51
github.com/antchfx/htmlquery v1.2.4 github.com/antchfx/htmlquery v1.2.4
github.com/corona10/goimagehash v1.0.3 github.com/corona10/goimagehash v1.0.3
github.com/fogleman/gg v1.3.0 github.com/fogleman/gg v1.3.0

5
go.sum
View File

@ -3,8 +3,11 @@ github.com/FloatTech/AnimeAPI v1.3.0-beta8.0.20220222140454-0d15c275f385/go.mod
github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ= github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ=
github.com/FloatTech/sqlite v0.2.0 h1:x3uls/hExXH1+bbaNLkvilce6ATtWlDx4IqoxBW/bv8= github.com/FloatTech/sqlite v0.2.0 h1:x3uls/hExXH1+bbaNLkvilce6ATtWlDx4IqoxBW/bv8=
github.com/FloatTech/sqlite v0.2.0/go.mod h1:xIDWIvpOFl8AXmZm0FC8t3PZjiR6ZutytCpBv2EWCns= github.com/FloatTech/sqlite v0.2.0/go.mod h1:xIDWIvpOFl8AXmZm0FC8t3PZjiR6ZutytCpBv2EWCns=
github.com/FloatTech/zbputils v1.3.0-beta8.0.20220222140356-fceefeb900dc h1:4oQAPzmpfzdz+8aTXuQYfcN5/v1rNVIxRpwHNJXqN40=
github.com/FloatTech/zbputils v1.3.0-beta8.0.20220222140356-fceefeb900dc/go.mod h1:tUXu86+Hoi6vcLHfcVwjZa9ZYF4JRoNaCC510EELjfs= github.com/FloatTech/zbputils v1.3.0-beta8.0.20220222140356-fceefeb900dc/go.mod h1:tUXu86+Hoi6vcLHfcVwjZa9ZYF4JRoNaCC510EELjfs=
github.com/FloatTech/zbputils v1.3.0-beta8.0.20220223084631-5f53225f25fd h1:ysvDWN/ktQwn6kNBZwBl9meYX3NvB6HXNC0dh+t9d4U=
github.com/FloatTech/zbputils v1.3.0-beta8.0.20220223084631-5f53225f25fd/go.mod h1:kSp2Z3Udn8NBnbfHayj//uX1G38WsX2dGcLG4yoXmI4=
github.com/FloatTech/zbputils v1.3.0-beta8.0.20220223084851-30900a9dfa51 h1:5WB1ZorvJBQ4KBvTpmk5XXTLGOJpdN0cEf8ICzLoh44=
github.com/FloatTech/zbputils v1.3.0-beta8.0.20220223084851-30900a9dfa51/go.mod h1:kSp2Z3Udn8NBnbfHayj//uX1G38WsX2dGcLG4yoXmI4=
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc h1:AAx50/fb/xS4lvsdQg+bFbGvqSDhyV1MF+p2PLCamZ0= github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc h1:AAx50/fb/xS4lvsdQg+bFbGvqSDhyV1MF+p2PLCamZ0=
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc/go.mod h1:OMmITAib6POA37xCichWM0aRnoVpSMZO1rB/G01wrr0= github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc/go.mod h1:OMmITAib6POA37xCichWM0aRnoVpSMZO1rB/G01wrr0=

View File

@ -6,7 +6,7 @@ import (
"time" "time"
control "github.com/FloatTech/zbputils/control" control "github.com/FloatTech/zbputils/control"
"github.com/fumiama/cron" "github.com/FloatTech/zbputils/process"
zero "github.com/wdvxdr1123/ZeroBot" zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message" "github.com/wdvxdr1123/ZeroBot/message"
@ -63,10 +63,9 @@ func init() {
// 定时任务每天晚上最后2分钟执行一次 // 定时任务每天晚上最后2分钟执行一次
func fansDaily() { func fansDaily() {
c := cron.New() _, err := process.CronTab.AddFunc("58 23 * * *", func() { sendNotice() })
_, err := c.AddFunc("58 23 * * *", func() { sendNotice() }) if err != nil {
if err == nil { panic(err)
c.Start()
} }
} }

View File

@ -5,7 +5,7 @@ import (
"time" "time"
control "github.com/FloatTech/zbputils/control" control "github.com/FloatTech/zbputils/control"
"github.com/fumiama/cron" "github.com/FloatTech/zbputils/process"
zero "github.com/wdvxdr1123/ZeroBot" zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message" "github.com/wdvxdr1123/ZeroBot/message"
@ -21,10 +21,9 @@ func init() { // 插件主体
}) })
// 定时任务每天10点执行一次 // 定时任务每天10点执行一次
c := cron.New() _, err := process.CronTab.AddFunc("0 10 * * *", func() { sendNotice() })
_, err := c.AddFunc("0 10 * * *", func() { sendNotice() }) if err != nil {
if err == nil { panic(err)
c.Start()
} }
} }

View File

@ -11,8 +11,9 @@ import (
"strings" "strings"
"time" "time"
"github.com/FloatTech/zbputils/binary"
control "github.com/FloatTech/zbputils/control" control "github.com/FloatTech/zbputils/control"
"github.com/fumiama/cron" "github.com/FloatTech/zbputils/process"
zero "github.com/wdvxdr1123/ZeroBot" zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message" "github.com/wdvxdr1123/ZeroBot/message"
@ -28,8 +29,7 @@ func init() {
}) })
// 定时任务每天8点执行一次 // 定时任务每天8点执行一次
c := cron.New() _, err := process.CronTab.AddFunc("* 8 * * *", func() {
_, err := c.AddFunc("* 8 * * *", func() {
m, ok := control.Lookup("moyucalendar") m, ok := control.Lookup("moyucalendar")
if !ok { if !ok {
return return
@ -48,8 +48,8 @@ func init() {
return true return true
}) })
}) })
if err == nil { if err != nil {
c.Start() panic(err)
} }
} }
@ -76,7 +76,7 @@ func crew() (string, error) {
if err != nil { if err != nil {
return "", err return "", err
} }
match := newest.FindStringSubmatch(string(b)) match := newest.FindStringSubmatch(binary.BytesToString(b))
if len(match) < 2 { if len(match) < 2 {
return "", errors.New("newest not found") return "", errors.New("newest not found")
} }
@ -112,7 +112,7 @@ func crew() (string, error) {
if err != nil { if err != nil {
return "", err return "", err
} }
matcha := weixin.FindStringSubmatch(string(b)) matcha := weixin.FindStringSubmatch(binary.BytesToString(b))
if len(matcha) < 2 { if len(matcha) < 2 {
continue continue
} }
@ -135,11 +135,14 @@ func crew() (string, error) {
return "", errors.New("status not ok") return "", errors.New("status not ok")
} }
bw, _ := ioutil.ReadAll(respw.Body) bw, _ := ioutil.ReadAll(respw.Body)
today := regexp.MustCompile(time.Now().Format("2006-01-02")) today, err := regexp.Compile(time.Now().Format("2006-01-02"))
if err != nil {
return "", err
}
if !today.Match(bw) { if !today.Match(bw) {
return "", errors.New("calendar not found") return "", errors.New("calendar not found")
} }
matchw := calendar.FindStringSubmatch(string(bw)) matchw := calendar.FindStringSubmatch(binary.BytesToString(bw))
if len(matchw) < 2 { if len(matchw) < 2 {
return "", errors.New("calendar not found") return "", errors.New("calendar not found")
} }