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: "/Volumes/x/code/amazebot/bbot/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

branch

  • get branch(): undefined | Branch
  • set branch(branch: Branch | undefined): void
  • Provide the last matched branch as an property.

    Returns undefined | Branch

  • Add to the branches collection form the branch property.

    Parameters

    Returns void

conditions

  • get conditions(): any
  • Get the conditions of the last matched branch.

    Returns any

envelope

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

user

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