Skip to content

Commit

Permalink
Put beta EventSub things in own package
Browse files Browse the repository at this point in the history
  • Loading branch information
dnsge committed Mar 15, 2024
1 parent 7d25238 commit 60889e8
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 59 deletions.
3 changes: 3 additions & 0 deletions bindings/beta/beta.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Package beta contains bindings for beta-versioned EventSub structures. Backwards
// compatibility across twitch-eventsub-framework versions is not guaranteed.
package beta
50 changes: 50 additions & 0 deletions bindings/beta/beta_events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package beta

type EventChannelUnbanRequestCreate struct {
// The ID of the unban request.
ID string `json:"id"`
// The broadcaster’s user ID for the channel the unban request was created for.
BroadcasterUserID string `json:"broadcaster_user_id"`
// The broadcaster’s login name.
BroadcasterUserLogin string `json:"broadcaster_user_login"`
// The broadcaster’s display name.
BroadcasterUserName string `json:"broadcaster_user_name"`
// User ID of user that is requesting to be unbanned.
UserID string `json:"user_id"`
// The user’s login name.
UserLogin string `json:"user_login"`
// The user’s display name.
UserName string `json:"user_name"`
// Message sent in the unban request.
Text string `json:"text"`
// The UTC timestamp (in RFC3339 format) of when the unban request was created.
CreatedAt string `json:"created_at"`
}

type EventChannelUnbanRequestResolve struct {
// The ID of the unban request.
ID string `json:"id"`
// The broadcaster’s user ID for the channel the unban request was created for.
BroadcasterUserID string `json:"broadcaster_user_id"`
// The broadcaster’s login name.
BroadcasterUserLogin string `json:"broadcaster_user_login"`
// The broadcaster’s display name.
BroadcasterUserName string `json:"broadcaster_user_name"`
// Optional. User ID of moderator who approved/denied the request.
ModeratorUserID string `json:"moderator_user_id"`
// Optional. The moderator’s login name
ModeratorUserLogin string `json:"moderator_user_login"`
// Optional. The moderator’s display name
ModeratorUserName string `json:"moderator_user_name"`
// User ID of user that requested to be unbanned.
UserID string `json:"user_id"`
// The user’s login name.
UserLogin string `json:"user_login"`
// The user’s display name.
UserName string `json:"user_name"`
// Optional. Resolution text supplied by the mod/broadcaster upon approval/denial of the request.
ResolutionText string `json:"resolution_text"`
// Dictates whether the unban request was approved or denied.
// Can be the following: approved, canceled, denied
Status ChannelUnbanRequestResolveStatus `json:"status"`
}
9 changes: 9 additions & 0 deletions bindings/beta/beta_objects.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package beta

type ChannelUnbanRequestResolveStatus string

const (
ChannelUnbanRequestResolveStatusApproved ChannelUnbanRequestResolveStatus = "approved"
ChannelUnbanRequestResolveStatusCanceled ChannelUnbanRequestResolveStatus = "canceled"
ChannelUnbanRequestResolveStatusDenied ChannelUnbanRequestResolveStatus = "denied"
)
57 changes: 0 additions & 57 deletions bindings/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -933,60 +933,3 @@ type EventChannelChatNotification struct {
// Information about the bits badge tier event. Null if notice_type is not bits_badge_tier.
BitsBadgeTier *ChatNotificationBitsBadgeTierEvent `json:"bits_badge_tier,omitempty"`
}

type EventChannelUnbanRequestCreate struct {
// The ID of the unban request.
ID string `json:"id"`
// The broadcaster’s user ID for the channel the unban request was created for.
BroadcasterUserID string `json:"broadcaster_user_id"`
// The broadcaster’s login name.
BroadcasterUserLogin string `json:"broadcaster_user_login"`
// The broadcaster’s display name.
BroadcasterUserName string `json:"broadcaster_user_name"`
// User ID of user that is requesting to be unbanned.
UserID string `json:"user_id"`
// The user’s login name.
UserLogin string `json:"user_login"`
// The user’s display name.
UserName string `json:"user_name"`
// Message sent in the unban request.
Text string `json:"text"`
// The UTC timestamp (in RFC3339 format) of when the unban request was created.
CreatedAt string `json:"created_at"`
}

type ChannelUnbanRequestResolveStatus string

