Class

Intent

Intent(options, impersonateUserId, appservice)

An Intent is an intelligent client that tracks things like the user's membership in rooms to ensure the action being performed is possible. This is very similar to how Intents work in the matrix-js-sdk in that the Intent will ensure that the user is joined to the room before posting a message, for example.
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.

View Source appservice/Intent.ts, line 21

Classes

Intent
Intent

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).

View Source appservice/Intent.ts, line 30

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).

View Source appservice/Intent.ts, line 369

# underlyingClient

Gets the underlying MatrixClient that powers this Intent.

View Source appservice/Intent.ts, line 84

# unstableApis

Gets the unstable API access class. This is generally not recommended to be used by appservices.

View Source appservice/Intent.ts, line 92

# userId

Gets the user ID this intent is for.

View Source appservice/Intent.ts, line 78

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.

View Source appservice/Intent.ts, line 410

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

View Source appservice/Intent.ts, line 478

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.

View Source appservice/Intent.ts, line 497

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

View Source appservice/Intent.ts, line 468

Resolves when complete
Promise.<any>

# async getJoinedRooms() → {Promise.<Array.<string>>}

Gets the joined rooms for the intent.

View Source appservice/Intent.ts, line 419

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

View Source appservice/Intent.ts, line 438

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.

View Source appservice/Intent.ts, line 429

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

View Source appservice/Intent.ts, line 488

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.

View Source appservice/Intent.ts, line 459

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.

View Source appservice/Intent.ts, line 449

Resolves to the event ID of the sent message.
Promise.<string>

# underlyingClient() → {MatrixClient}

Gets the underlying MatrixClient that powers this Intent.

View Source appservice/Intent.ts, line 392

MatrixClient

# unstableApis() → {UnstableAppserviceApis}

Gets the unstable API access class. This is generally not recommended to be used by appservices.

View Source appservice/Intent.ts, line 400

The unstable API access class.

# userId() → {string}

Gets the user ID this intent is for.

View Source appservice/Intent.ts, line 385

string