Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
HandleMessage func(msg Message[NotificationPayload])
HandleError func(err error)
// contains filtered or unexported fields
}
func (*Conn) Connect ¶
func (c *Conn) Connect(inbound <-chan InboundMessage) error
Connect connects to the twitch eventsub websocket It will wait util a message is send to the inbound channel before connecting this is because twitch will close the connection if we don't send a event sub subscription within 10 seconds after connecting. Connect will try to reconnect if the connection is dropped until inboud is closed. If twitch sends reconnect messsage, Connect will reconnect to the session. Duplicate messages are filtered out.
type Event ¶
type Event struct {
UserID string `json:"user_id"`
UserLogin string `json:"user_login"`
UserName string `json:"user_name"`
BroadcasterUserID string `json:"broadcaster_user_id"`
BroadcasterUserLogin string `json:"broadcaster_user_login"`
BroadcasterUserName string `json:"broadcaster_user_name"`
FollowedAt time.Time `json:"followed_at"`
// Poll releated
Title string `json:"title"`
Choices []Choice `json:"choices"`
BitsVoting Voting `json:"bits_voting"`
ChannelPointsVoting Voting `json:"channel_points_voting"`
StartedAt time.Time `json:"started_at"`
EndsAt time.Time `json:"ends_at"` // empty if done
EndedAt time.Time `json:"ended_at"` // empty until done
Status string `json:"status"` // completed when done, else empty
// Raid related
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"`
// Ad related
IsAutomatic bool `json:"is_automatic"`
DurationInSeconds int `json:"duration_seconds"`
RequesterUserID string `json:"requester_user_id"`
RequesterUserLogin string `json:"requester_user_login"`
RequesterUserName string `json:"requester_user_name"`
}
type EventSubService ¶
type EventSubService interface {
CreateEventSubSubscription(ctx context.Context, reqData twitch.CreateEventSubSubscriptionRequest) (twitch.CreateEventSubSubscriptionResponse, error)
}
type InboundMessage ¶
type InboundMessage struct {
Req twitch.CreateEventSubSubscriptionRequest
Service EventSubService
}
type Message ¶
type Message[T any] struct { Metadata metadata `json:"metadata"` Payload T `json:"payload"` }
type NotificationPayload ¶
type NotificationPayload struct {
Subscription Subscription `json:"subscription"`
Event Event `json:"event"`
}
type SessionPayload ¶
type SessionPayload struct {
Session Session `json:"session"`
}
type Subscription ¶
Click to show internal directories.
Click to hide internal directories.