Something went wrong. Try again.
A work-in-progress chat bot for Streamplace with chat overlay functionality
Something went wrong. Try again.
902 B · 26 lines
TypeScript
at svelte
123456789101112131415161718192021222324252627/** * Adapter from the internal WebSocket type (EnrichedChatMessage) to the * display-layer type (DisplayChatMessage). Lives here so ChatOverlay can * import it without touching twitchWebsocket.ts, and so the wire format * stays decoupled from rendering concerns. */export function normalizeStreamplaceMessage( msg: EnrichedChatMessage,): DisplayChatMessage { const record = msg.record as { text?: string; reply?: unknown };
return { id: msg.uri, source: "streamplace", channel: msg.author.handle, displayName: msg.author.displayName ?? msg.author.handle, avatarUrl: msg.author.avatarUrl, pronouns: msg.author.pronouns, color: msg.chatProfile?.color ?? undefined, text: record.text ?? "", badges: (msg.badges ?? []).map((b) => ({ badgeType: b.badgeType })), isReply: !!record.reply, streamerAvatarUrl: msg.streamerAvatarUrl, timestamp: new Date(msg.indexedAt), };}