···11TODOs:
2233-- [ ] thanking for follows only when live
44-- [ ] making chat overlay available to all users again
33+- [X] thanking for follows only when live
44+- [X] making chat overlay available to all users again
55- [ ] refactoring/cleaner file structure
66- [X] README.md
77- [ ] VIP & event badges
+18-18
utils/eventHandler.ts
···117117 const record = event.commit.record as PlaceStreamChatMessage.Main;
118118 if (botInstances.has(record.streamer)) {
119119 // Send to bot
120120- const streamplaceBot = botInstances.get(record.streamer);
121121- streamplaceBot!.processMessage(event);
122122- // Enrich and pass to subscribed websocket clients
123123- const subscribedClients = this.streamerClients.get(
120120+ const streamplaceBot = botInstances.get(record.streamer)!;
121121+ streamplaceBot.processMessage(event);
122122+ }
123123+ // Enrich and pass to subscribed websocket clients
124124+ const subscribedClients = this.streamerClients.get(
125125+ record.streamer,
126126+ );
127127+ if (subscribedClients && subscribedClients.size > 0) {
128128+ const enrichedMessage = await this.enrichMessage(
124129 record.streamer,
130130+ event,
125131 );
126126- if (subscribedClients && subscribedClients.size > 0) {
127127- const enrichedMessage = await this.enrichMessage(
128128- record.streamer,
129129- event,
130130- );
131131- const messageJson = JSON.stringify({
132132- type: "chat_message",
133133- data: enrichedMessage,
134134- });
132132+ const messageJson = JSON.stringify({
133133+ type: "chat_message",
134134+ data: enrichedMessage,
135135+ });
135136136136- // Send to all subscribed clients
137137- for (const client of subscribedClients) {
138138- if (client.readyState === WebSocket.OPEN) {
139139- client.send(messageJson);
140140- }
137137+ // Send to all subscribed clients
138138+ for (const client of subscribedClients) {
139139+ if (client.readyState === WebSocket.OPEN) {
140140+ client.send(messageJson);
141141 }
142142 }
143143 }