0
Fork 0
mirror of https://codeberg.org/SafeTwitch/safetwitch-backend.git synced 2024-12-22 13:13:00 -05:00

Add logger and scripts

This commit is contained in:
dragongoose 2023-04-08 18:15:57 -04:00
parent 076bb58b7e
commit 0b02e1f2ae
No known key found for this signature in database
GPG key ID: 50DB99B921579009
2 changed files with 8 additions and 1 deletions

View file

@ -21,6 +21,7 @@
}, },
"scripts": { "scripts": {
"dev": "npx nodemon index.ts", "dev": "npx nodemon index.ts",
"prod": "npx ts-node index.ts" "prod": "npx ts-node index.ts",
"build": "npx tsc"
} }
} }

View file

@ -1,6 +1,7 @@
import { randomUUID } from 'crypto'; import { randomUUID } from 'crypto';
import ws from 'ws'; import ws from 'ws';
import { TwitchChat } from '../util/scraping/chat/chat'; import { TwitchChat } from '../util/scraping/chat/chat';
import { logger } from '../util/logger';
interface ExtWebSocket extends ws { interface ExtWebSocket extends ws {
id?: string; id?: string;
@ -86,6 +87,11 @@ export class TwitchChatServer {
private handleHostTarget = async(channel: string, viewers: number, target: string, tags: Record<string,string>) => { private handleHostTarget = async(channel: string, viewers: number, target: string, tags: Record<string,string>) => {
const socketsToSend = await this.findClientsForStreamer(channel) const socketsToSend = await this.findClientsForStreamer(channel)
.catch((err) => {
logger.info(`No clients following ${channel}, unsubscribing`)
})
if(!socketsToSend) return;
for(let socket of socketsToSend) { for(let socket of socketsToSend) {
let payload = { let payload = {
type: 'HOSTTARGET', type: 'HOSTTARGET',