feat: add twitch channel points miner runtime

This commit is contained in:
2026-04-29 22:33:55 +02:00
parent 1147f4d25b
commit b631d201b0
12 changed files with 1640 additions and 19 deletions
+39
View File
@@ -3,6 +3,8 @@
// and streamer login resolution without exposing raw payload assembly to callers.
package gql
import "strings"
// persistedQuery stores the persisted-query metadata Twitch expects.
type persistedQuery struct {
Version int `json:"version"`
@@ -85,3 +87,40 @@ func WithIsStreamLiveQuery(channelID string) Request {
"id": channelID,
})
}
// ChannelPointsContext fetches channel points state for one streamer login.
func ChannelPointsContext(login string) Request {
return operation("ChannelPointsContext", "1530a003a7d374b0380b79db0be0534f30ff46e61cffa2bc0e2468a909fbc024", map[string]any{
"channelLogin": login,
})
}
// ClaimCommunityPoints claims an available channel points bonus chest.
func ClaimCommunityPoints(channelID, claimID string) Request {
return operation("ClaimCommunityPoints", "46aaeebe02c99afdf4fc97c7c0cba964124bf6b0af229395f1f6d1feed05b3d0", map[string]any{
"input": map[string]any{
"channelID": channelID,
"claimID": claimID,
},
})
}
// VideoPlayerStreamInfoOverlayChannel fetches stream metadata used for watch telemetry.
func VideoPlayerStreamInfoOverlayChannel(login string) Request {
return operation("VideoPlayerStreamInfoOverlayChannel", "198492e0857f6aedead9665c81c5a06d67b25b58034649687124083ff288597d", map[string]any{
"channel": login,
})
}
// HLSMasterPlaylistURL builds the usher URL Twitch uses for live playback.
func HLSMasterPlaylistURL(login, signature, token string) string {
var builder strings.Builder
builder.Grow(len(login) + len(signature) + len(token) + 80)
builder.WriteString("https://usher.ttvnw.net/api/channel/hls/")
builder.WriteString(login)
builder.WriteString(".m3u8?player=twitchweb&allow_source=true&type=any&p=1&sig=")
builder.WriteString(signature)
builder.WriteString("&token=")
builder.WriteString(token)
return builder.String()
}