Something went wrong. Try again.
fossabot clone for streamplace superbot.mmatt.net
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import { EventEmitter } from 'node:events'import type { ActivityRef } from '../../shared/schemas.ts'import type { MessageRef, ReplyTarget } from '../atproto/bot.ts'
/** Side effects the bot can have on Streamplace. Swapped for a recorder in tests. */export interface Platform { botDid(): string canSend(): boolean send(channelDid: string, text: string, reply?: ReplyTarget): Promise<MessageRef> hide(channelDid: string, messageUri: string): Promise<void> block(channelDid: string, subjectDid: string): Promise<string> unblock(channelDid: string, blockUri: string): Promise<void> findBlocks(channelDid: string, subjectDid: string): Promise<string[]> pin(channelDid: string, messageUri: string, expiresAt?: string): Promise<void> updateStream(channelDid: string, patch: { title?: string; activity?: ActivityRef | null }): Promise<void>}
/** Live events pushed to dashboards over SSE. */export type ChannelEvent = | { type: 'chat'; message: ChatEntry } | { type: 'hidden'; uri: string } | { type: 'live'; live: unknown } | { type: 'media' } | { type: 'giveaway' } | { type: 'audit'; entry: unknown } | { type: 'status'; status: unknown }
export interface ChatEntry { uri: string did: string handle: string displayName: string text: string badges: string[] color: string | null createdAt: string isBot: boolean hidden: boolean}
export const bus = new EventEmitter<{ event: [string, ChannelEvent] }>()bus.setMaxListeners(1000)
export function publish(channelId: string, event: ChannelEvent) { bus.emit('event', channelId, event)}