Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Implements

  • ServiceListener
  • ServiceEmitter

Index

Constructors

constructor

  • new Messenger(listener: boolean): Messenger
  • Build this service, specifying whether to awaken as a listener.

    Parameters

    • listener: boolean

      Whether to start listening during construction.

    Returns Messenger

Properties

Private _eventListeners

_eventListeners: object

An object of arrays storing events by trigger and their actions.

Type declaration

  • [event: string]: ServiceRegistration[]

Protected activateMessageListener

activateMessageListener: function

Awaken this class as a listener.

Type declaration

    • (): void
    • Returns void

fetchNotes

fetchNotes: function

Promise to find the comment history of a particular thread.

param

ID of the thread to search.

param

ID of the room in which the thread resides.

param

Criteria to match.

param

Optional, some words which may be used to shortlist the results.

Type declaration

    • (thread: string, room: string, filter: RegExp, search?: undefined | string): Promise<string[]>
    • Parameters

      • thread: string
      • room: string
      • filter: RegExp
      • Optional search: undefined | string

      Returns Promise<string[]>

Private listening

listening: boolean = false

A boolean flag for if this object has been activated as a listener.

makeGeneric

makeGeneric: function

Promise to turn the data enqueued into a generic message format.

param

Raw data from the enqueue, remembering this is as dumb and quick as possible.

returns

A promise that resolves to the generic form of the event.

Type declaration

makeSpecific

makeSpecific: function

Promise to turn a generic message format into a form suitable for emitting to create a message.

param

Generic message format to encode.

returns

A promise that resolves to an emit context, which is as dumb as possible.

Type declaration

makeTagUpdate

makeTagUpdate: function

Promise to turn a generic message format into a form suitable for emitting to update tags.

param

Generic message format to encode.

returns

A promise that resolves to an emit context, which is as dumb as possible.

Type declaration

Protected sendPayload

sendPayload: function

Deliver the payload to the service. Sourcing the relevant context has already been performed.

param

The object to be delivered to the service.

returns

Response from the service endpoint.

Type declaration

Protected workers

workers: WorkerMap<string | null> = new Map<T, Worker<T>>()

Static Private _expressApp

_expressApp: express.Express

A singleton express instance for all web-hook based message services to share.

type

{Express}.

Static Protected logger

logger: Logger = new Logger()

A place to put output for debug and reference.

Accessors

apiHandle

  • get apiHandle(): ServiceAPIHandle | void
  • Retrieve the SDK API instance handle for the service, should one exist.

    Returns ServiceAPIHandle | void

    Service SDK API handle or void.

serviceName

  • get serviceName(): string
  • Get the service name, as required by the framework.

    Returns string

    Name of the service.

Static Protected expressApp

  • get expressApp(): express.Express
  • Create or retrieve the singleton express app.

    Returns express.Express

    Singleton express server app.

Methods

Protected getWorker

Protected handleEvent

  • Pass an event to registered listenerMethods.

    Parameters

    Returns Promise<void>

    Promise that resolves once the event is handled.

listen

  • listen(): void

queueEvent

registerEvent

  • registerEvent(registration: ServiceRegistration): void
  • Store an event of interest, so that the method gets triggered appropriately.

    Parameters

    • registration: ServiceRegistration

      Registration object with event trigger and other details.

    Returns void

Protected removeWorker

  • removeWorker(context: string | null): void

sendData

  • Emit data to the service.

    Parameters

    • data: ServiceEmitRequest

      Service Emit Request to send, if relevant.

    Returns Promise<MessengerEmitResponse>

    Details of the successful transmission from the service.

translateEventName

  • translateEventName(eventType: string): string
  • Turns the generic, messenger, name for an event into a specific trigger name for this class.

    Parameters

    • eventType: string

      Name of the event to translate, eg 'message'.

    Returns string

    This class's equivalent, eg 'post'.

Static Protected extractMetadata

  • extractMetadata(message: string, format: string): Metadata
  • Given a basic string this will extract a more rich context for the event, if embedded.

    Parameters

    • message: string

      Basic string that may contain metadata.

    • format: string

      Format of the metadata encoding.

    Returns Metadata

    Object of content, genesis and hidden.

Static Protected getIndicatorArrays

  • getIndicatorArrays(): object

Static initInterimContext

  • Make a handle context, using a receipt context and some extra information.

    Parameters

    • event: ReceiptContext

      Event to be converted.

    • to: string

      Destination for the handle context.

    • Default value toIds: MessengerIds = {}

      Pre-populate the toIds, if desired.

    Returns InterimContext

    Newly created context for handling a message.

Static Protected messageOfTheDay

  • messageOfTheDay(): string
  • A daily rotating message from a configured list.

    Returns string

    String of the message for today.

Static Private metadataByRegex

  • metadataByRegex(message: string, regex: RegExp): Metadata
  • Generic handler for stock metadata regex, must match the syntax of: first match is the indicator of visibility, second match is message source, remove the whole match for content.

    Parameters

    • message: string

      String to evaluate into metadata.

    • regex: RegExp

      Criteria for extraction.

    Returns Metadata

    Object of the metadata, decoded.

Static Protected stringifyMetadata

  • Encode the metadata of an event into a string to embed in the message.

    Parameters

    • data: TransmitContext

      Event to gather details from.

    • format: string

      Format of the metadata encoding.

    Returns string

    Text with data embedded.

Generated using TypeDoc