api

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrefFormExplicitKey   = "explicit"
	PrefFormSongLengthKey = "song-length"
)
View Source
const (
	SongRequestsTitle = "TwitchSongRequests"
)

Variables

This section is empty.

Functions

func CheckSpotifyUser

func CheckSpotifyUser(ctx context.Context, client *spotify.Client, redeemEvent *helix.EventSubChannelPointsCustomRewardRedemptionEvent)

func DoNothingOnSuccess

func DoNothingOnSuccess(auth *util.AuthConfig,
	userStore db.UserStore,
	event *helix.EventSubChannelPointsCustomRewardRedemptionEvent,
	success bool) error

DoNothingOnSuccess is a no-op to satisfy the function interface. See https://github.com/SaxyPandaBear/TwitchSongRequests/issues/133

func IsRevocationRequest

func IsRevocationRequest(r *http.Request) bool

func IsValidReward

func IsValidReward(e *helix.EventSubChannelPointsCustomRewardRedemptionEvent) bool

IsValidReward ensures that the redemption event has a title which contains the named keyword. This is a naive approach for dropping unwanted events.

func IsVerificationRequest

func IsVerificationRequest(r *http.Request) bool

func UpdateRedemptionStatus

func UpdateRedemptionStatus(auth *util.AuthConfig,
	userStore db.UserStore,
	event *helix.EventSubChannelPointsCustomRewardRedemptionEvent,
	success bool) error

TODO: this doesn't work unless the application manages the channel point reward

see https://github.com/SaxyPandaBear/TwitchSongRequests/issues/133

Types

type EventSubHandler

type EventSubHandler struct {
	// contains filtered or unexported fields
}

func NewEventSubHandler

func NewEventSubHandler(u db.UserStore, auth *util.AuthConfig, callbackURL, secret string) *EventSubHandler

func (*EventSubHandler) SubscribeToTopic

func (e *EventSubHandler) SubscribeToTopic(w http.ResponseWriter, r *http.Request)

SubscribeToTopic

type EventSubNotification

type EventSubNotification struct {
	Subscription helix.EventSubSubscription `json:"subscription"`
	Challenge    string                     `json:"challenge"`
	Event        json.RawMessage            `json:"event"`
}

type PreferenceHandler

type PreferenceHandler struct {
	// contains filtered or unexported fields
}

func NewPreferenceHandler

func NewPreferenceHandler(d db.PreferenceStore, redirectURL string) *PreferenceHandler

func (*PreferenceHandler) SavePreferences

func (h *PreferenceHandler) SavePreferences(w http.ResponseWriter, r *http.Request)

type RewardHandler

type RewardHandler struct {

	// OnSuccess is a callback function that executes after successfully
	// publishing to the queue
	OnSuccess func(*util.AuthConfig, db.UserStore, *helix.EventSubChannelPointsCustomRewardRedemptionEvent, bool) error
	CheckUser func(context.Context, *spotify.Client, *helix.EventSubChannelPointsCustomRewardRedemptionEvent)
	// contains filtered or unexported fields
}

func NewRewardHandler

func NewRewardHandler(config *RewardHandlerConfig) *RewardHandler

func (*RewardHandler) ChannelPointRedeem

func (h *RewardHandler) ChannelPointRedeem(w http.ResponseWriter, r *http.Request)

type RewardHandlerConfig

type RewardHandlerConfig struct {
	Secret    string
	Publisher queue.Publisher
	UserStore db.UserStore
	PrefStore db.PreferenceStore
	MsgCount  db.MessageCounter
	Twitch    *util.AuthConfig
	Spotify   *util.AuthConfig
}

type SpotifyAuthZHandler

type SpotifyAuthZHandler struct {
	// contains filtered or unexported fields
}

func NewSpotifyAuthZHandler

func NewSpotifyAuthZHandler(url string, auth *util.AuthConfig, userStore db.UserStore) *SpotifyAuthZHandler

type StatsHandler

type StatsHandler struct {
	// contains filtered or unexported fields
}

func NewStatsHandler

func NewStatsHandler(counter db.MessageCounter) *StatsHandler

func (*StatsHandler) RunningCount

func (h *StatsHandler) RunningCount(w http.ResponseWriter, r *http.Request)

func (*StatsHandler) TotalMessages

func (h *StatsHandler) TotalMessages(w http.ResponseWriter, r *http.Request)

type SubscribeRequest

type SubscribeRequest struct {
	UserID string `json:"user_id"`
}

type SvgData

type SvgData struct {
	SchemaVersion int    `json:"schemaVersion"`
	Label         string `json:"label"`
	Message       string `json:"message"`
	Color         string `json:"color"`
	Style         string `json:"style"`
}

https://shields.io/endpoint schema

type TwitchAuthZHandler

type TwitchAuthZHandler struct {
	// contains filtered or unexported fields
}

func NewTwitchAuthZHandler

func NewTwitchAuthZHandler(url string, auth *util.AuthConfig, userStore db.UserStore, prefStore db.PreferenceStore) *TwitchAuthZHandler

func (*TwitchAuthZHandler) Authorize

func (h *TwitchAuthZHandler) Authorize(w http.ResponseWriter, r *http.Request)

Authorize handles the callback from the OAuth authorization

type UserHandler

type UserHandler struct {
	// contains filtered or unexported fields
}

func NewUserHandler

func NewUserHandler(d db.UserStore, p db.PreferenceStore, redirectURL string, twitch, spotify *util.AuthConfig) *UserHandler

func (*UserHandler) RevokeUserAccesses

func (h *UserHandler) RevokeUserAccesses(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL