add twitch api

This commit is contained in:
Jay
2018-09-12 00:29:38 +08:00
parent fc007136db
commit f70d11517c
6 changed files with 250 additions and 8 deletions
+1
View File
@@ -10,5 +10,6 @@ var c *cron.Cron
func SetBackground() {
c = cron.New()
c.AddFunc("0 * * * * *", readFacebookPage)
c.AddFunc("*/20 * * * * *", getStreamStatus)
c.Start()
}
+32
View File
@@ -0,0 +1,32 @@
package background
import (
"fmt"
"git.trj.tw/golang/mtfosbot/module/utils"
"git.trj.tw/golang/mtfosbot/model"
"git.trj.tw/golang/mtfosbot/module/apis/twitch"
)
func getStreamStatus() {
fmt.Println("run twitch check")
channels, err := model.GetAllChannel()
if err != nil {
return
}
var ids []string
for _, v := range channels {
ids = append(ids, v.ID)
}
info := twitch.GetUserStreamStatus(ids)
fmt.Printf("info len: %d\n", len(info))
for _, v := range info {
fmt.Println(utils.ToMap(v))
}
}
func checkStream(ch *model.TwitchChannel) {
}