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

Properties

bot

bot: "/home/circleci/repo/src/index" = bot

Optional branches

branches: Branch[]

done

done: boolean = false

Optional envelopes

envelopes: Envelope[]

Optional exit

exit: undefined | true | false

message

message: Message = new bot.NullMessage()

Optional method

method: undefined | string

processed

processed: object

Type declaration

  • [key: string]: number

Optional scope

scope: undefined | string

Optional sequence

sequence: undefined | string

Accessors

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.getBranch(id).match.

    Returns any

matched

  • get matched(): boolean
  • Use property getting for match state (only matched branches are kept)

    Returns boolean

Methods

clone

dispatchedEnvelope

  • dispatchedEnvelope(): undefined | Envelope

finish

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

    Returns this

getBranch

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

    Parameters

    • Optional id: number | string

    Returns undefined | Branch

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(): undefined | Envelope

reply

  • reply(...content: any[]): Promise<State>
  • Respond with the incoming message's user name prefixed

    Parameters

    • Rest ...content: any[]

    Returns Promise<State>

respond

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

    Parameters

    • Rest ...content: any[]

    Returns Promise<State>

respondEnvelope

  • respondEnvelope(options?: bot.IEnvelope): Envelope
  • Create or return pending envelope, to respond to incoming message

    Parameters

    • Optional options: bot.IEnvelope

    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>

setBranch

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

    Parameters

    Returns void

Generated using TypeDoc