twitch

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrInvalidState state configured between request and response
	ErrInvalidState = errors.New("invalid state coming from Twitch")
)
View Source
var (
	ErrTooManyLoginNames = errors.New("too many login sets. Cannot be more than 100")
)
View Source
var (
	ErrTooManyUserLoginNames = errors.New("too many user login sets. Cannot be more than 100")
)

Functions

This section is empty.

Types

type Client

type Client struct {

	// Available public methods on client
	Streams StreamsI
	Users   UsersI
	// contains filtered or unexported fields
}

func New

func New(config *Config) (*Client, error)

New returns a new Twitch client

type Config

type Config struct {
	ClientID     string
	ClientSecret string
}

type Error

type Error struct {
	Err     string `json:"error"`
	Status  int    `json:"status"`
	Message string `json:"message"`
}

Error describes a Twitch error

func (Error) Error

func (e Error) Error() string

type Stream

type Stream struct {
	GameID       string    `json:"game_id,omitempty"`
	GameName     string    `json:"game_name,omitempty"`
	ID           string    `json:"id,omitempty"`
	IsMature     bool      `json:"is_mature,omitempty"`
	Language     string    `json:"language,omitempty"`
	StartedAt    time.Time `json:"started_at,omitempty"`
	TagIds       []string  `json:"tag_ids,omitempty"`
	ThumbnailURL string    `json:"thumbnail_url,omitempty"`
	Title        string    `json:"title,omitempty"`
	Type         string    `json:"type,omitempty"`
	UserID       string    `json:"user_id,omitempty"`
	UserLogin    string    `json:"user_login,omitempty"`
	UserName     string    `json:"user_name,omitempty"`
	ViewerCount  int       `json:"viewer_count,omitempty"`
}

Stream describes a Twitch stream

type StreamsI

type StreamsI interface {
	// GetStream returns information about active streams.
	// Streams are returned sorted by number of current viewers, in descending order.
	// If any, returns streams broadcast by one or more specified user login names. You can specify up to 100 names.
	// https://dev.twitch.tv/docs/api/reference#get-streams
	GetStream(userLogin ...string) ([]*Stream, error)

	// GetFollowed returns information about active streams belonging to channels that the authenticated user follows.
	// Streams are returned sorted by number of current viewers, in descending order.
	// Across multiple pages of results, there may be duplicate or missing streams, as viewers join and leave streams.
	// https://dev.twitch.tv/docs/api/reference#get-followed-streams
	GetFollowed() ([]*Stream, error)
}

type User

type User struct {
	BroadcasterType string    `json:"broadcaster_type"`
	CreatedAt       time.Time `json:"created_at"`
	Description     string    `json:"description"`
	DisplayName     string    `json:"display_name"`
	ID              string    `json:"id"`
	Login           string    `json:"login"`
	OfflineImageURL string    `json:"offline_image_url"`
	ProfileImageURL string    `json:"profile_image_url"`
	Type            string    `json:"type"`
	ViewCount       int       `json:"view_count"`
}

User describes a Twitch user

type UsersI

type UsersI interface {
	// Get returns information about one or more specified Twitch users.
	// Users are identified by optional user IDs and/or login name.
	// If neither a user ID nor a login name is specified, the user is looked up by Bearer token.
	// https://dev.twitch.tv/docs/api/reference#get-users
	Get(login ...string) ([]*User, error)

	// ProfileImageBytes load the given profile from URL
	// Reduce its size and send it as bytes
	ProfileImageBytes(user *User) ([]byte, error)

	// Me returns current connected user
	Me() *User
}

Jump to

Keyboard shortcuts

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