Class representing a Chat Controller.

Constructors

  • Constructs an instance of ChatController.

    Parameters

    • Optionaloption: ChatOption

      The chat options.

    Returns ChatController

Methods

  • Adds a message to the chat.

    Parameters

    • message: Message<MessageContent>

      The message to add.

    Returns Promise<number>

    A Promise resolving to the index of the added message.

  • Adds an event handler for action changed.

    Parameters

    • callback: OnActionChanged

      The event handler to add.

    Returns void

  • Adds an event handler for messages changed.

    Parameters

    • callback: OnMessagesChanged

      The event handler to add.

    Returns void

  • Cancels the current action request.

    Returns void

  • Clears all messages from the chat.

    Returns void

  • Gets the current action request.

    Returns undefined | ActionRequest

    The current action request.

  • Gets all action responses.

    Returns ActionResponse[]

    An array of action responses.

  • Gets all messages in the chat.

    Returns Message<MessageContent>[]

    An array of messages.

  • Gets the chat options.

    Returns ChatOption

    The chat options.

  • Removes a message from the chat.

    Parameters

    • index: number

      The index of the message to remove.

    Returns void

  • Removes an event handler for action changed.

    Parameters

    • callback: OnActionChanged

      The event handler to remove.

    Returns void

  • Removes an event handler for messages changed.

    Parameters

    • callback: OnMessagesChanged

      The event handler to remove.

    Returns void

  • Sets the action request and its response handlers.

    Type Parameters

    • T extends ActionRequest

    Parameters

    • request: T

      The action request.

    • OptionalonResponse: OnActionResponsed

      The response handler.

    Returns Promise<ActionResponse>

    A Promise resolving to the action response.

  • Sets the action response and triggers related actions.

    Parameters

    • request: ActionRequest

      The action request.

    • response: ActionResponse

      The action response.

    Returns Promise<void>

    A Promise resolving when the action response is processed.

  • Sets the messages in the chat.

    Parameters

    • messages: Message<MessageContent>[]

      The messages to set.

    Returns void

  • Updates a message in the chat.

    Parameters

    • index: number

      The index of the message to update.

    • message: Message<MessageContent>

      The updated message.

    Returns void