Files
2026-10-22 17:07:08 +08:00

20 lines
916 B
TypeScript

import type {Json} from '../../../../types/bot/workflow/workflow.ts';
import type {WorkflowEventDefinition} from '../../../../types/bot/workflow/metadata.ts';
import * as message from './message.ts';
import * as chat from './chat.ts';
import * as whisper from './whisper.ts';
import * as spawn from './spawn.ts';
import * as health from './health.ts';
import * as custom from './custom.ts';
export const event_registry = {message, chat, whisper, spawn, health, custom} satisfies Record<string, WorkflowEventDefinition>;
export function normalize_event(event: string, args: unknown[]): Record<string, Json> | undefined {
if (args.length > 32) return;
if (Object.hasOwn(event_registry, event)) {
const definition: WorkflowEventDefinition = event_registry[event as keyof typeof event_registry];
return definition.normalize(args);
}
return custom.normalize_custom_event(event, args);
}