add youtube background

This commit is contained in:
Jay
2018-09-17 14:30:49 +08:00
parent e8db6fdab5
commit cfc1e43192
4 changed files with 46 additions and 0 deletions
+1
View File
@@ -12,5 +12,6 @@ func SetBackground() {
c.AddFunc("0 * * * * *", readFacebookPage)
c.AddFunc("*/20 * * * * *", getStreamStatus)
c.AddFunc("*/5 * * * * *", checkOpay)
c.AddFunc("0 0 */3 * * *", checkYoutubeSubscribe)
c.Start()
}
+20
View File
@@ -0,0 +1,20 @@
package background
import (
"time"
"git.trj.tw/golang/mtfosbot/model"
googleapis "git.trj.tw/golang/mtfosbot/module/apis/google"
)
func checkYoutubeSubscribe() {
e := time.Now().Unix() + (4 * 60 * 60)
yt, err := model.GetYoutubeChannelsWithExpire(e)
if err != nil || len(yt) == 0 {
return
}
for _, v := range yt {
googleapis.SubscribeYoutube(v.ID)
}
}