Skip to content

Commit

Permalink
Add support for unban request events (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnsge authored Mar 14, 2024
1 parent e4555a0 commit bd6a570
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/dnsge/twitch-eventsub-framework
go 1.17

require (
github.com/dnsge/twitch-eventsub-bindings v1.2.1
github.com/dnsge/twitch-eventsub-bindings v1.2.2
github.com/mozillazg/go-httpheader v0.3.0
github.com/stretchr/testify v1.8.2
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dnsge/twitch-eventsub-bindings v1.2.1 h1:PTn3o8ctiH9rdzXPGqSG5iIqIvGKV9EZ9pU54zDUjp4=
github.com/dnsge/twitch-eventsub-bindings v1.2.1/go.mod h1:Zbj+TpgcdNu4Gj6+6KG/+A7EvWMDbzQ+UGm35P918pc=
github.com/dnsge/twitch-eventsub-bindings v1.2.2 h1:xMJMHKcYlW+IMH0yvXLsqmRG6yNcAQIx/FTTUbkMFvk=
github.com/dnsge/twitch-eventsub-bindings v1.2.2/go.mod h1:Zbj+TpgcdNu4Gj6+6KG/+A7EvWMDbzQ+UGm35P918pc=
github.com/mozillazg/go-httpheader v0.3.0 h1:3brX5z8HTH+0RrNA1362Rc3HsaxyWEKtGY45YrhuINM=
github.com/mozillazg/go-httpheader v0.3.0/go.mod h1:PuT8h0pw6efvp8ZeUec1Rs7dwjK08bt6gKSReGMqtdA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
28 changes: 24 additions & 4 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ type SubHandler struct {
HandleChannelCheer func(h *esb.ResponseHeaders, event *esb.EventChannelCheer)
HandleChannelRaid func(h *esb.ResponseHeaders, event *esb.EventChannelRaid)

HandleChannelBan func(h *esb.ResponseHeaders, event *esb.EventChannelBan)
HandleChannelUnban func(h *esb.ResponseHeaders, event *esb.EventChannelUnban)
HandleChannelModeratorAdd func(h *esb.ResponseHeaders, event *esb.EventChannelModeratorAdd)
HandleChannelModeratorRemove func(h *esb.ResponseHeaders, event *esb.EventChannelModeratorRemove)
HandleChannelBan func(h *esb.ResponseHeaders, event *esb.EventChannelBan)
HandleChannelUnban func(h *esb.ResponseHeaders, event *esb.EventChannelUnban)
HandleChannelUnbanRequestCreate func(h *esb.ResponseHeaders, event *esb.ChannelUnbanRequestCreate)
HandleChannelUnbanRequestResolve func(h *esb.ResponseHeaders, event *esb.ChannelUnbanRequestResolve)
HandleChannelModeratorAdd func(h *esb.ResponseHeaders, event *esb.EventChannelModeratorAdd)
HandleChannelModeratorRemove func(h *esb.ResponseHeaders, event *esb.EventChannelModeratorRemove)

HandleChannelPointsRewardAdd func(
h *esb.ResponseHeaders,
Expand Down Expand Up @@ -352,6 +354,24 @@ func (s *SubHandler) handleNotification(
if s.HandleChannelUnban != nil {
go s.HandleChannelUnban(h, &data)
}
case "channel.unban_request.create":
var data esb.ChannelUnbanRequestCreate
if err := json.Unmarshal(event, &data); err != nil {
http.Error(w, "Invalid JSON body", http.StatusBadRequest)
return
}
if s.HandleChannelUnbanRequestCreate != nil {
go s.HandleChannelUnbanRequestCreate(h, &data)
}
case "channel.unban_request.resolve":
var data esb.ChannelUnbanRequestResolve
if err := json.Unmarshal(event, &data); err != nil {
http.Error(w, "Invalid JSON body", http.StatusBadRequest)
return
}
if s.HandleChannelUnbanRequestResolve != nil {
go s.HandleChannelUnbanRequestResolve(h, &data)
}
case "channel.moderator.add":
var data esb.EventChannelModeratorAdd
if err := json.Unmarshal(event, &data); err != nil {
Expand Down

0 comments on commit bd6a570

Please sign in to comment.