Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 0e02f80

Browse files
authored
Merge pull request #947 from SteffoSpieler/fix/stream-elements-replay
fix: Stream Elements replay event not working
2 parents ac6f2c0 + 6bb60d5 commit 0e02f80

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

services/nodecg-io-streamelements/extension/StreamElements.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
StreamElementsFollowEvent,
77
StreamElementsHostEvent,
88
StreamElementsRaidEvent,
9+
StreamElementsReplayEvent,
910
StreamElementsSubBombEvent,
1011
StreamElementsSubscriberEvent,
1112
StreamElementsTestCheerEvent,
@@ -188,6 +189,20 @@ export class StreamElementsServiceClient extends EventEmitter {
188189
handler(data);
189190
}
190191
});
192+
193+
this.socket.on("event:update", (data: StreamElementsReplayEvent) => {
194+
// event:update is all replays of previous real events.
195+
// Because the structure is similar to the test events and just the keys in the root element
196+
// are named differently we rename those to align with the naming in the test events
197+
// and handle it as a test event from here on.
198+
if (data) {
199+
handler({
200+
event: data.data,
201+
listener: data.name,
202+
provider: data.provider,
203+
} as unknown as StreamElementsTestEvent);
204+
}
205+
});
191206
}
192207

193208
public onSubscriber(handler: (data: StreamElementsSubscriberEvent) => void, includeSubGifts = true): void {

services/nodecg-io-streamelements/extension/StreamElementsEvent.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { ObjectMap } from "nodecg-io-core";
2+
13
interface StreamElementsBaseEvent<TType, TData> {
24
/**
35
* StreamElements hexadecimal Event ID
@@ -158,7 +160,7 @@ interface StreamElementsBaseTestEvent<TListener, TEvent> {
158160
/**
159161
* Event provider
160162
*/
161-
provider: "twitch" | "youtube" | "facebook";
163+
provider?: "twitch" | "youtube" | "facebook";
162164
listener: TListener;
163165
event: TEvent & StreamElementsTestDataBase;
164166
}
@@ -285,3 +287,15 @@ export type StreamElementsTestEvent =
285287
| StreamElementsTestRaidEvent
286288
| StreamElementsTestSubscriberEvent
287289
| StreamElementsTestTipEvent;
290+
291+
/**
292+
* When replaying real events the structure is similar to the test events
293+
* except for the keys in the root object.
294+
* This is a replay event general for all types.
295+
* The data structure and name follows the same schema as the test events.
296+
*/
297+
export interface StreamElementsReplayEvent {
298+
provider?: "twitch" | "youtube" | "facebook";
299+
name: string;
300+
data: ObjectMap<string | number>;
301+
}

0 commit comments

Comments
 (0)