Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

  • new SyncBot(name?: string): SyncBot
  • Creates a SyncBot using SYNCBOT_MAPPINGS and SYNCBOT_HUB_SERVICE from the environment.

    Parameters

    • Default value name: string = "SyncBot"

      Identifier for this bot, defaults to SyncBot.

    Returns SyncBot

Properties

Protected _botname

_botname: string

Private hub

hub: DataHub

Protected logger

logger: Logger = new Logger()

Private messengers

messengers: Map<string, Messenger> = new Map<string, Messenger>()

Methods

Protected addServiceEmitter

  • addServiceEmitter(name: string, data?: any): ServiceEmitter | void
  • Add a new type of ServiceEmitter to the client. Should the ServiceEmitter already exist on the client with the handle/name, this will do nothing.

    Parameters

    • name: string

      The name of the ServiceEmitter to add.

    • Optional data: any

    Returns ServiceEmitter | void

    The constructed or pre-existing ServiceEmitter or void on failure.

Protected addServiceListener

  • addServiceListener(name: string, data?: any): ServiceListener | void
  • Add a new type of ServiceListener to the client. Should the ServiceListener already exist on the client with the handle/name, this will do nothing.

    Parameters

    • name: string

      The name of the ServiceListener to add.

    • Optional data: any

    Returns ServiceListener | void

    The constructed or pre-existing ServiceListener or void on failure.

Private createComment

  • Pass a transmission context to the emitter.

    Parameters

    Returns Promise<string>

    Promise that will resolve to the id of the created message.

Private createConnection

  • createConnection(event: InterimContext, type: "thread"): Promise<void>
  • Connect two threads with comments about each other.

    Parameters

    • event: InterimContext

      Event with the two threads specified.

    • type: "thread"

      What to connect, must be thread.

    Returns Promise<void>

    Resolves when connection is stored.

Private createRouter

  • Create a function that will route a data payload to the specified room.

    Parameters

    Returns ServiceListenerMethod

    Function that routes the payload.

Protected dispatchToAllEmitters

  • dispatchToAllEmitters(data: ServiceEmitRequest): Promise<any[]>
  • Dispatch to the specified emitter. This method exists as a shortcut to avoid having to retrieve a specific emitter before sending to it.

    Parameters

    • data: ServiceEmitRequest

      The ServiceEmitRequest to use. This will be dispatched to all ServiceEmitters.

    Returns Promise<any[]>

    An array of ServiceEmitResponses from all the ServiceEmitters.

Protected dispatchToEmitter

  • dispatchToEmitter(handle: string, data: any): Promise<any>
  • Dispatch to a specific ServiceEmitter. This method exists as a shortcut to avoid having to retrieve a specific emitter before sending to it.

    throws

    Any error returned from the service represented by the ServiceEmitter.

    Parameters

    • handle: string

      The handle of the ServiceEmitter to dispatch to.

    • data: any

      Emitter appropriate data to send.

    Returns Promise<any>

    Data returned from the service represented by the ServiceEmitter.

Private getDataHub

  • getDataHub(key: string, data?: any): DataHub
  • Retrieve or create a data hub that can retrieve a user's data.

    Parameters

    • key: string

      Name of the hub to seek.

    • Optional data: any

      Instantiation data for the hub.

    Returns DataHub

    Object which implements the data hub abstract.

Protected getEmitter

  • getEmitter(handle: string): ServiceEmitter | void
  • Find a particular attached ServiceEmitter based upon its name.

    Parameters

    • handle: string

      Handle of the ServiceEmitter instance to find (name if no handle was set).

    Returns ServiceEmitter | void

    Instance of the ServiceEmitter found, or void if not found.

Protected getListener

  • getListener(handle: string): ServiceListener | void
  • Find a particular attached ServiceListener based upon its handle.

    Parameters

    • handle: string

      Handle of the ServiceListener instance to find (name if no handle was set).

    Returns ServiceListener | void

    Instance of the ServiceListener found, or void if not found.

