@botmesh/core - v2.0.0-alpha.2
    Preparing search index...

    Transport-agnostic provider contract. TRaw is the provider's native raw payload (proto.IWebMessageInfo, webhook entry, gateway object); it stays unknown in all shared code and is narrowed only inside provider-specific paths.

    STABILITY CONTRACT (normative): for the lifetime of a session, the same entity MUST yield the same senderId and the same chat the same chatId on every emitted event. All transport-internal aliasing is resolved inside the provider before emission. The core performs no identity reconciliation.

    INBOUND ID CONTRACT (normative): a message's ref.id and an interaction's interactionId identify ONE logical inbound event within its chat: distinct events get distinct ids, and a redelivery of the same event (webhook retry, reconnect replay) carries the same id. Core relies on this for inbound idempotency (BotConfig.dedupe, keyed by chatId + id). When the transport provides no such id, synthesize one from per-event data that a redelivery repeats (e.g. kind + event timestamp) or emit '', which opts the event out of deduplication. Never fall back to a per-user constant (sender id, user_ref) or a shared placeholder ('<prefix>_0').

    Hierarchy (View Summary)

    Implements

    Index
    id: "mock" = 'mock'

    Stable transport tag (e.g. 'baileys', 'telegram') — used to namespace conversation keys if one Bot ever runs multiple providers concurrently.

    capabilities: ProviderCapabilities
    selfId: string | null = null

    The bot's own user id once connected (for group mention matching). Optional.

    outbox: MockOutgoing[] = []
    journal: MockJournalEntry[] = []

    Chronological journal of inbound messages/interactions (as emitted, before any chaos wrapper) and of every send with the ref it returned. Bounded by maxJournal.

    edits: MockEdit[] = []

    Edits recorded by editMessage (enabled by streaming 'edit'/'draft' or supports.edit).

    drafts: MockDraft[] = []

    Draft previews recorded by sendDraft (enabled by streaming: 'draft' or supports.drafts).

    deleted: MessageRef[] = []

    Messages deleted through deleteMessage (enabled by streaming not 'none' or supports.delete).

    acks: { interactionId: string; opts?: { text?: string; defer?: boolean } }[] = []

    Interaction acks recorded by acknowledgeInteraction, in order.

    textFormatFor?: (chatId: string) => TextFormat | undefined

    Per-chat text format — present only when MockProviderOptions.textFormatFor is given.

    maxJournal: number
    starts: number = 0

    start() calls so far.

    stops: number = 0

    stop() calls so far.

    • Records the ack in acks (button/callback interactions).

      Parameters

      • interactionId: string
      • Optionalopts: { text?: string; defer?: boolean }

      Returns Promise<void>

    • Simulate the user pressing "stop" on the latest draft that offered it.

      Returns boolean

    • Bytes of a simulated media: a copy of the bytes behind the ref (incomingMedia, chat.sendMedia); an empty buffer for a legacy token: null ref (incoming(text, { type: 'image' })). A { url } token without bytes rejects with MediaUnavailableError — the mock never touches the network.

      Parameters

      Returns Promise<Buffer<ArrayBufferLike>>

    • Forget the journal (the seq counter keeps growing; outbox is untouched).

      Returns void

    • Simulate an inbound media message (type: kind, body = caption). source bytes are what downloadMedia returns; { url } alone is metadata only, and the download then rejects with MediaUnavailableError.

      Parameters

      Returns void

    • Simulate a reaction to a message (bot.on('reaction'), 'reaction' hooks). to is the reacted message; the sender defaults to from (the chat), as in a DM.

      Parameters

      • emoji: string
      • opts: { to: MessageRef; from?: string; sender?: string; removed?: boolean }

      Returns void

    • Simulate an inbound call notification (what bot.on('call') and the CALL trigger receive). Reuse the same id to emit later updates of one call. For a group call pass chatId (the group) and isGroup: true; from is the caller.

      Parameters

      Returns void