add twitch API stuff, add follow/sub/cheer labels
This commit is contained in:
parent
8a7210ad56
commit
626540e728
17 changed files with 1143 additions and 3 deletions
27
main.go
27
main.go
|
|
@ -12,6 +12,8 @@ import (
|
|||
|
||||
"codeberg.org/arimelody/ari-stream-tools/learning"
|
||||
"codeberg.org/arimelody/ari-stream-tools/music"
|
||||
"codeberg.org/arimelody/ari-stream-tools/twitch"
|
||||
"codeberg.org/arimelody/ari-stream-tools/utils/dotenv"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
|
|
@ -23,6 +25,13 @@ func main() {
|
|||
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
||||
defer cancel()
|
||||
|
||||
envars, err := dotenv.LoadEnv()
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
log.Fatalf("Failed to read .env: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
|
||||
host := DEFAULT_HOST
|
||||
|
|
@ -43,12 +52,30 @@ func main() {
|
|||
TitleFilePath: "learning-title.txt",
|
||||
})
|
||||
musicService := music.New(ctx)
|
||||
twitchService, err := twitch.New(ctx, twitch.ServiceOptions{
|
||||
Port: port,
|
||||
ChannelName: dotenv.SafeGet(envars, "TWITCH_CHANNEL_NAME"),
|
||||
ClientID: dotenv.SafeGet(envars, "TWITCH_CLIENT_ID"),
|
||||
ClientSecret: dotenv.SafeGet(envars, "TWITCH_CLIENT_SECRET"),
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create Twitch service: %v", err)
|
||||
}
|
||||
|
||||
srv := gin.Default()
|
||||
srv.Use(gin.LoggerWithConfig(gin.LoggerConfig{
|
||||
SkipPaths: []string{
|
||||
"/twitch/public",
|
||||
"/music/public",
|
||||
"/learning/public",
|
||||
},
|
||||
}))
|
||||
learningService.BindRoutes(srv.Group("/learning"))
|
||||
musicService.BindRoutes(srv.Group("/music"))
|
||||
twitchService.BindRoutes(srv.Group("/twitch"))
|
||||
|
||||
go musicService.Run(ctx)
|
||||
go twitchService.Run(ctx)
|
||||
go func() {
|
||||
log.Printf("Now serving at http://%s:%d\n", host, port)
|
||||
failed <- srv.Run(fmt.Sprintf("%s:%d", host, port))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue