twitch

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2023 License: MIT Imports: 10 Imported by: 0

README

Twitch Eventsub

Go Report Card Software License GoDoc tests

Implements a Twitch EventSub Websocket connection

If a websocket connection has no subscriptions, then it will close automatically on twitch's end so call client.OnWelcome and subscribe there after getting the subscription ID.

Example

package main

import (
	"fmt"

	"github.com/joeyak/go-twitch-eventsub"
)

var (
	userID = "<USERID>"
	accessToken = "<ACCESSTOKEN>"
	clientID = "<CLIENTID>"
)

func main() {
	client := twitch.NewClient()

	client.OnError(func(err error) {
		fmt.Printf("ERROR: %v\n", err)
	})
	client.OnWelcome(func(message twitch.WelcomeMessage) {
		fmt.Printf("WELCOME: %v\n", message)

		events := []twitch.EventSubscription{
			twitch.SubStreamOnline,
			twitch.SubStreamOffline,
		}

		for _, event := range events {
			fmt.Printf("subscribing to %s\n", event)
			_, err := twitch.SubscribeEvent(twitch.SubscribeRequest{
				SessionID:   message.Payload.Session.ID,
				ClientID:    clientID,
				AccessToken: accessToken,
				Event:       event,
				Condition: map[string]string{
					"broadcaster_user_id": userID,
				},
			})
			if err != nil {
				fmt.Printf("ERROR: %v\n", err)
				return
			}
		}
	})
	client.OnNotification(func(message twitch.NotificationMessage) {
		fmt.Printf("NOTIFICATION: %s: %#v\n", message.Payload.Subscription.Type, message.Payload.Event)
	})
	client.OnKeepAlive(func(message twitch.KeepAliveMessage) {
		fmt.Printf("KEEPALIVE: %v\n", message)
	})
	client.OnRevoke(func(message twitch.RevokeMessage) {
		fmt.Printf("REVOKE: %v\n", message)
	})
	client.OnRawEvent(func(event string, metadata MessageMetadata, eventType EventSubscription) {
		fmt.Printf("EVENT[%s]: %s: %s\n", eventType, metadata, event)
	})

	err := client.Connect()
	if err != nil {
		fmt.Printf("Could not connect client: %v\n", err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConnClosed   = fmt.Errorf("connection closed")
	ErrNilOnWelcome = fmt.Errorf("OnWelcome function was not set")
)

Functions

This section is empty.

Types

type BaseCharity added in v0.1.16

type BaseCharity struct {
	Broadcaster
	User

	CharityName        string `json:"charity_name"`
	CharityDescription string `json:"charity_description"`
	CharityWebsite     string `json:"charity_website"`
}

type Broadcaster added in v0.1.9

type Broadcaster struct {
	BroadcasterUserId    string `json:"broadcaster_user_id"`
	BroadcasterUserLogin string `json:"broadcaster_user_login"`
	BroadcasterUserName  string `json:"broadcaster_user_name"`
}

type ChannelPointReward added in v0.1.3

type ChannelPointReward struct {
	ID     string `json:"id"`
	Title  string `json:"title"`
	Cost   int    `json:"cost"`
	Prompt string `json:"prompt"`
}

type Client added in v0.1.1

type Client struct {
	Address string
	// contains filtered or unexported fields
}

func NewClient added in v0.1.1

func NewClient() *Client

func NewClientWithUrl added in v0.1.1

func NewClientWithUrl(url string) *Client

func (*Client) Close added in v0.1.1

func (c *Client) Close() error

func (*Client) Connect added in v0.1.1

func (c *Client) Connect() error

func (*Client) ConnectWithContext added in v0.1.1

func (c *Client) ConnectWithContext(ctx context.Context) error

func (*Client) OnError added in v0.1.1

func (c *Client) OnError(callback func(err error))

func (*Client) OnEventChannelBan added in v0.1.2

func (c *Client) OnEventChannelBan(callback func(event EventChannelBan))

func (*Client) OnEventChannelChannelPointsCustomRewardAdd added in v0.1.3

func (c *Client) OnEventChannelChannelPointsCustomRewardAdd(callback func(event EventChannelChannelPointsCustomRewardAdd))

func (*Client) OnEventChannelChannelPointsCustomRewardRedemptionAdd added in v0.1.3

func (c *Client) OnEventChannelChannelPointsCustomRewardRedemptionAdd(callback func(event EventChannelChannelPointsCustomRewardRedemptionAdd))

func (*Client) OnEventChannelChannelPointsCustomRewardRedemptionUpdate added in v0.1.3

func (c *Client) OnEventChannelChannelPointsCustomRewardRedemptionUpdate(callback func(event EventChannelChannelPointsCustomRewardRedemptionUpdate))

func (*Client) OnEventChannelChannelPointsCustomRewardRemove added in v0.1.3

func (c *Client) OnEventChannelChannelPointsCustomRewardRemove(callback func(event EventChannelChannelPointsCustomRewardRemove))

func (*Client) OnEventChannelChannelPointsCustomRewardUpdate added in v0.1.3

func (c *Client) OnEventChannelChannelPointsCustomRewardUpdate(callback func(event EventChannelChannelPointsCustomRewardUpdate))

func (*Client) OnEventChannelCharityCampaignDonate added in v0.1.16

func (c *Client) OnEventChannelCharityCampaignDonate(callback func(event EventChannelCharityCampaignDonate))

func (*Client) OnEventChannelCharityCampaignProgress added in v0.1.16

func (c *Client) OnEventChannelCharityCampaignProgress(callback func(event EventChannelCharityCampaignProgress))

func (*Client) OnEventChannelCharityCampaignStart added in v0.1.16

func (c *Client) OnEventChannelCharityCampaignStart(callback func(event EventChannelCharityCampaignStart))

func (*Client) OnEventChannelCharityCampaignStop added in v0.1.16

func (c *Client) OnEventChannelCharityCampaignStop(callback func(event EventChannelCharityCampaignStop))

func (*Client) OnEventChannelCheer added in v0.1.3

func (c *Client) OnEventChannelCheer(callback func(event EventChannelCheer))

func (*Client) OnEventChannelFollow added in v0.1.2

func (c *Client) OnEventChannelFollow(callback func(event EventChannelFollow))

func (*Client) OnEventChannelGoalBegin added in v0.1.3

func (c *Client) OnEventChannelGoalBegin(callback func(event EventChannelGoalBegin))

func (*Client) OnEventChannelGoalEnd added in v0.1.3

func (c *Client) OnEventChannelGoalEnd(callback func(event EventChannelGoalEnd))

func (*Client) OnEventChannelGoalProgress added in v0.1.3

func (c *Client) OnEventChannelGoalProgress(callback func(event EventChannelGoalProgress))

func (*Client) OnEventChannelHypeTrainBegin added in v0.1.3

func (c *Client) OnEventChannelHypeTrainBegin(callback func(event EventChannelHypeTrainBegin))

func (*Client) OnEventChannelHypeTrainEnd added in v0.1.3

func (c *Client) OnEventChannelHypeTrainEnd(callback func(event EventChannelHypeTrainEnd))

func (*Client) OnEventChannelHypeTrainProgress added in v0.1.3

func (c *Client) OnEventChannelHypeTrainProgress(callback func(event EventChannelHypeTrainProgress))

func (*Client) OnEventChannelModeratorAdd added in v0.1.3

func (c *Client) OnEventChannelModeratorAdd(callback func(event EventChannelModeratorAdd))

func (*Client) OnEventChannelModeratorRemove added in v0.1.3

func (c *Client) OnEventChannelModeratorRemove(callback func(event EventChannelModeratorRemove))

func (*Client) OnEventChannelPollBegin added in v0.1.3

func (c *Client) OnEventChannelPollBegin(callback func(event EventChannelPollBegin))

func (*Client) OnEventChannelPollEnd added in v0.1.3

func (c *Client) OnEventChannelPollEnd(callback func(event EventChannelPollEnd))

func (*Client) OnEventChannelPollProgress added in v0.1.3

func (c *Client) OnEventChannelPollProgress(callback func(event EventChannelPollProgress))

func (*Client) OnEventChannelPredictionBegin added in v0.1.3

func (c *Client) OnEventChannelPredictionBegin(callback func(event EventChannelPredictionBegin))

func (*Client) OnEventChannelPredictionEnd added in v0.1.3

func (c *Client) OnEventChannelPredictionEnd(callback func(event EventChannelPredictionEnd))

func (*Client) OnEventChannelPredictionLock added in v0.1.3

func (c *Client) OnEventChannelPredictionLock(callback func(event EventChannelPredictionLock))

func (*Client) OnEventChannelPredictionProgress added in v0.1.3

func (c *Client) OnEventChannelPredictionProgress(callback func(event EventChannelPredictionProgress))

func (*Client) OnEventChannelRaid added in v0.1.3

func (c *Client) OnEventChannelRaid(callback func(event EventChannelRaid))

func (*Client) OnEventChannelShieldModeBegin added in v0.1.16

func (c *Client) OnEventChannelShieldModeBegin(callback func(event EventChannelShieldModeBegin))

func (*Client) OnEventChannelShieldModeEnd added in v0.1.16

func (c *Client) OnEventChannelShieldModeEnd(callback func(event EventChannelShieldModeEnd))

func (*Client) OnEventChannelSubscribe added in v0.1.2

func (c *Client) OnEventChannelSubscribe(callback func(event EventChannelSubscribe))

func (*Client) OnEventChannelSubscriptionEnd added in v0.1.2

func (c *Client) OnEventChannelSubscriptionEnd(callback func(event EventChannelSubscriptionEnd))

func (*Client) OnEventChannelSubscriptionGift added in v0.1.2

func (c *Client) OnEventChannelSubscriptionGift(callback func(event EventChannelSubscriptionGift))

func (*Client) OnEventChannelSubscriptionMessage added in v0.1.2

func (c *Client) OnEventChannelSubscriptionMessage(callback func(event EventChannelSubscriptionMessage))

func (*Client) OnEventChannelUnban added in v0.1.2

func (c *Client) OnEventChannelUnban(callback func(event EventChannelUnban))

func (*Client) OnEventChannelUpdate added in v0.1.2

func (c *Client) OnEventChannelUpdate(callback func(event EventChannelUpdate))

func (*Client) OnEventDropEntitlementGrant added in v0.1.3

func (c *Client) OnEventDropEntitlementGrant(callback func(event []EventDropEntitlementGrant))

func (*Client) OnEventExtensionBitsTransactionCreate added in v0.1.3

func (c *Client) OnEventExtensionBitsTransactionCreate(callback func(event EventExtensionBitsTransactionCreate))

func (*Client) OnEventStreamOffline added in v0.1.3

func (c *Client) OnEventStreamOffline(callback func(event EventStreamOffline))

func (*Client) OnEventStreamOnline added in v0.1.3

func (c *Client) OnEventStreamOnline(callback func(event EventStreamOnline))

func (*Client) OnEventUserAuthorizationGrant added in v0.1.3

func (c *Client) OnEventUserAuthorizationGrant(callback func(event EventUserAuthorizationGrant))

func (*Client) OnEventUserAuthorizationRevoke added in v0.1.3

func (c *Client) OnEventUserAuthorizationRevoke(callback func(event EventUserAuthorizationRevoke))

func (*Client) OnEventUserUpdate added in v0.1.3

func (c *Client) OnEventUserUpdate(callback func(event EventUserUpdate))

func (*Client) OnKeepAlive added in v0.1.1

func (c *Client) OnKeepAlive(callback func(message KeepAliveMessage))

func (*Client) OnNotification added in v0.1.1

func (c *Client) OnNotification(callback func(message NotificationMessage))

func (*Client) OnRawEvent added in v0.1.4

func (c *Client) OnRawEvent(callback func(event string, metadata MessageMetadata, eventType EventSubscription))

func (*Client) OnReconnect added in v0.1.1

func (c *Client) OnReconnect(callback func(message ReconnectMessage))

func (*Client) OnRevoke added in v0.1.1

func (c *Client) OnRevoke(callback func(message RevokeMessage))

func (*Client) OnWelcome added in v0.1.1

func (c *Client) OnWelcome(callback func(message WelcomeMessage))

type DropEntitlement added in v0.1.3

type DropEntitlement struct {
	User

	OrganizationId string    `json:"organization_id"`
	CategoryId     string    `json:"category_id"`
	CategoryName   string    `json:"category_name"`
	CampaignId     string    `json:"campaign_id"`
	EntitlementId  string    `json:"entitlement_id"`
	BenefitId      string    `json:"benefit_id"`
	CreatedAt      time.Time `json:"created_at"`
}

type Emote added in v0.1.3

type Emote struct {
	ID    string `json:"id"`
	Begin int    `json:"begin"`
	End   int    `json:"end"`
}

type EventChannelBan added in v0.1.2

type EventChannelBan struct {
	User
	Broadcaster
	Moderator

	Reason      string `json:"reason"`
	BannedAt    string `json:"banned_at"`
	EndsAt      string `json:"ends_at"`
	IsPermanent bool   `json:"is_permanent"`
}

type EventChannelChannelPointsCustomRewardAdd added in v0.1.3

type EventChannelChannelPointsCustomRewardAdd struct {
	Broadcaster

	ID                                string                    `json:"id"`
	IsEnabled                         bool                      `json:"is_enabled"`
	IsPaused                          bool                      `json:"is_paused"`
	IsInStock                         bool                      `json:"is_in_stock"`
	Title                             string                    `json:"title"`
	Cost                              int                       `json:"cost"`
	Prompt                            string                    `json:"prompt"`
	IsUserInputRequired               bool                      `json:"is_user_input_required"`
	ShouldRedemptionsSkipRequestQueue bool                      `json:"should_redemptions_skip_request_queue"`
	MaxPerStream                      MaxChannelPointsPerStream `json:"max_per_stream"`
	MaxPerUserPerStream               MaxChannelPointsPerStream `json:"max_per_user_per_stream"`
	BackgroundColor                   string                    `json:"background_color"`
	Image                             Image                     `json:"image"`
	DefaultImage                      Image                     `json:"default_image"`
	GlobalCooldown                    GlobalCooldown            `json:"global_cooldown"`
	CooldownExpiresAt                 time.Time                 `json:"cooldown_expires_at"`
	RedemptionsRedeemedCurrentStream  int                       `json:"redemptions_redeemed_current_stream"`
}

type EventChannelChannelPointsCustomRewardRedemptionAdd added in v0.1.3

type EventChannelChannelPointsCustomRewardRedemptionAdd struct {
	Broadcaster
	User

	ID         string             `json:"id"`
	UserInput  string             `json:"user_input"`
	Status     string             `json:"status"`
	Reward     ChannelPointReward `json:"reward"`
	RedeemedAt time.Time          `json:"redeemed_at"`
}

type EventChannelChannelPointsCustomRewardRedemptionUpdate added in v0.1.3

type EventChannelChannelPointsCustomRewardRedemptionUpdate EventChannelChannelPointsCustomRewardRedemptionAdd

type EventChannelChannelPointsCustomRewardRemove added in v0.1.3

type EventChannelChannelPointsCustomRewardRemove EventChannelChannelPointsCustomRewardAdd

type EventChannelChannelPointsCustomRewardUpdate added in v0.1.3

type EventChannelChannelPointsCustomRewardUpdate EventChannelChannelPointsCustomRewardAdd

type EventChannelCharityCampaignDonate added in v0.1.16

type EventChannelCharityCampaignDonate struct {
	BaseCharity

	Amount GoalAmount `json:"amount"`
}

type EventChannelCharityCampaignProgress added in v0.1.16

type EventChannelCharityCampaignProgress struct {
	BaseCharity

	CurrentAmount GoalAmount `json:"current_amount"`
	TargetAmount  GoalAmount `json:"target_amount"`
}

type EventChannelCharityCampaignStart added in v0.1.16

type EventChannelCharityCampaignStart struct {
	EventChannelCharityCampaignProgress

	StartedAt time.Time `json:"started_at"`
}

type EventChannelCharityCampaignStop added in v0.1.16

type EventChannelCharityCampaignStop struct {
	EventChannelCharityCampaignProgress

	StoppedAt time.Time `json:"stopped_at"`
}

type EventChannelCheer added in v0.1.3

type EventChannelCheer struct {
	User
	Broadcaster

	Message     string `json:"message"`
	Bits        int    `json:"bits"`
	IsAnonymous bool   `json:"is_anonymous"`
}

type EventChannelFollow added in v0.1.2

type EventChannelFollow struct {
	User
	Broadcaster

	FollowedAt time.Time `json:"followed_at"`
}

type EventChannelGoalBegin added in v0.1.3

type EventChannelGoalBegin struct {
	Broadcaster

	ID                 string    `json:"id"`
	CharityName        string    `json:"charity_name"`
	CharityDescription string    `json:"charity_description"`
	CharityWebsite     string    `json:"charity_website"`
	CurrentAmount      int       `json:"current_amount"`
	TargetAmount       int       `json:"target_amount"`
	StoppedAt          time.Time `json:"stopped_at"`
}

type EventChannelGoalEnd added in v0.1.3

type EventChannelGoalEnd EventChannelGoalBegin

type EventChannelGoalProgress added in v0.1.3

type EventChannelGoalProgress EventChannelGoalBegin

type EventChannelHypeTrainBegin added in v0.1.3

type EventChannelHypeTrainBegin struct {
	Broadcaster

	Id               string                  `json:"id"`
	Total            int                     `json:"total"`
	Progress         int                     `json:"progress"`
	Goal             int                     `json:"goal"`
	TopContributions []HypeTrainContribution `json:"top_contributions"`
	LastContribution HypeTrainContribution   `json:"last_contribution"`
	Level            int                     `json:"level"`
	StartedAt        time.Time               `json:"started_at"`
	ExpiresAt        time.Time               `json:"expires_at"`
}

type EventChannelHypeTrainEnd added in v0.1.3

type EventChannelHypeTrainEnd struct {
	Broadcaster

	Id               string                  `json:"id"`
	Level            int                     `json:"level"`
	Total            int                     `json:"total"`
	TopContributions []HypeTrainContribution `json:"top_contributions"`
	StartedAt        time.Time               `json:"started_at"`
	ExpiresAt        time.Time               `json:"expires_at"`
	CooldownEndsAt   time.Time               `json:"cooldown_ends_at"`
}

type EventChannelHypeTrainProgress added in v0.1.3

type EventChannelHypeTrainProgress struct {
	EventChannelHypeTrainBegin

	Level int `json:"level"`
}

type EventChannelModeratorAdd added in v0.1.3

type EventChannelModeratorAdd struct {
	Broadcaster
	User
}

type EventChannelModeratorRemove added in v0.1.3

type EventChannelModeratorRemove struct {
	Broadcaster
	User
}

type EventChannelPollBegin added in v0.1.3

type EventChannelPollBegin struct {
	Broadcaster

	ID                  string       `json:"id"`
	Title               string       `json:"title"`
	Choices             []PollChoice `json:"choices"`
	BitsVoting          PollVoting   `json:"bits_voting"`
	ChannelPointsVoting PollVoting   `json:"channel_points_voting"`
	StartedAt           time.Time    `json:"started_at"`
	EndsAt              time.Time    `json:"ends_at"`
}

type EventChannelPollEnd added in v0.1.3

type EventChannelPollEnd struct {
	EventChannelPollBegin

	Status string `json:"status"`
}

type EventChannelPollProgress added in v0.1.3

type EventChannelPollProgress EventChannelPollBegin

type EventChannelPredictionBegin added in v0.1.3

type EventChannelPredictionBegin struct {
	Broadcaster

	ID        string              `json:"id"`
	Title     string              `json:"title"`
	Outcomes  []PredictionOutcome `json:"outcomes"`
	StartedAt time.Time           `json:"started_at"`
	LocksAt   time.Time           `json:"locks_at"`
}

type EventChannelPredictionEnd added in v0.1.3

type EventChannelPredictionEnd struct {
	Broadcaster

	ID               string              `json:"id"`
	Title            string              `json:"title"`
	WinningOutcomeID string              `json:"winning_outcome_id"`
	Outcomes         []PredictionOutcome `json:"outcomes"`
	Status           string              `json:"status"`
	StartedAt        time.Time           `json:"started_at"`
	EndedAt          time.Time           `json:"ended_at"`
}

type EventChannelPredictionLock added in v0.1.3

type EventChannelPredictionLock EventChannelPredictionBegin

type EventChannelPredictionProgress added in v0.1.3

type EventChannelPredictionProgress EventChannelPredictionBegin

type EventChannelRaid added in v0.1.3

type EventChannelRaid struct {
	FromBroadcasterUserId    string `json:"from_broadcaster_user_id"`
	FromBroadcasterUserLogin string `json:"from_broadcaster_user_login"`
	FromBroadcasterUserName  string `json:"from_broadcaster_user_name"`
	ToBroadcasterUserId      string `json:"to_broadcaster_user_id"`
	ToBroadcasterUserLogin   string `json:"to_broadcaster_user_login"`
	ToBroadcasterUserName    string `json:"to_broadcaster_user_name"`
	Viewers                  int    `json:"viewers"`
}

type EventChannelShieldModeBegin added in v0.1.16

type EventChannelShieldModeBegin struct {
	Broadcaster
	Moderator

	StartedAt time.Time `json:"started_at"`
	StoppedAt time.Time `json:"stopped_at"`
}

type EventChannelShieldModeEnd added in v0.1.16

type EventChannelShieldModeEnd EventChannelShieldModeBegin

type EventChannelSubscribe added in v0.1.2

type EventChannelSubscribe struct {
	User
	Broadcaster

	Tier   string `json:"tier"`
	IsGift bool   `json:"is_gift"`
}

type EventChannelSubscriptionEnd added in v0.1.2

type EventChannelSubscriptionEnd struct {
	User
	Broadcaster

	Tier   string `json:"tier"`
	IsGift bool   `json:"is_gift"`
}

type EventChannelSubscriptionGift added in v0.1.2

type EventChannelSubscriptionGift struct {
	User
	Broadcaster

	Total           int    `json:"total"`
	Tier            string `json:"tier"`
	CumulativeTotal int    `json:"cumulative_total"`
	IsAnonymous     bool   `json:"is_anonymous"`
}

type EventChannelSubscriptionMessage added in v0.1.2

type EventChannelSubscriptionMessage struct {
	User
	Broadcaster

	Tier             string  `json:"tier"`
	Message          Message `json:"message"`
	CumulativeMonths int     `json:"cumulative_months"`
	StreakMonths     int     `json:"streak_months"`
	DurationMonths   int     `json:"duration_months"`
}

type EventChannelUnban added in v0.1.2

type EventChannelUnban struct {
	User
	Broadcaster
	Moderator
}

type EventChannelUpdate added in v0.1.2

type EventChannelUpdate struct {
	Broadcaster

	Title        string `json:"title"`
	Language     string `json:"language"`
	CategoryID   string `json:"category_id"`
	CategoryName string `json:"category_name"`
	IsMature     bool   `json:"is_mature"`
}

type EventDropEntitlementGrant added in v0.1.3

type EventDropEntitlementGrant struct {
	ID   string          `json:"id"`
	Data DropEntitlement `json:"data"`
}

type EventExtensionBitsTransactionCreate added in v0.1.3

type EventExtensionBitsTransactionCreate struct {
	Broadcaster
	User

	ID                string           `json:"id"`
	ExtensionClientID string           `json:"extension_client_id"`
	Product           ExtensionProduct `json:"product"`
}

type EventStreamOffline added in v0.1.3

type EventStreamOffline Broadcaster

type EventStreamOnline added in v0.1.3

type EventStreamOnline struct {
	Broadcaster

	Id        string    `json:"id"`
	Type      string    `json:"type"`
	StartedAt time.Time `json:"started_at"`
}

type EventSubscription

type EventSubscription string
var (
	SubChannelUpdate EventSubscription = "channel.update"
	SubChannelFollow EventSubscription = "channel.follow"

	SubChannelSubscribe           EventSubscription = "channel.subscribe"
	SubChannelSubscriptionEnd     EventSubscription = "channel.subscription.end"
	SubChannelSubscriptionGift    EventSubscription = "channel.subscription.gift"
	SubChannelSubscriptionMessage EventSubscription = "channel.subscription.message"

	SubChannelCheer EventSubscription = "channel.cheer"
	SubChannelRaid  EventSubscription = "channel.raid"
	SubChannelBan   EventSubscription = "channel.ban"
	SubChannelUnban EventSubscription = "channel.unban"

	SubChannelModeratorAdd    EventSubscription = "channel.moderator.add"
	SubChannelModeratorRemove EventSubscription = "channel.moderator.remove"

	SubChannelChannelPointsCustomRewardAdd              EventSubscription = "channel.channel_points_custom_reward.add"
	SubChannelChannelPointsCustomRewardUpdate           EventSubscription = "channel.channel_points_custom_reward.update"
	SubChannelChannelPointsCustomRewardRemove           EventSubscription = "channel.channel_points_custom_reward.remove"
	SubChannelChannelPointsCustomRewardRedemptionAdd    EventSubscription = "channel.channel_points_custom_reward_redemption.add"
	SubChannelChannelPointsCustomRewardRedemptionUpdate EventSubscription = "channel.channel_points_custom_reward_redemption.update"

	SubChannelPollBegin    EventSubscription = "channel.poll.begin"
	SubChannelPollProgress EventSubscription = "channel.poll.progress"
	SubChannelPollEnd      EventSubscription = "channel.poll.end"

	SubChannelPredictionBegin    EventSubscription = "channel.prediction.begin"
	SubChannelPredictionProgress EventSubscription = "channel.prediction.progress"
	SubChannelPredictionLock     EventSubscription = "channel.prediction.lock"
	SubChannelPredictionEnd      EventSubscription = "channel.prediction.end"

	SubDropEntitlementGrant           EventSubscription = "drop.entitlement.grant"
	SubExtensionBitsTransactionCreate EventSubscription = "extension.bits_transaction.create"

	SubChannelGoalBegin    EventSubscription = "channel.goal.begin"
	SubChannelGoalProgress EventSubscription = "channel.goal.progress"
	SubChannelGoalEnd      EventSubscription = "channel.goal.end"

	SubChannelHypeTrainBegin    EventSubscription = "channel.hype_train.begin"
	SubChannelHypeTrainProgress EventSubscription = "channel.hype_train.progress"
	SubChannelHypeTrainEnd      EventSubscription = "channel.hype_train.end"

	SubStreamOnline  EventSubscription = "stream.online"
	SubStreamOffline EventSubscription = "stream.offline"

	SubUserAuthorizationGrant  EventSubscription = "user.authorization.grant"
	SubUserAuthorizationRevoke EventSubscription = "user.authorization.revoke"
	SubUserUpdate              EventSubscription = "user.update"

	SubChannelCharityCampaignDonate   EventSubscription = "channel.charity_campaign.donate"
	SubChannelCharityCampaignStart    EventSubscription = "channel.charity_campaign.start"
	SubChannelCharityCampaignProgress EventSubscription = "channel.charity_campaign.progress"
	SubChannelCharityCampaignStop     EventSubscription = "channel.charity_campaign.stop"

	SubChannelShieldModeBegin EventSubscription = "channel.shield_mode.begin"
	SubChannelShieldModeEnd   EventSubscription = "channel.shield_mode.end"
)

type EventUserAuthorizationGrant added in v0.1.3

type EventUserAuthorizationGrant struct {
	User

	ClientID string `json:"client_id"`
}

type EventUserAuthorizationRevoke added in v0.1.3

type EventUserAuthorizationRevoke EventUserAuthorizationGrant

type EventUserUpdate added in v0.1.3

type EventUserUpdate struct {
	User

	Email         string `json:"email"`
	EmailVerified bool   `json:"email_verified"`
	Description   string `json:"description"`
}

type ExtensionProduct added in v0.1.3

type ExtensionProduct struct {
	Name          string `json:"name"`
	Bits          int    `json:"bits"`
	SKU           string `json:"sku"`
	InDevelopment bool   `json:"in_development"`
}

type GlobalCooldown added in v0.1.3

type GlobalCooldown struct {
	IsEnabled bool `json:"is_enabled"`
	Seconds   int  `json:"seconds"`
}

type GoalAmount added in v0.1.3

type GoalAmount struct {
	Value         int    `json:"value"`
	DecimalPlaces int    `json:"decimal_places"`
	Currency      string `json:"currency"`
}

func (GoalAmount) Amount added in v0.1.3

func (a GoalAmount) Amount() float64

type HypeTrainContribution added in v0.1.3

type HypeTrainContribution struct {
	User

	Type  string `json:"type"`
	Total int    `json:"total"`
}

type Image added in v0.1.3

type Image struct {
	Url1x string `json:"url_1x"`
	Url2x string `json:"url_2x"`
	Url4x string `json:"url_4x"`
}

type KeepAliveMessage

type KeepAliveMessage struct {
	Metadata MessageMetadata `json:"metadata"`
	Payload  struct{}        `json:"payload"`
}

type MaxChannelPointsPerStream added in v0.1.3

type MaxChannelPointsPerStream struct {
	IsEnabled bool `json:"is_enabled"`
	Value     int  `json:"value"`
}

type Message added in v0.1.3

type Message struct {
	Text   string  `json:"text"`
	Emotes []Emote `json:"emotes"`
}

type MessageMetadata added in v0.1.5

type MessageMetadata struct {
	MessageID        string    `json:"message_id"`
	MessageType      string    `json:"message_type"`
	MessageTimestamp time.Time `json:"message_timestamp"`
}

type Moderator added in v0.1.9

type Moderator struct {
	ModeratorUserId    string `json:"moderator_user_id"`
	ModeratorUserLogin string `json:"moderator_user_login"`
	ModeratorUserName  string `json:"moderator_user_name"`
}

type NotificationMessage

type NotificationMessage struct {
	Metadata MessageMetadata `json:"metadata"`
	Payload  struct {
		Subscription PayloadSubscription `json:"subscription"`
		Event        *json.RawMessage    `json:"event"`
	} `json:"payload"`
}

type PayloadSession added in v0.1.9

type PayloadSession struct {
	ID                      string    `json:"id"`
	Status                  string    `json:"status"`
	ConnectedAt             time.Time `json:"connected_at"`
	KeepaliveTimeoutSeconds int       `json:"keepalive_timeout_seconds"`
	ReconnectUrl            string    `json:"reconnect_url"`
}

type PayloadSubscription added in v0.1.9

type PayloadSubscription struct {
	SubscriptionRequest

	ID       string    `json:"id"`
	Status   string    `json:"status"`
	Cost     int       `json:"cost"`
	CreateAt time.Time `json:"created_at"`
}

type PollChoice added in v0.1.3

type PollChoice struct {
	ID                string `json:"id"`
	Title             string `json:"title"`
	BitsVotes         int    `json:"bits_votes"`
	ChannelPointVotes int    `json:"channel_points_votes"`
	Votes             int    `json:"votes"`
}

type PollVoting added in v0.1.3

type PollVoting struct {
	IsEnabled     bool `json:"is_enabled"`
	AmountPerVote int  `json:"amount_per_vote"`
}

type PredictionOutcome added in v0.1.3

type PredictionOutcome struct {
	ID            string         `json:"id"`
	Title         string         `json:"title"`
	Color         string         `json:"color"`
	Users         int            `json:"users"`
	ChannelPoints int            `json:"channel_points"`
	TopPredictors []TopPredictor `json:"top_predictors"`
}

type ReconnectMessage

type ReconnectMessage struct {
	Metadata MessageMetadata `json:"metadata"`
	Payload  struct {
		Session PayloadSession `json:"session"`
	} `json:"payload"`
}

type RevokeMessage

type RevokeMessage struct {
	Metadata MessageMetadata `json:"metadata"`
	Payload  struct {
		Subscription PayloadSubscription `json:"subscription"`
	} `json:"payload"`
}

type SubscribeRequest

type SubscribeRequest struct {
	SessionID   string
	ClientID    string
	AccessToken string
	Event       EventSubscription
	Condition   map[string]string
}

type SubscribeResponse

type SubscribeResponse struct {
	Data         []PayloadSubscription `json:"data"`
	Total        int                   `json:"total"`
	TotalCost    int                   `json:"total_cost"`
	MaxTotalCost int                   `json:"max_total_cost"`
}

func SubscribeEvent

func SubscribeEvent(request SubscribeRequest) (SubscribeResponse, error)

func SubscribeEventUrl added in v0.1.11

func SubscribeEventUrl(request SubscribeRequest, url string) (SubscribeResponse, error)

func SubscribeEventUrlWithContext added in v0.1.11

func SubscribeEventUrlWithContext(ctx context.Context, request SubscribeRequest, url string) (SubscribeResponse, error)

func SubscribeEventWithContext added in v0.1.6

func SubscribeEventWithContext(ctx context.Context, request SubscribeRequest) (SubscribeResponse, error)

type SubscriptionRequest added in v0.1.9

type SubscriptionRequest struct {
	Type      EventSubscription     `json:"type"`
	Version   string                `json:"version"`
	Condition map[string]string     `json:"condition"`
	Transport SubscriptionTransport `json:"transport"`
}

type SubscriptionTransport added in v0.1.9

type SubscriptionTransport struct {
	Method    string `json:"method"`
	SessionID string `json:"session_id"`
}

type TopPredictor added in v0.1.3

type TopPredictor struct {
	User

	ChannelPointsWon  int `json:"channel_points_won"`
	ChannelPointsUsed int `json:"channel_points_used"`
}

type User added in v0.1.9

type User struct {
	UserID    string `json:"user_id"`
	UserLogin string `json:"user_login"`
	UserName  string `json:"user_name"`
}

type WelcomeMessage

type WelcomeMessage struct {
	Metadata MessageMetadata `json:"metadata"`
	Payload  struct {
		Session PayloadSession `json:"session"`
	} `json:"payload"`
}

Jump to

Keyboard shortcuts

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