const (
ChannelUnbanRequestResolveStatusApproved ChannelUnbanRequestResolveStatus = "approved"
ChannelUnbanRequestResolveStatusCanceled ChannelUnbanRequestResolveStatus = "canceled"
ChannelUnbanRequestResolveStatusDenied ChannelUnbanRequestResolveStatus = "denied"
)

type EventChannelUnbanRequestResolve struct {
// The ID of the unban request.
ID string `json:"id"`
// The broadcaster’s user ID for the channel the unban request was created for.
BroadcasterUserID string `json:"broadcaster_user_id"`
// The broadcaster’s login name.
BroadcasterUserLogin string `json:"broadcaster_user_login"`
// The broadcaster’s display name.
BroadcasterUserName string `json:"broadcaster_user_name"`
// Optional. User ID of moderator who approved/denied the request.
ModeratorUserID string `json:"moderator_user_id"`
// Optional. The moderator’s login name
ModeratorUserLogin string `json:"moderator_user_login"`
// Optional. The moderator’s display name
ModeratorUserName string `json:"moderator_user_name"`
// User ID of user that requested to be unbanned.
UserID string `json:"user_id"`
// The user’s login name.
UserLogin string `json:"user_login"`
// The user’s display name.
UserName string `json:"user_name"`
// Optional. Resolution text supplied by the mod/broadcaster upon approval/denial of the request.
ResolutionText string `json:"resolution_text"`
// Dictates whether the unban request was approved or denied.
// Can be the following: approved, canceled, denied
Status ChannelUnbanRequestResolveStatus `json:"status"`
}
9 changes: 7 additions & 2 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/mozillazg/go-httpheader"

"github.com/dnsge/twitch-eventsub-framework/v2/bindings"
"github.com/dnsge/twitch-eventsub-framework/v2/bindings/beta"
)

const (
Expand Down Expand Up @@ -52,8 +53,6 @@ type SubHandler struct {
HandleChannelRaid EventHandler[bindings.EventChannelRaid] `eventsub-type:"channel.raid" eventsub-version:"1"`
HandleChannelBan EventHandler[bindings.EventChannelBan] `eventsub-type:"channel.ban" eventsub-version:"1"`
HandleChannelUnban EventHandler[bindings.EventChannelUnban] `eventsub-type:"channel.unban" eventsub-version:"1"`
HandleChannelUnbanRequestCreate EventHandler[bindings.EventChannelUnbanRequestCreate] `eventsub-type:"channel.unban_request.create" eventsub-version:"beta"`
HandleChannelUnbanRequestResolve EventHandler[bindings.EventChannelUnbanRequestResolve] `eventsub-type:"channel.unban_request.resolve" eventsub-version:"beta"`
HandleChannelModeratorAdd EventHandler[bindings.EventChannelModeratorAdd] `eventsub-type:"channel.moderator.add" eventsub-version:"1"`
HandleChannelModeratorRemove EventHandler[bindings.EventChannelModeratorRemove] `eventsub-type:"channel.moderator.remove" eventsub-version:"1"`
HandleChannelPointsRewardAdd EventHandler[bindings.EventChannelPointsRewardAdd] `eventsub-type:"channel.channel_points_custom_reward.add" eventsub-version:"1"`
Expand Down Expand Up @@ -86,6 +85,12 @@ type SubHandler struct {
HandleChannelChatClearUserMessages EventHandler[bindings.EventChannelChatClearUserMessages] `eventsub-type:"channel.chat.clear_user_messages" eventsub-version:"1"`
HandleChannelChatMessageDelete EventHandler[bindings.EventChannelChatMessageDelete] `eventsub-type:"channel.chat.message_delete" eventsub-version:"1"`
HandleChannelChatNotification EventHandler[bindings.EventChannelChatNotification] `eventsub-type:"channel.chat.notification" eventsub-version:"1"`

// ======================================================
// NOTE: Beta handlers, may break backwards-compatibility
// ======================================================
HandleChannelUnbanRequestCreate EventHandler[beta.EventChannelUnbanRequestCreate] `eventsub-type:"channel.unban_request.create" eventsub-version:"beta"`
HandleChannelUnbanRequestResolve EventHandler[beta.EventChannelUnbanRequestResolve] `eventsub-type:"channel.unban_request.resolve" eventsub-version:"beta"`
}

func NewSubHandler(doSignatureVerification bool, secret []byte) *SubHandler {
Expand Down

0 comments on commit 60889e8

Please sign in to comment.