twitch

package
v0.0.0-...-4c63195 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelData

type ChannelData struct {
	ID           string    `json:"id"`
	UserID       string    `json:"user_id"`
	GameID       string    `json:"game_id"`
	Type         string    `json:"type"`
	Title        string    `json:"title"`
	ViewerCount  int       `json:"viewer_count"`
	StartedAt    time.Time `json:"started_at"`
	Language     string    `json:"language"`
	ThumbnailURL string    `json:"thumbnail_url"`
}

ChannelData ...

type Database

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

Database is the struct for holding the main database and the two buckets

var (
	DB *Database
)

func NewDB

func NewDB() *Database

NewDB returns a new database

func (*Database) AddChannel

func (d *Database) AddChannel(twitchName, channel string, hook *Webhook) (err error)

AddChannel adds a twitch channel to motitor and adds the channelID + webhook to be notified

func (*Database) Close

func (d *Database) Close()

Close closes the current databse

func (*Database) DeleteWebhook

func (d *Database) DeleteWebhook(twitchName, wID, cID string) (err error)

DeleteWebhook deletes a webhook from a twitch channel

func (*Database) GetAllTwitchChannels

func (d *Database) GetAllTwitchChannels() (channels []string, err error)

GetAllTwitchChannels returns all the twitch channels being tracked

func (*Database) GetGameByID

func (d *Database) GetGameByID(id string) (gameData *GameData, err error)

GetGameByID returns a twitch game by it's ID it tries to see if the game is cached and if not calls the twitch api and caches response

func (*Database) GetTwitchNamesByChannel

func (d *Database) GetTwitchNamesByChannel(cID string) (names []string, err error)

GetTwitchNamesByChannel return all the tracked twitch names from a discord channel

func (*Database) GetUserByID

func (d *Database) GetUserByID(id string) (userData *UserData, err error)

GetUserByID returns a twitch user by their id it tries to see if the user is cached and if not calls the twitch api and caches response

func (*Database) GetWebhooksByTwitchName

func (d *Database) GetWebhooksByTwitchName(twitchName string) (hooks []*Webhook, err error)

GetWebhooksByTwitchName returns a slice of all the webhooks for a twitch channel

type GameData

type GameData struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	BoxArtURL string `json:"box_art_url"`
}

GameData holds info about a specific game

type GamesResponse

type GamesResponse struct {
	Data []*GameData `json:"data"`
}

GamesResponse is the data structure for the twitch games endpoint

type StreamsResponse

type StreamsResponse struct {
	Data []*ChannelData `json:"data"`
}

StreamsResponse ..

type Twitch

type Twitch struct {
	ClientID string
	// contains filtered or unexported fields
}

Twitch is the struct that holds the basic info for the package

var API *Twitch

func NewAPI

func NewAPI(clientID string) *Twitch

NewAPI ...

func (*Twitch) GetGameByID

func (t *Twitch) GetGameByID(id string) (*GameData, error)

GetGameByID ...

func (*Twitch) GetUserByID

func (t *Twitch) GetUserByID(id string) (*UserData, error)

GetUserByID polls the twitch api for a user by their id

func (*Twitch) Open

func (t *Twitch) Open(twitchdb *Database, interval int64)

Open ...

func (*Twitch) RequestChannels

func (t *Twitch) RequestChannels(channels []string) (*StreamsResponse, error)

RequestChannels requests a list of channels

type UserData

type UserData struct {
	ID              string `json:"id"`
	Login           string `json:"login"`
	DisplayName     string `json:"display_name"`
	Type            string `json:"type"`
	BroadcasterType string `json:"broadcaster_type"`
	Description     string `json:"description"`
	ProfileImageURL string `json:"profile_image_url"`
	OfflineImageURL string `json:"offline_image_url"`
	ViewCount       int    `json:"view_count"`
}

UserData holds info about a specific twitch streamer

type UsersResponse

type UsersResponse struct {
	Data []*UserData `json:"data"`
}

UsersResponse is the data structure for the twitch users endpoint

type Webhook

type Webhook struct {
	Channel string `json:"channel"` // discord channel id
	ID      string `json:"id"`      // webhook id
	Token   string `json:"token"`   // webhook token
}

Webhook stores the data of a single webhook

Jump to

Keyboard shortcuts

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