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 20

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 29

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 355

# underlyingClient

Gets the underlying MatrixClient that powers this Intent.

View Source appservice/Intent.ts, line 82

# unstableApis

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

View Source appservice/Intent.ts, line 90

# userId

Gets the user ID this intent is for.

View Source appservice/Intent.ts, line 76

Methods

# async enableEncryption() → {Promise.<void>}

Sets up crypto on the client if it hasn't already been set up.

View Source appservice/Intent.ts, line 394

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

View Source appservice/Intent.ts, line 462

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 480

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 453

Resolves when complete
Promise.<any>

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

Gets the joined rooms for the intent. Note that by working around the intent to join rooms may yield inaccurate results.

View Source appservice/Intent.ts, line 404

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 423

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 414

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

View Source appservice/Intent.ts, line 471

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 444

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 434

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 378

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 386

The unstable API access class.

# userId() → {string}

Gets the user ID this intent is for.

View Source appservice/Intent.ts, line 371

string