Skip to content

Commit

Permalink
add notification message parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
dmmulroy committed Apr 15, 2024
1 parent 8e6d4ef commit e829117
Show file tree
Hide file tree
Showing 9 changed files with 505 additions and 42 deletions.
6 changes: 5 additions & 1 deletion src/glitch.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ pub fn get_access_token() {
let assert Ok(client_secret) = env.get("CLIENT_SECRET")
let scopes = [
scope.ChannelBot,
scope.ChannelManageRedemptions,
scope.ChannelReadRedemptions,
scope.ChannelReadSubscriptions,
scope.ChatRead,
scope.UserBot,
Expand Down Expand Up @@ -47,6 +49,8 @@ fn new_client() {
let assert Ok(client_secret) = env.get("CLIENT_SECRET")
let scopes = [
scope.ChannelBot,
scope.ChannelManageRedemptions,
scope.ChannelReadRedemptions,
scope.ChannelReadSubscriptions,
scope.ChatRead,
scope.UserBot,
Expand Down Expand Up @@ -93,6 +97,6 @@ pub fn test_eventsub() {

pub fn main() {
// get_access_token()
// let _ = test_chat()
// // let _ = test_chat()
test_eventsub()
}
23 changes: 0 additions & 23 deletions src/glitch/api/transport.gleam

This file was deleted.

39 changes: 36 additions & 3 deletions src/glitch/eventsub/eventsub.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ fn handle(state: EventSub, message: WebSocketMessage) {
io.println("Closed")
io.debug(message)
}
websocket_message.NotificationMessage(..) -> {
io.println("NotificationMessage")
io.debug(message)
}
websocket_message.SessionKeepaliveMessage(..) -> {
io.println("SessionKeepaliveMessage")
io.debug(message)
Expand All @@ -69,21 +73,50 @@ fn handle(state: EventSub, message: WebSocketMessage) {
io.debug(message)
}
websocket_message.WelcomeMessage(_, payload) -> {
// let resp =
// eventsub.create_eventsub_subscription(
// state.client,
// CreateEventSubSubscriptionRequest(
// ChannelChatMessage,
// "1",
// Condition(
// Some("209286766"),
// None,
// None,
// None,
// None,
// Some(client.client_id(state.client)),
// None,
// Some("209286766"),
// ),
// Transport(
// WebSocket,
// None,
// None,
// Some(payload.session.id),
// None,
// None,
// None,
// ),
// ),
// )
// let _ = io.debug(resp)

let resp =
eventsub.create_eventsub_subscription(
state.client,
CreateEventSubSubscriptionRequest(
ChannelChatMessage,
subscription.ChannelPointsCustomRewardRedemptionAdd,
"1",
Condition(
Some("209286766"),
None,
None,
None,
None,
Some(client.client_id(state.client)),
None,
Some("209286766"),
None,
None,
),
Transport(
WebSocket,
Expand Down
Empty file.
Loading

0 comments on commit e829117

Please sign in to comment.