add twitch api
This commit is contained in:
@@ -10,5 +10,6 @@ var c *cron.Cron
|
||||
func SetBackground() {
|
||||
c = cron.New()
|
||||
c.AddFunc("0 * * * * *", readFacebookPage)
|
||||
c.AddFunc("*/20 * * * * *", getStreamStatus)
|
||||
c.Start()
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user