Documentation
¶
Index ¶
- type AllConfigurationsResponse
- type Channel
- type Configuration
- type ConfigurationResponse
- type ExtensionEnabledChannels
- type Options
- type PubSubPermissions
- type PublishType
- type Record
- type ResponseCommon
- func (rc *ResponseCommon) GetExtSendChatMessageRateLimit() int
- func (rc *ResponseCommon) GetExtSendChatMessageRateLimitRemaining() int
- func (rc *ResponseCommon) GetExtSetConfigurationRateLimit() int
- func (rc *ResponseCommon) GetExtSetConfigurationRateLimitRemaining() int
- func (rc *ResponseCommon) GetPubSubChannelRateLimit() int
- func (rc *ResponseCommon) GetPubSubChannelRateLimitRemaining() int
- type RoleType
- type Secret
- type SecretsResponse
- type Segment
- type SegmentType
- type Twitch
- func (t *Twitch) CreateClaims(channelID string, role RoleType, permissions *PubSubPermissions) (claims *TwitchJWTClaims)
- func (t *Twitch) CreateExtensionSecret(delay int) (resp *SecretsResponse, err error)
- func (t *Twitch) GetAllChannelConfigurations(channelID string) (resp *AllConfigurationsResponse, err error)
- func (t *Twitch) GetBroadcasterSegment(channelID string) (*ConfigurationResponse, error)
- func (t *Twitch) GetDeveloperSegment(channelID string) (*ConfigurationResponse, error)
- func (t *Twitch) GetExtensionSecrets() (resp *SecretsResponse, err error)
- func (t *Twitch) GetGlobalSegment() (*ConfigurationResponse, error)
- func (t *Twitch) GetLiveChannelsWithExtensionEnabled(extensionId string, bookmark string) (channels *ExtensionEnabledChannels, err error)
- func (t *Twitch) JWTSign(claims *TwitchJWTClaims) (tokenString string, err error)
- func (t *Twitch) JWTVerify(token string) (claims *TwitchJWTClaims, err error)
- func (t *Twitch) PublishChannelNotification(channelID string, i interface{}) (res *ResponseCommon, err error)
- func (t *Twitch) PublishGlobalNotification(i interface{}) (res *ResponseCommon, err error)
- func (t *Twitch) PublishWhisperNotification(channelID string, opaqueId string, i interface{}) (res *ResponseCommon, err error)
- func (t *Twitch) RevokeExtensionSecrets() (res *ResponseCommon, err error)
- func (t *Twitch) SendTwitchChatMessage(channelID string, message string) (res *ResponseCommon, err error)
- func (t *Twitch) SetBroadcasterSegment(data interface{}, channelID string) (res *ResponseCommon, err error)
- func (t *Twitch) SetDeveloperSegment(data interface{}, channelID string) (res *ResponseCommon, err error)
- func (t *Twitch) SetExtensionRequired(channelID string) (res *ResponseCommon, err error)
- func (t *Twitch) SetGlobalSegment(data interface{}) (res *ResponseCommon, err error)
- type TwitchJWTClaims
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllConfigurationsResponse ¶
type AllConfigurationsResponse struct { Configurations map[string]*Configuration `json:"configurations"` ResponseCommon }
AllConfigurationsResponse contains all possible segment configurations for a broadcaster
type Channel ¶
type Channel struct { Game string `json:"game"` ID string `json:"id"` Username string `json:"username"` Title string `json:"title"` Viewers string `json:"view_count"` }
Channel A struct representative of an individual channel returned by getLiveChannelsWithExtensionEnabled
type Configuration ¶
Configuration Contains SegmentType and record information
type ConfigurationResponse ¶
type ConfigurationResponse struct { Configuration *Configuration `json:"configurations"` ResponseCommon }
ConfigurationResponse contains data for the queried segment configuration of type global, broadcaster or developer
type ExtensionEnabledChannels ¶
type ExtensionEnabledChannels struct { ResponseCommon Channels []*Channel `json:"channels"` Bookmark string `json:"cursor"` }
ExtensionEnabledChannels Response type of the getLiveChannelsWithExtensionEnabled
type PubSubPermissions ¶
type PubSubPermissions struct { Send []PublishType `json:"send,omitempty"` Listen []PublishType `json:"listen,omitempty"` }
PubSubPermissions publish permissions used within JWT claims
func FormBroadcastSendPubSubPermissions ¶
func FormBroadcastSendPubSubPermissions() *PubSubPermissions
FormBroadcastSendPubSubPermissions create the pubsub permissions for publishing a broadcast message type
func FormGenericPubSubPermissions ¶
func FormGenericPubSubPermissions() *PubSubPermissions
FormGenericPubSubPermissions create the pubsub permissions for publishing to message for any target type
func FormGlobalSendPubSubPermissions ¶
func FormGlobalSendPubSubPermissions() *PubSubPermissions
FormGlobalSendPubSubPermissions create the pubsub permissions for publishing a global targeted message
func FormWhisperSendPubSubPermissions ¶
func FormWhisperSendPubSubPermissions(opaqueId string) *PubSubPermissions
FormWhisperSendPubSubPermissions create the pubsub permissions for publishing a whisper message type
type PublishType ¶
type PublishType string
PublishType The Pub/Sub broadcast type
const ( GenericPublish PublishType = "*" BroadcastPublish PublishType = "broadcast" GlobalPublish PublishType = "global" )
Types of Pub/Sub Permissions or targets
type Record ¶
Record contains information about the version and raw content stored within the SegmentType configuation
type ResponseCommon ¶
ResponseCommon ...
func (*ResponseCommon) GetExtSendChatMessageRateLimit ¶
func (rc *ResponseCommon) GetExtSendChatMessageRateLimit() int
GetExtSendChatMessageRateLimit returns the "Ratelimit-Ratelimit-Ratelimiterextensionchatmessages-Limit" header as an int.
func (*ResponseCommon) GetExtSendChatMessageRateLimitRemaining ¶
func (rc *ResponseCommon) GetExtSendChatMessageRateLimitRemaining() int
GetExtSendChatMessageRateLimitRemaining returns the "Ratelimit-Ratelimit-Ratelimiterextensionchatmessages-Remaining" header as an int.
func (*ResponseCommon) GetExtSetConfigurationRateLimit ¶
func (rc *ResponseCommon) GetExtSetConfigurationRateLimit() int
GetExtSetConfigurationRateLimit returns the "Ratelimit-Ratelimiterextensionsetconfiguration-Limit" header as an int
func (*ResponseCommon) GetExtSetConfigurationRateLimitRemaining ¶
func (rc *ResponseCommon) GetExtSetConfigurationRateLimitRemaining() int
GetExtSetConfigurationRateLimitRemaining returns the "Ratelimit-Ratelimiterextensionsetconfiguration-Remaining" header as an int.
func (*ResponseCommon) GetPubSubChannelRateLimit ¶
func (rc *ResponseCommon) GetPubSubChannelRateLimit() int
GetPubSubChannelRateLimit returns the "Ratelimit-Ratelimitermessagesbychannel-Limit" header as an int for the pubsub messages to channel
func (*ResponseCommon) GetPubSubChannelRateLimitRemaining ¶
func (rc *ResponseCommon) GetPubSubChannelRateLimitRemaining() int
GetPubSubChannelRateLimitRemaining returns the "Ratelimit-Ratelimitermessagesbychannel-Remaining" header as an int
type Secret ¶
type Secret struct { Active string `json:"active"` Content string `json:"content"` Expires string `json:"expires"` }
Secret information about a generated secret
type SecretsResponse ¶
type SecretsResponse struct { Version int `json:"format_version"` Secrets []*Secret `json:"secrets"` ResponseCommon }
SecretsResponse response structure received when generating or querying for generated secrets
type Segment ¶
type Segment struct { Segment string `json:"segment_type"` ChannelID string `json:"channel_id,omitempty"` }
Segment contains information about the type and twitch channel the configuration is for.
type SegmentType ¶
type SegmentType string
SegmentType A segment configuration type
const ( BroadcasterSegment SegmentType = "broadcaster" DeveloperSegment SegmentType = "developer" GlobalSegment SegmentType = "global" )
Types of segments datastores for the configuration service
type Twitch ¶
type Twitch struct { OwnerID string Secret string ClientID string Version string ConfigVersion string // contains filtered or unexported fields }
Twitch package struct
func NewClient ¶
func NewClient( ownerID string, clientID string, secret string, extVersion string, configVersion string, opts ...*Options, ) ( twitch *Twitch, )
NewClient create reference to twitch-ext package https://dev.twitch.tv/docs/extensions/reference/#endpoints
func (*Twitch) CreateClaims ¶
func (t *Twitch) CreateClaims( channelID string, role RoleType, permissions *PubSubPermissions, ) ( claims *TwitchJWTClaims, )
CreateClaims will construct a claims suitable for generating a JWT token, containing necessary information required by the Twitch API. @param channelID if this value is empty it will default to 'all' @param role if this value is empty it will default to 'external'
func (*Twitch) CreateExtensionSecret ¶
func (t *Twitch) CreateExtensionSecret( delay int, ) ( resp *SecretsResponse, err error, )
CreateExtensionSecret create a new twitch secret for your twitch extension. The delay period, between the generation of the new secret and its use by Twitch, is specified by delay. https://dev.twitch.tv/docs/extensions/reference/#create-extension-secret
func (*Twitch) GetAllChannelConfigurations ¶
func (t *Twitch) GetAllChannelConfigurations(channelID string) (resp *AllConfigurationsResponse, err error)
GetAllChannelConfigurations retrieves channel specific configuration returns map containing both broadcaster and developer segments. https://dev.twitch.tv/docs/extensions/reference/#get-extension-channel-configuration
func (*Twitch) GetBroadcasterSegment ¶
func (t *Twitch) GetBroadcasterSegment(channelID string) (*ConfigurationResponse, error)
GetBroadcasterSegment retrieves channel specific Broadcaster SegmentType configuration
func (*Twitch) GetDeveloperSegment ¶
func (t *Twitch) GetDeveloperSegment(channelID string) (*ConfigurationResponse, error)
GetDeveloperSegment retrieves channel specific developer SegmentType configuration
func (*Twitch) GetExtensionSecrets ¶
func (t *Twitch) GetExtensionSecrets() ( resp *SecretsResponse, err error, )
GetExtensionSecrets returns a list of the extension secrets https://dev.twitch.tv/docs/extensions/reference/#get-extension-secret
func (*Twitch) GetGlobalSegment ¶
func (t *Twitch) GetGlobalSegment() (*ConfigurationResponse, error)
GetGlobalSegment retrieves global extension SegmentType configuration
func (*Twitch) GetLiveChannelsWithExtensionEnabled ¶
func (t *Twitch) GetLiveChannelsWithExtensionEnabled( extensionId string, bookmark string, ) ( channels *ExtensionEnabledChannels, err error, )
GetLiveChannelsWithExtensionEnabled Retrieve all live twitch channels which have the extension enabled. https://dev.twitch.tv/docs/extensions/reference/#get-live-channels-with-extension-activated
func (*Twitch) JWTSign ¶
func (t *Twitch) JWTSign(claims *TwitchJWTClaims) (tokenString string, err error)
JWTSign Sign the a JWT Claim to produce a base64 token.
func (*Twitch) JWTVerify ¶
func (t *Twitch) JWTVerify(token string) (claims *TwitchJWTClaims, err error)
JWTVerify validates a extension client side twitch base64 token and converts it into a twitch claim type, containing relevant information.
func (*Twitch) PublishChannelNotification ¶
func (t *Twitch) PublishChannelNotification(channelID string, i interface{}) (res *ResponseCommon, err error)
PublishChannelNotification publish a notification to a specific channel with the twitch extension enabled.
func (*Twitch) PublishGlobalNotification ¶
func (t *Twitch) PublishGlobalNotification(i interface{}) (res *ResponseCommon, err error)
PublishGlobalNotification publish a notification to all channels with the twitch extension enabled. https://dev.twitch.tv/docs/extensions/reference/#send-extension-pubsub-message
func (*Twitch) PublishWhisperNotification ¶
func (t *Twitch) PublishWhisperNotification(channelID string, opaqueId string, i interface{}) (res *ResponseCommon, err error)
PublishWhisperNotification publish a notification to a specific user viewing the twitch extension.
func (*Twitch) RevokeExtensionSecrets ¶
func (t *Twitch) RevokeExtensionSecrets() (res *ResponseCommon, err error)
RevokeExtensionSecrets all the secrets to the extension. https://dev.twitch.tv/docs/extensions/reference/#revoke-extension-secrets
func (*Twitch) SendTwitchChatMessage ¶
func (t *Twitch) SendTwitchChatMessage(channelID string, message string) (res *ResponseCommon, err error)
SendTwitchChatMessage publish message to twitch chat of a specific channel ID. - Twitch extension must have this permission - The maximum message size is 280 character - There is a limit of 12 messages per minute, per channel. https://dev.twitch.tv/docs/extensions/reference/#send-extension-chat-message
func (*Twitch) SetBroadcasterSegment ¶
func (t *Twitch) SetBroadcasterSegment(data interface{}, channelID string) (res *ResponseCommon, err error)
SetBroadcasterSegment sets channel specific broadcaster SegmentType configuration
func (*Twitch) SetDeveloperSegment ¶
func (t *Twitch) SetDeveloperSegment(data interface{}, channelID string) (res *ResponseCommon, err error)
SetDeveloperSegment sets channel specific developer SegmentType configuration
func (*Twitch) SetExtensionRequired ¶
func (t *Twitch) SetExtensionRequired(channelID string) (res *ResponseCommon, err error)
SetExtensionRequired is used to indicate that a channel has updated their configration, matching that of the latest twitch extension configuration version configured. https://dev.twitch.tv/docs/extensions/reference/#set-extension-required-configuration
func (*Twitch) SetGlobalSegment ¶
func (t *Twitch) SetGlobalSegment(data interface{}) (res *ResponseCommon, err error)
SetGlobalSegment sets global extension configuration
type TwitchJWTClaims ¶
type TwitchJWTClaims struct { OpaqueUserID string `json:"opaque_user_id,omitempty"` UserID string `json:"user_id"` ChannelID string `json:"channel_id,omitempty"` Role RoleType `json:"role"` Unlinked bool `json:"is_unlinked,omitempty"` Permissions *PubSubPermissions `json:"pubsub_perms"` jwt.StandardClaims }
TwitchJWTClaims contains information containing twitch specific JWT information.