IProvider that wraps another one and delivers its traffic adversarially
(see the module docs and ChaosOptions). Pass it to new Bot({ provider })
and keep driving the wrapped provider (chaos.inner.incoming(...)).
Optional provider capabilities (typing, markRead, downloadMedia, …)
are exposed only when the wrapped provider has them, so feature detection
in the Bot keeps working.
Type Parameters
Implements
Constructors
Constructor
Parameters
Returns
ChaosProvider<P>
Throws
when an option is out of range.Properties
inner
id
Implementation of
IProvider.id
capabilities
Implementation of
IProvider.capabilities
seed
log
delivered
ingest?
Parameters
Returns
unknown
Implementation of
IProvider.ingest
downloadMedia?
Parameters
Returns
Promise<Buffer<ArrayBufferLike> | ReadableStream>
Implementation of
IProvider.downloadMedia
serializeMediaRef?
BotConfig.durability): turn a live MediaRef into a JSON-safe,
versioned reference that rehydrateMediaRef can rebuild in another process, so a
replayed message (crash recovery, background retry) can still download its media.
Synchronous, cheap and side-effect free; a throw counts as “not durable”. Return
undefined for a ref that must not be journaled (e.g. view-once media). Never include
credentials: the result is stored at rest with the inbound record.
Parameters
Returns
|SerializedMediaRef
| undefined
Implementation of
IProvider.serializeMediaRef
rehydrateMediaRef?
MediaRef of a replayed message from what serializeMediaRef wrote.
ref is the journaled ref without its token. Pure decoding: it must not need the
transport to be connected. stored comes from storage and is UNTRUSTED: reject an
invalid, unknown-version or tampered value with a ProviderError.
Parameters
Returns
|MediaRef
| Promise<MediaRef>
Implementation of
IProvider.rehydrateMediaRef
getMessage?
getMessage callback baked into BaileysProvider today.
Parameters
Returns
Promise<
| InboundMessage<unknown>
| undefined>
Implementation of
IProvider.getMessage
markRead?
Parameters
Returns
Promise<void>
Implementation of
IProvider.markRead
typing?
Parameters
Returns
Promise<void>
Implementation of
IProvider.typing
deleteMessage?
Parameters
Returns
Promise<void>
Implementation of
IProvider.deleteMessage
editMessage?
Parameters
Returns
Promise<SendResult<unknown>>
Implementation of
IProvider.editMessage
sendDraft?
draftId → the same draft is updated in place. A draft is
NOT a message: the caller must still send() the final text. Only for
providers with capabilities.streaming === 'draft'; rejects (typed error)
where the transport refuses drafts (e.g. Telegram groups), and the caller
then falls back to edits or chunks.
Parameters
Returns
Promise<void>
Implementation of
IProvider.sendDraft
acknowledgeInteraction?
Parameters
Returns
Promise<void>
Implementation of
IProvider.acknowledgeInteraction
canRenderForm?
form OutboundContent for form (and opts.nativeId) can be
rendered natively right now, e.g. whether a WhatsApp Flow is mapped to it.
Only consulted when capabilities.forms === 'native'; when it returns
false, an auto-mode flow().form() asks field by field without sending
(and failing) a form message first. Absent = every form is renderable.
Parameters
Returns
boolean
Implementation of
IProvider.canRenderForm
textFormatFor?
whatsapp: chats
render WhatsApp markup, SMS chats render none). Return undefined when the
chat’s format is unknown; the core then falls back to
capabilities.textFormat. Exposed as ctx.textFormat. Must be synchronous
and cheap (it runs once per inbound message). Absent = every chat uses
capabilities.textFormat.
Parameters
Returns
TextFormat | undefined
Implementation of
IProvider.textFormatFor
Methods
start()
Returns
Promise<void>
Implementation of
IProvider.start
stop()
Returns
Promise<void>
Implementation of
IProvider.stop
onEvent()
Parameters
Returns
() =>void
Implementation of
IProvider.onEvent
send()
attempts, probability, or the connection is down), in which
case it rejects with a typed ProviderError and nothing reaches the
wrapped provider’s outbox.
Parameters
Returns
Promise<SendResult<unknown>>
Implementation of
IProvider.send
disconnect()
{ state: 'closed', reason }, then holds
inbound and fails sends (per options) until reconnect. A finite
downtimeMs schedules the reconnect automatically; the default for a
manual drop is to stay down until reconnect() is called.
Parameters
Returns
void
reconnect()
connecting then ready, redelivers the last
replayOnReconnect events (offline-sync duplicates), then delivers what
was held while down, in arrival order.
Returns
void
replay()
count delivered inbound events — an explicit webhook retry.
Parameters
Returns
void
flush()
Returns
void
settle()
Parameters
Returns
Promise<void>
Throws
if still busy aftertimeoutMs (default 5000).
Accessors
selfId
Get Signature
null when it has none: never undefined, see IProvider.selfId).
Returns
string | null
The bot’s own user id once connected (for group mention matching). Optional.
Implementation of
IProvider.selfId
connection
Get Signature
Returns
unknown
A single primary connection handle for DEBUGGING ONLY. Not a structural
guarantee of exactly one connection (Discord may hold many shard sockets).
Core must NOT reach through this for behavior.
Implementation of
IProvider.connection
connected
Get Signature
false while a simulated drop is in effect.
Returns
boolean
sendAttempts
Get Signature
send() calls so far (failed ones included).
Returns
number
pending
Get Signature
Returns
number