random commit
This commit is contained in:
@@ -7,16 +7,28 @@ import (
|
||||
"time"
|
||||
|
||||
twitch "github.com/gempir/go-twitch-irc/v4"
|
||||
helix "github.com/nicklaw5/helix"
|
||||
twitchapi "streambot_twitch/internal/twitchapi"
|
||||
)
|
||||
|
||||
// check Twitch API connectivity
|
||||
func TestTwitchAPI(client *twitchapi.Client, streamerChannel string) error {
|
||||
_, err := client.GetUserID(streamerChannel)
|
||||
userID, err := client.GetUserID(streamerChannel)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Twitch API test failed: %w", err)
|
||||
return fmt.Errorf("failed to get Usre ID: %w", err)
|
||||
}
|
||||
log.Println("Twitch API connection successful")
|
||||
resp, err := client.api.GetChannelInformation(&helix.GetChannelInformationParams{
|
||||
BroadcasterID: userID,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get channel information: %w", err)
|
||||
}
|
||||
if len(resp.Data.Channels) == 0 {
|
||||
return fmt.Errorf("no channel information found")
|
||||
}
|
||||
|
||||
log.Printf("Twitch API connection Test Successful for channel: %s", streamerChannel)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user