Constructor
# new Intent(options, impersonateUserId, appservice)
Creates a new intent. Intended to be created by application services.
Parameters:
| Name | Type | Description |
|---|---|---|
options |
IAppserviceOptions
|
The options for the application service. |
impersonateUserId |
string
|
The user ID to impersonate. |
appservice |
Appservice
|
The application service itself. |
Classes
Members
# metrics
The metrics instance for this intent. Note that this will not raise metrics
for the underlying client - those will be available through this instance's
parent (the appservice).
Metrics
# metrics
The metrics instance for this intent. Note that this will not raise metrics
for the underlying client - those will be available through this instance's
parent (the appservice).
# underlyingClient
Gets the underlying MatrixClient that powers this Intent.
# unstableApis
Gets the unstable API access class. This is generally not recommended to be
used by appservices.
Methods
# async enableEncryption(providedDeviceId) → {Promise.<void>}
Sets up crypto on the client if it hasn't already been set up.
Parameters:
| Name | Type | Description |
|---|---|---|
providedDeviceId |
Optional device ID. If given, this will used instead of trying to masquerade as the first non-key enabled device. |
Resolves when complete.
Promise.<void>
# async ensureJoined(roomId) → {Promise.<any>}
Ensures the user is joined to the given room
Parameters:
| Name | Type | Description |
|---|---|---|
roomId |
string
|
The room ID to join |
- Deprecated:
- Use `joinRoom()` instead
Resolves when complete
Promise.<any>
# async ensureRegistered(deviceId) → {Promise.<any>}
Ensures the user is registered
Parameters:
| Name | Type | Description |
|---|---|---|
deviceId |
An optional device ID to register with. |
Resolves when complete
Promise.<any>
# async ensureRegisteredAndJoined(roomId) → {Promise.<any>}
Ensures the user is registered and joined to the given room.
Parameters:
| Name | Type | Description |
|---|---|---|
roomId |
string
|
The room ID to join |
Resolves when complete
Promise.<any>
# async getJoinedRooms() → {Promise.<Array.<string>>}
Gets the joined rooms for the intent.
Resolves to an array of room IDs where
the intent is joined.
Promise.<Array.<string>>
# async joinRoom(roomIdOrAlias) → {Promise.<string>}
Joins the given room
Parameters:
| Name | Type | Description |
|---|---|---|
roomIdOrAlias |
string
|
the room ID or alias to join |
resolves to the joined room ID
Promise.<string>
# async leaveRoom(roomId, reasonopt) → {Promise.<any>}
Leaves the given room.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
roomId |
string
|
The room ID to leave | |
reason |
string
|
<optional> |
Optional reason to be included as the reason for leaving the room. |
Resolves when the room has been left.
Promise.<any>
# async refreshJoinedRooms() → {Promise.<Array.<string>>}
Refreshes which rooms the user is joined to, potentially saving time on
calls like ensureJoined()
- Deprecated:
- There is no longer a joined rooms cache, use `getJoinedRooms()` instead
Resolves to the joined room IDs for the user.
Promise.<Array.<string>>
# async sendEvent(roomId, content) → {Promise.<string>}
Sends an event to a room.
Parameters:
| Name | Type | Description |
|---|---|---|
roomId |
string
|
The room ID to send the event to. |
content |
any
|
The content of the event. |
Resolves to the event ID of the sent event.
Promise.<string>
# async sendText(roomId, body, msgtype) → {Promise.<string>}
Sends a text message to a room.
Parameters:
| Name | Type | Description |
|---|---|---|
roomId |
string
|
The room ID to send text to. |
body |
string
|
The message body to send. |
msgtype |
"m.text"
|
"m.emote"
|
"m.notice"
|
The message type to send. |
Resolves to the event ID of the sent message.
Promise.<string>
# underlyingClient() → {MatrixClient}
Gets the underlying MatrixClient that powers this Intent.
# unstableApis() → {UnstableAppserviceApis}
Gets the unstable API access class. This is generally not recommended to be
used by appservices.
The unstable API access class.