# README
go-twitch-pubsub
Twitch PubSub library for Go
Getting Started
package main
import (
"fmt"
"github.com/pajlada/go-twitch-pubsub"
)
func main() {
pubsubClient := twitchpubsub.NewClient(twitchpubsub.DefaultHost)
userID := "82008718"
channelID := "11148817"
// OAuth token for userID with chat_login (or chat:read?) scope
userToken := "jdgfkhjkdfhgdfjg"
// Listen to a topic
pubsubClient.Listen(twitchpubsub.ModerationActionTopic(userID, channelID), userToken)
// Specify what callback is called when that topic receives a message
pubsubClient.OnModerationAction(func(channelID string, event *twitchpubsub.ModerationAction) {
fmt.Println(event.CreatedBy, event.ModerationAction, "on", event.TargetUserID)
})
go pubsubClient.Start()
c := make(chan bool)
<-c
}
# Packages
No description provided by the author
# Functions
BitsEventTopic returns a properly formatted bits event topic string with the given channel ID argument.
ModerationActionTopic returns a properly formatted moderation action topic string with the given user and channel ID arguments.
NewClient creates a client struct and fills it in with some default values.
ModerationActionTopic returns a properly formatted moderation action topic string with the given user and channel ID arguments.
BitsEventTopic returns a properly formatted bits event topic string with the given channel ID argument.
# Constants
No description provided by the author
# Variables
DefaultHost is the default host to connect to Twitch's pubsub servers.
ErrDisconnectedByUser is returned from Connect after the user calls Disconnect().
ErrNotConnected is returned if an action is attempted to be performed on a Client when it is not connected.
# Structs
Base TODO: Refactor.
BaseData TODO: Refactor.
BitsEvent describes an incoming "Bit" action coming from Twitch's PubSub servers.
Client is the client that connects to Twitch's pubsub servers.
InnerData TODO: Refactor.
No description provided by the author
No description provided by the author
Message TODO: Refactor.
ModerationAction describes an incoming "Moderation" action coming from Twitch's PubSub servers.
ModerationAction describes an incoming "Moderation" action coming from Twitch's PubSub servers.
BitsEvent describes an incoming "Bit" action coming from Twitch's PubSub servers.
ResponseMessage TODO: Refactor.