Skip to content

Commit

Permalink
Add support for channel.chat.message (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnsge authored Jan 26, 2024
1 parent 6c72eb5 commit e4555a0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 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.0
github.com/dnsge/twitch-eventsub-bindings v1.2.1
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.0 h1:iqIwGf8MLXPHKZZorvvMaiCvSf6iftdKar5SXPeAojY=
github.com/dnsge/twitch-eventsub-bindings v1.2.0/go.mod h1:Zbj+TpgcdNu4Gj6+6KG/+A7EvWMDbzQ+UGm35P918pc=
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/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
10 changes: 10 additions & 0 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ type SubHandler struct {
event *esb.EventUserAuthorizationRevoke,
)

HandleChannelChatMessage func(h *esb.ResponseHeaders, event *esb.EventChannelChatMessage)
HandleChannelChatClear func(h *esb.ResponseHeaders, event *esb.EventChannelChatClear)
HandleChannelChatClearUserMessages func(
h *esb.ResponseHeaders,
Expand Down Expand Up @@ -594,6 +595,15 @@ func (s *SubHandler) handleNotification(
if s.HandleUserUpdate != nil {
go s.HandleUserUpdate(h, &data)
}
case "channel.chat.message":
var data esb.EventChannelChatMessage
if err := json.Unmarshal(event, &data); err != nil {
http.Error(w, "Invalid JSON body", http.StatusBadRequest)
return
}
if s.HandleChannelChatMessage != nil {
go s.HandleChannelChatMessage(h, &data)
}
case "channel.chat.clear":
var data esb.EventChannelChatClear
if err := json.Unmarshal(event, &data); err != nil {
Expand Down

0 comments on commit e4555a0

Please sign in to comment.