import { MonoTypeOperatorFunction, map } from "rxjs"; import { Message, CommandDefinition } from "./types"; export const getCommand = (commandDefinition: CommandDefinition | string) => { if (typeof commandDefinition === "string") { return commandDefinition; } else { return commandDefinition.command; } }; export const EXTERNAL_SOURCE_TAG = Symbol("externalSource"); export const isExternalMessage = (message: Message) => { return (message as Record)?.[EXTERNAL_SOURCE_TAG] === true; }; export const tagAsExternal: MonoTypeOperatorFunction> = map( (message: Message) => { return Object.assign(message, { [EXTERNAL_SOURCE_TAG]: true }); }, );