Documentation ¶
Overview ¶
Package twitchnotify provides functionalities to watch the state of twitch streams and notifying changes by polling the twitch REST API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type Credentials ¶
type Credentials struct { ClientID string `json:"client_id"` ClientSecret string `json:"client_secret"` }
Credentials hold the client ID and client secret of a twitch API application.
type Game ¶
type Game struct { ID string `json:"id"` Name string `json:"name"` IconURL string `json:"box_art_url"` }
Game wraps information about a twitch game type.
type NotifyHandler ¶
NotifyHandler describes a callback handler when a stream either goes online or offline passing the stream data as well as the user data of the streamer.
type NotifyWorker ¶
type NotifyWorker struct {
// contains filtered or unexported fields
}
NotifyWorker provides general utilities to fetch watched online streamers and call notify handler callbacks when a stream goes online or offline.
func New ¶
func New( creds Credentials, wentOnlineHandler NotifyHandler, wentOfflineHandler NotifyHandler, config ...Config, ) (worker *NotifyWorker, err error)
New initializes a new NotifyWorker instance and starts the worker timer loop.
func (*NotifyWorker) AddUser ¶
func (w *NotifyWorker) AddUser(u *User) error
AddUser adds the specified twitch User to the watch list. If maxUserCap is reached, an ErrMaxUsersreached error is returned.
func (*NotifyWorker) GetUser ¶
func (w *NotifyWorker) GetUser(identifyer string, typ UserIdent) (*User, error)
GetUser tries to fetch a user either by login or by ID, specified by typ which one of these methods is used. Returns the fetched user object and occured errors during fetch.
func (*NotifyWorker) Handle ¶
func (w *NotifyWorker) Handle() error
Handle is the callback function executed on ech timer tick.
type Stream ¶
type Stream struct { ID string `json:"id"` UserID string `json:"user_id"` UserName string `json:"user_name"` GameID string `json:"game_id"` CommunityIDs []string `json:"community_ids"` Type string `json:"type"` Title string `json:"title"` ViewerCount int `json:"viewer_count"` StartedAt string `json:"started_at"` Language string `json:"language"` ThumbnailURL string `json:"thumbnail_url"` Game *Game }
Stream wraps information about a twitch stream.