Options
All
  • Public
  • Public/Protected
  • All
Menu

Class State

Generic state, starting point for outgoing dispatches States have access to all bBot modules from the bot property. It has defined properties but can be extended with any key/value pair. Each thought process attaches timestamps if they are actioned. Provides proxies to envelope messages, so responses can be easily actioned.

Hierarchy

  • State

Implements

Indexable

[key: string]: any

Generic state, starting point for outgoing dispatches States have access to all bBot modules from the bot property. It has defined properties but can be extended with any key/value pair. Each thought process attaches timestamps if they are actioned. Provides proxies to envelope messages, so responses can be easily actioned.

Index

Constructors

constructor

  • Create new state, usually assigned as b in middleware callbacks. Create new state, usually assigned as b in middleware callbacks.

    Parameters

    Returns State

Properties

bot

bot: Bot = bBot

branches

  • get branches(): BranchController

conditions

  • get conditions(): any

Optional dialogue

dialogue: Dialogue

done

done: boolean = false

envelope

  • get envelope(): Envelope

Optional envelopes

envelopes: Envelope[]

Optional exit

exit: undefined | false | true

match

  • get match(): any
  • Use property getter for last branch match (often the only match). In the context of a branch callback, this provides a shorthand to the branch that was just matched, as opposed to b.getMatching(id).match.

    Returns any

matched

  • get matched(): boolean

Optional matching

matching: Branch[]

matchingBranch

  • get matchingBranch(): undefined | Branch
  • set matchingBranch(branch: Branch | undefined): void

message

message: Message = messages.blank()

Optional method

method: undefined | string

processed

processed: object

Type declaration

  • [key: string]: number

resolved

  • get resolved(): undefined | false | true
  • A strict version of matched, only true if not matched on act stage.

    Returns undefined | false | true

Optional sequence

sequence: undefined | string

user

  • get user(): User

Methods

clone

  • Initialise a new state from this one's attribute.

    Returns State

dispatchedEnvelope

  • dispatchedEnvelope(): Envelope | undefined
  • Return the last dispatched envelope.

    Returns Envelope | undefined

finish

  • finish(): this
  • Indicate that no other branch should process this state.

    Returns this

getMatchingBranch

  • getMatchingBranch(id?: number | string): Branch | undefined
  • Get a matched branch by it's ID or index (or last matched).

    Parameters

    • Optional id: number | string

    Returns Branch | undefined

ignore

  • ignore(): this
  • Indicate that no more thought processes should look at this state.

    Returns this

inspect

  • inspect(): string
  • Get a pretty-printed view of the state without all the bot attributes.

    Returns string

pendingEnvelope

  • pendingEnvelope(): Envelope | undefined
  • Check for existing envelope without response.

    Returns Envelope | undefined

respond

  • respond(...content: any[]): Promise<State>
  • Dispatch the envelope via respond thought process.

    Parameters

    • Rest ...content: any[]

    Returns Promise<State>

respondEnvelope

  • Create or return pending envelope, to respond to incoming message.

    Parameters

    Returns Envelope

respondVia

  • respondVia(method: string, ...content: any[]): Promise<State>
  • Set method for dispatching envelope responding to state.

    Parameters

    • method: string
    • Rest ...content: any[]

    Returns Promise<State>

setMatchingBranch

  • setMatchingBranch(branch: Branch): void
  • Add to or create collection of matched branches.

    Parameters

    Returns void

Generated using TypeDoc