Skip to content

Commit

Permalink
added subsciription messsage event
Browse files Browse the repository at this point in the history
  • Loading branch information
Klaven committed Jul 27, 2024
1 parent bb32ba9 commit 58852a2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deployment/twitch-alerts-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ spec:
# Start your application & Litestream to share a PVC data directory.
containers:
- name: twitch-alerts
image: nullchannel/twitch-alerts:0.1.35
image: nullchannel/twitch-alerts:0.1.36
ports:
- name: httpport
containerPort: 8080
Expand Down
15 changes: 15 additions & 0 deletions twitch_listener_service/src/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ impl WebsocketClient {
if let Some(url) = data.reconnect_url {
self.connect_url = url.parse()?;
}

// One way of doing it
let req = twitch_api::helix::eventsub::CreateEventSubSubscriptionRequest::new();
let body = twitch_api::helix::eventsub::CreateEventSubSubscriptionBody::new(
twitch_api::eventsub::channel::ChannelFollowV2::new(
Expand All @@ -187,6 +189,7 @@ impl WebsocketClient {
.await?;
let transport = twitch_api::eventsub::Transport::websocket(data.id.clone());

// Create Channel Subscription
self.client
.create_eventsub_subscription(
twitch_api::eventsub::channel::ChannelSubscribeV1::broadcaster_user_id(
Expand All @@ -197,6 +200,7 @@ impl WebsocketClient {
)
.await?;

// Create Channel Raid Subscription
self.client
.create_eventsub_subscription(
twitch_api::eventsub::channel::ChannelRaidV1::to_broadcaster_user_id(
Expand All @@ -207,6 +211,17 @@ impl WebsocketClient {
)
.await?;

// Create Channel Subscription Message Subscription
self.client
.create_eventsub_subscription(
twitch_api::eventsub::channel::ChannelSubscriptionMessageV1::broadcaster_user_id(
self.user_id.clone(),
),
transport.clone(),
&*self.token.read().await,
)
.await?;

tracing::info!("we are listening");
Ok(())
}
Expand Down

0 comments on commit 58852a2

Please sign in to comment.