Constructor
# new Appservice(options)
Creates a new application service.
Parameters:
Name | Type | Description |
---|---|---|
options |
IAppserviceOptions
|
The options for the application service. |
Classes
Members
# botClient
Get the application service's "bot" MatrixClient (the sender_localpart).
Normally the botIntent should be used to ensure that the bot user is safely
handled.
# botIntent
Get the application service's "bot" Intent (the sender_localpart).
# botUserId
Get the application service's "bot" user ID (the sender_localpart).
# bridge
Gets the bridge-specific APIs for this application service.
# expressAppInstance
Gets the express app instance which is serving requests. Not recommended for
general usage, but may be used to append routes to the web server.
# metrics
The metrics instance for this appservice. This will raise all metrics
from this appservice instance as well as any intents/MatrixClients created
by the appservice.
Methods
# addPreprocessor(preprocessor) → {void}
Adds a preprocessor to the event pipeline. When this appservice encounters an event, it
will try to run it through the preprocessors it can in the order they were added.
Parameters:
Name | Type | Description |
---|---|---|
preprocessor |
IPreprocessor
|
the preprocessor to add |
void
# begin() → {Promise.<void>}
Starts the application service, opening the bind address to begin processing requests.
resolves when started
Promise.<void>
# botClient() → {MatrixClient}
Get the application service's "bot" MatrixClient (the sender_localpart).
Normally the botIntent should be used to ensure that the bot user is safely
handled.
The client for the application service itself.
# botIntent() → {Intent}
Get the application service's "bot" Intent (the sender_localpart).
The intent for the application service itself.
# bridge() → {MatrixBridge}
Gets the bridge-specific APIs for this application service.
# expressAppInstance()
Gets the express app instance which is serving requests. Not recommended for
general usage, but may be used to append routes to the web server.
# getAlias(localpart) → {string}
Gets a full alias for a given localpart. The alias will be formed with the domain name given
in the constructor.
Parameters:
Name | Type | Description |
---|---|---|
localpart |
The localpart to get an alias for. |
The alias.
string
# getAliasForSuffix(suffix) → {string}
Gets a full alias for a given suffix. The prefix is automatically detected from the registration
options.
Parameters:
Name | Type | Description |
---|---|---|
suffix |
The alias's suffix |
The alias.
string
# getAliasLocalpartForSuffix(suffix) → {string}
Gets the localpart of an alias for a given suffix. The prefix is automatically detected from the registration
options. Useful for the createRoom endpoint.
Parameters:
Name | Type | Description |
---|---|---|
suffix |
The alias's suffix |
The alias localpart.
string
# getIntent(localpart) → {Intent}
Gets an intent for a given localpart. The user ID will be formed with the domain name given
in the constructor.
Parameters:
Name | Type | Description |
---|---|---|
localpart |
The localpart to get an Intent for. |
An Intent for the user.
# getIntentForSuffix(suffix) → {Intent}
Gets an Intent for a given user suffix. The prefix is automatically detected from the registration
options.
Parameters:
Name | Type | Description |
---|---|---|
suffix |
The user's suffix |
An Intent for the user.
# getIntentForUserId(userId) → {Intent}
Gets an Intent for a given user ID.
Parameters:
Name | Type | Description |
---|---|---|
userId |
string
|
The user ID to get an Intent for. |
An Intent for the user.
# getSuffixForAlias(alias) → {string}
Gets the suffix for the provided alias. If the alias is not a namespaced
alias, this will return a falsey value.
Parameters:
Name | Type | Description |
---|---|---|
alias |
string
|
The alias to parse |
The suffix from the alias.
string
# getSuffixForUserId(userId) → {string}
Gets the suffix for the provided user ID. If the user ID is not a namespaced
user, this will return a falsey value.
Parameters:
Name | Type | Description |
---|---|---|
userId |
string
|
The user ID to parse |
The suffix from the user ID.
string
# getUserId(localpart) → {string}
Gets a full user ID for a given localpart. The user ID will be formed with the domain name given
in the constructor.
Parameters:
Name | Type | Description |
---|---|---|
localpart |
The localpart to get a user ID for. |
The user's ID.
string
# getUserIdForSuffix(suffix) → {string}
Gets a full user ID for a given suffix. The prefix is automatically detected from the registration
options.
Parameters:
Name | Type | Description |
---|---|---|
suffix |
The user's suffix |
The user's ID.
string
# isNamespacedAlias(alias) → {boolean}
Determines if a given alias is namespaced by this application service.
Parameters:
Name | Type | Description |
---|---|---|
alias |
string
|
The alias to check |
true if the alias is namespaced, false otherwise
boolean
# isNamespacedUser(userId) → {boolean}
Determines if a given user ID is namespaced by this application service.
Parameters:
Name | Type | Description |
---|---|---|
userId |
string
|
The user ID to check |
true if the user is namespaced, false otherwise
boolean
# setRoomDirectoryVisibility(networkId, roomId, visibility) → {Promise.<any>}
Sets the visibility of a room in the appservice's room directory.
Parameters:
Name | Type | Description |
---|---|---|
networkId |
string
|
The network ID to group the room under. |
roomId |
string
|
The room ID to manipulate the visibility of. |
visibility |
"public"
|
"private"
|
The visibility to set for the room. |
resolves when the visibility has been updated.
Promise.<any>