import type { Firehose, FirehoseOptions } from "@skyware/firehose"; import type { Jetstream, JetstreamOptions } from "@skyware/jetstream"; import { EventEmitter } from "node:events"; import type { Bot } from "./Bot.js"; /** * How the bot will receive and emit events. * @enum */ export declare const EventStrategy: { /** * By default, the bot will poll the notifications endpoint every `pollingInterval` seconds. * This is less resource-intensive than the firehose strategy, but it may take up to `pollingInterval` * seconds for the bot to receive new events. This strategy will not emit the `firehose` event. */ Polling: string; /** * The bot will open a websocket connection to the relay and receive events in real-time. * This will consume more bandwidth and CPU than the polling strategy, but the bot will receive * events as soon as they are emitted. * Prefer to use the {@link EventStrategy.Jetstream} strategy instead. */ Firehose: string; /** * The bot will open a websocket connection to a [Jetstream](https://github.com/bluesky-social/jetstream) * instance and receive events in real-time. */ Jetstream: string; }; export type EventStrategy = typeof EventStrategy[keyof typeof EventStrategy]; /** Options for the bot event emitter. */ export interface BotEventEmitterOptions { /** * How the bot will receive and emit events. * @default EventStrategy.Polling */ strategy?: EventStrategy; /** * The interval in seconds at which the bot will poll the notifications endpoint. Only used if `strategy` is {@link EventStrategy.Polling}. * @default 5 */ pollingInterval?: number; /** * The Date to begin processing notifications from. Only used if `strategy` is {@link EventStrategy.Polling}. * @default new Date() */ processFrom?: Date; /** * Options to pass to the Firehose constructor. Only used if `strategy` is {@link EventStrategy.Firehose}. * Prefer to use the {@link EventStrategy.Jetstream} strategy instead. * @see EventStrategy.Jetstream */ firehoseOptions?: FirehoseOptions; /** * Options to pass to the Jetstream constructor. Only used if `strategy` is {@link EventStrategy.Jetstream}. * @see EventStrategy.Jetstream */ jetstreamOptions?: JetstreamOptions; } declare const JETSTREAM_EVENTS: ["app.bsky.feed.post", "app.bsky.feed.repost", "app.bsky.feed.like", "app.bsky.graph.follow"]; export declare class BotEventEmitter extends EventEmitter { protected bot: Bot; /** How the bot will receive and emit events. */ private strategy; /** * The interval in seconds at which the bot will poll the notifications endpoint. * Only used if `strategy` is {@link EventStrategy.Polling}. */ private pollingInterval; /** The timestamp of the last notification processed, if using {@link EventStrategy.Polling}. */ private lastSeen?; /** Used to cancel polling. */ private pollingController?; /** * The firehose event stream, if using {@link EventStrategy.Firehose}. */ firehose?: Firehose; /** The jetstream event stream. */ jetstream?: Jetstream; /** Whether the bot is emitting events. */ emitting: boolean; /** * @param options The options for the event emitter. * @param bot The active Bot instance. */ constructor(options: BotEventEmitterOptions, bot: Bot); /** Start emitting events. */ start(): void; /** Stop emitting events. */ stop(): void; /** Start receiving and processing firehose events. */ startFirehose(): void; /** Start receiving and processing jetstream events. */ startJetstream(): void; /** Start polling the notifications endpoint. */ startPolling(): void; /** Poll the notifications endpoint. */ poll(): Promise; } export {};