add youtube background
This commit is contained in:
parent
e8db6fdab5
commit
cfc1e43192
@ -19,6 +19,18 @@ type YoutubeChannel struct {
|
||||
Groups []*YoutubeGroup `db:"-"`
|
||||
}
|
||||
|
||||
// GetAllYoutubeChannels -
|
||||
func GetAllYoutubeChannels() (yt []*YoutubeChannel, err error) {
|
||||
err = x.Select(&yt, `select * from "public"."youtube_channel"`)
|
||||
return
|
||||
}
|
||||
|
||||
// GetYoutubeChannelsWithExpire -
|
||||
func GetYoutubeChannelsWithExpire(e int64) (yt []*YoutubeChannel, err error) {
|
||||
err = x.Select(&yt, `select * from "public"."youtube_channel" where "expire" = -1 or "expire" < $1`, e)
|
||||
return
|
||||
}
|
||||
|
||||
// GetYoutubeChannelWithID -
|
||||
func GetYoutubeChannelWithID(id string) (yt *YoutubeChannel, err error) {
|
||||
err = x.Get(&yt, `select * from "public"."youtube_channel" where "id" = $1`, id)
|
||||
|
@ -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
module/background/youtube.go
Normal file
20
module/background/youtube.go
Normal 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)
|
||||
}
|
||||
}
|
13
router/api/twitch.go
Normal file
13
router/api/twitch.go
Normal file
@ -0,0 +1,13 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"git.trj.tw/golang/mtfosbot/model"
|
||||
)
|
||||
|
||||
func sessionTypeTwitch(id string) (ch []*model.TwitchChannel, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func sessionTypeSystem() (ch []*model.TwitchChannel, err error) {
|
||||
return
|
||||
}
|
Loading…
Reference in New Issue
Block a user