forked from dnsge/twitch-eventsub-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
31 lines (26 loc) · 825 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import (
"fmt"
"log"
"net/http"
esf "github.com/twirapp/twitch-eventsub-framework"
"github.com/twirapp/twitch-eventsub-framework/esb"
)
const (
// Key for verifying webhook requests
secretKey = `hey this is really secret`
)
func main() {
handler := esf.NewSubHandler(true, []byte(secretKey))
handler.HandleChannelUpdate = func(h *esb.ResponseHeaders, event *esb.EventChannelUpdate) {
fmt.Println("Got a channel.update notification!")
fmt.Printf("Message id: %s\n", h.MessageID)
fmt.Printf("Channel: %s Title: %s\n", event.BroadcasterUserName, event.Title)
}
// Listen on port 8080. In a real application, you would pass your mux with
// a route that uses the handler.
err := http.ListenAndServe("127.0.0.1:8080", handler)
if err != nil {
log.Fatalf("Failed to listen: %v\n", err)
}
}