Private getMessageService

  • getMessageService(key: string, data?: any): Messenger
  • Retrieve or create a service that can understand the generic message format.

    Parameters

    • key: string

      Name of the service to seek.

    • Optional data: any

      Instantiation data for the service.

    Returns Messenger

    Object which implements the generic message abstract.

getNodeBinPath

  • getNodeBinPath(): Promise<string>

Private handleError

  • Report an error back to the source of the event.

    Parameters

    • error: Error

      error to report.

    • event: InterimContext

      source event that should be reflected into target context.

    Returns void

Private logError

  • This should be called when something really goes wrong, and in-app reports fail.

    Parameters

    • error: Error

      Error to report.

    • event: InterimContext

      Event that caused the error.

    Returns void

Private logSuccess

  • Record to the console some details from the event.

    Parameters

    • event: TransmitContext

      Event to record, will only pass on safe information.

    Returns void

Protected processConfiguration

  • processConfiguration(configFile: string): ProcBotConfiguration | void
  • Process a configuration file from YAML into a nested object.

    Parameters

    • configFile: string

      The configuration file as a string.

    Returns ProcBotConfiguration | void

    The configuration object or void.

Private register

Protected retrieveConfiguration

  • retrieveConfiguration(details: ConfigurationLocation): Promise<ProcBotConfiguration | void>
  • Retrieve a ProcBotConfiguration file from a ServiceEmitter or inbuilt route.

    Parameters

    • details: ConfigurationLocation

      An object detailing the service to retrieve the configuration file from, and its location.

    Returns Promise<ProcBotConfiguration | void>

    A Promise containing configuration object should one have been found, or void.

Private updateTags

  • Pass a tag creation context to the emitter.

    Parameters

    Returns Promise<void>

    Promise that will resolve once the tags are sent.

Private useConfigured

  • Use the configuration to provide the detail requested.

    Parameters

    • event: InterimContext

      Event to scrutinise and mutate.

    • type: "user"

      Property to search for, must be 'user'.

    Returns Promise<string>

    Resolves to the found property.

Private useConfiguredOrProvided

  • useConfiguredOrProvided(event: InterimContext, type: "user"): Promise<string>
  • Use the configuration or the source data to provide the detail requested.

    Parameters

    • event: InterimContext

      Event to scrutinise and mutate.

    • type: "user"

      Property to search for, must be 'user'.

    Returns Promise<string>

    Resolves to the found property.

Private useConnected

  • useConnected(event: InterimContext, type: "thread"): Promise<string>
  • Use the thread history to provide the detail requested.

    Parameters

    • event: InterimContext

      Event to scrutinise and mutate.

    • type: "thread"

      Property to search for, must be 'thread'.

    Returns Promise<string>

    Resolves to the found property.

Private useGeneric

  • useGeneric(event: InterimContext, type: "user" | "token"): Promise<string>

Private useHub

  • Use the hub service to provide the detail requested.

    Parameters

    • event: InterimContext

      Event to scrutinise and mutate.

    • type: "token"

      Property to search for, must be 'token'.

    Returns Promise<string>

    Resolves to the found property.

Private useHubOrGeneric

  • useHubOrGeneric(event: InterimContext, type: "token"): Promise<string>

Private useProvided

  • Use the source to provide the detail requested.

    Parameters

    • event: InterimContext

      Event to scrutinise and mutate.

    • type: "user"

      Property to search for, must be 'user'.

    Returns Promise<string>

    Resolves to the found property.

Private useSystem

  • useSystem(event: InterimContext, type: "user" | "token"): Promise<string>
  • Use the environment SYNCBOT_SYSTEM_MESSAGE_ACCOUNTS to provide the detail requested.

    Parameters

    • event: InterimContext

      Event to scrutinise and mutate.

    • type: "user" | "token"

      Property to search for, must be 'user' or 'token'.

    Returns Promise<string>

    Resolves to the found property.

Static Private extractTokens

  • Returns an array of the tokens in a provided context

    Parameters

    Returns string[]

Generated using TypeDoc