mirror of
https://github.com/imgfloat/server.git
synced 2026-02-05 03:39:26 +00:00
Add twitch chat integration
This commit is contained in:
@@ -24,6 +24,7 @@ export class BroadcastRenderer {
|
||||
this.scriptWorkerReady = false;
|
||||
this.scriptErrorKeys = new Set();
|
||||
this.scriptAttachmentCache = new Map();
|
||||
this.chatMessages = [];
|
||||
|
||||
this.obsBrowser = !!globalThis.obsstudio;
|
||||
this.supportsAnimatedDecode =
|
||||
@@ -409,6 +410,7 @@ export class BroadcastRenderer {
|
||||
},
|
||||
);
|
||||
this.scriptWorkerReady = true;
|
||||
this.updateScriptWorkerChatMessages();
|
||||
}
|
||||
|
||||
updateScriptWorkerCanvas() {
|
||||
@@ -424,6 +426,29 @@ export class BroadcastRenderer {
|
||||
});
|
||||
}
|
||||
|
||||
updateScriptWorkerChatMessages() {
|
||||
if (!this.scriptWorker || !this.scriptWorkerReady) {
|
||||
return;
|
||||
}
|
||||
this.scriptWorker.postMessage({
|
||||
type: "chatMessages",
|
||||
payload: {
|
||||
messages: this.chatMessages,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
receiveChatMessage(message) {
|
||||
if (!message) {
|
||||
return;
|
||||
}
|
||||
const now = Date.now();
|
||||
const entry = { ...message, timestamp: now };
|
||||
const cutoff = now - 120_000;
|
||||
this.chatMessages = [...this.chatMessages, entry].filter((item) => item.timestamp >= cutoff);
|
||||
this.updateScriptWorkerChatMessages();
|
||||
}
|
||||
|
||||
extractScriptErrorLocation(stack, scriptId) {
|
||||
if (!stack || !scriptId) {
|
||||
return "";
|
||||
|
||||
Reference in New Issue
Block a user