new Intent(client, botClient)
Create an entity which can fulfil the intent of a given user.
Parameters:
Name | Type | Description |
---|---|---|
client |
MatrixClient | The matrix client instance whose intent is being fulfilled e.g. the entity joining the room when you call intent.join(roomId). |
botClient |
MatrixClient | The client instance for the AS bot itself. This will be used to perform more priveleged actions such as creating new rooms, sending invites, etc. |
- Source:
Methods
ban(roomId, target, reason) → {Promise}
Ban a user from a room.
This will automatically make the client join the room so they can send the ban if they are not already joined.Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | The room to ban the user from. |
target |
string | The target of the ban operation. |
reason |
string | Optional. The reason for the ban. |
- Source:
Returns:
Resolved when banned, else rejected with an error.
- Type
- Promise
createRoom(opts) → {Promise}
Create a room with a set of options.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
opts |
Object | Options.
Properties
|
- Source:
Returns:
- Type
- Promise
invite(roomId, target) → {Promise}
Invite a user to a room.
This will automatically make the client join the room so they can send the invite if they are not already joined.Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | The room to invite the user to. |
target |
string | The user ID to invite. |
- Source:
Returns:
Resolved when invited, else rejected with an error.
- Type
- Promise
join(roomId) → {Promise}
Join a room
This will automatically send an invite from the bot if it is an invite-only room, which may make the bot attempt to join the room if it isn't already.Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | The room to join. |
- Source:
Returns:
- Type
- Promise
kick(roomId, target, reason) → {Promise}
Kick a user from a room.
This will automatically make the client join the room so they can send the kick if they are not already joined.Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | The room to kick the user from. |
target |
string | The target of the kick operation. |
reason |
string | Optional. The reason for the kick. |
- Source:
Returns:
Resolved when kickked, else rejected with an error.
- Type
- Promise
leave(roomId) → {Promise}
Leave a room
This will no-op if the user isn't in the room.Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | The room to leave. |
- Source:
Returns:
- Type
- Promise
onEvent(event)
Inform this Intent class of an incoming event. Various optimisations will be
done if this is provided. For example, a /join request won't be sent out if
it knows you've already been joined to the room.
Parameters:
Name | Type | Description |
---|---|---|
event |
Object | The incoming event JSON |
- Source:
sendEvent(roomId, type, content) → {Promise}
Send a message event to a room.
This will automatically make the client join the room so they can send the message if they are not already joined. It will also make sure that the client has sufficient power level to do this.Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | The room to send to. |
type |
string | The event type |
content |
Object | The event content |
- Source:
Returns:
- Type
- Promise
sendMessage(roomId, content) → {Promise}
Send an m.room.message
event to a room.
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | The room to send to. |
content |
Object | The event content |
- Source:
Returns:
- Type
- Promise
sendStateEvent(roomId, type, skey, content) → {Promise}
Send a state event to a room.
This will automatically make the client join the room so they can send the state if they are not already joined. It will also make sure that the client has sufficient power level to do this.Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | The room to send to. |
type |
string | The event type |
skey |
string | The state key |
content |
Object | The event content |
- Source:
Returns:
- Type
- Promise
sendText(roomId, text) → {Promise}
Send a plaintext message to a room.
This will automatically make the client join the room so they can send the message if they are not already joined. It will also make sure that the client has sufficient power level to do this.Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | The room to send to. |
text |
string | The text string to send. |
- Source:
Returns:
- Type
- Promise
sendTyping(roomId, isTyping) → {Promise}
Send a typing event to a room.
This will automatically make the client join the room so they can send the typing event if they are not already joined.Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | The room to send to. |
isTyping |
boolean | True if typing |
- Source:
Returns:
- Type
- Promise
setAvatarUrl(url) → {Promise}
Set the user's avatar URL
Parameters:
Name | Type | Description |
---|---|---|
url |
string | The new avatar URL |
- Source:
Returns:
- Type
- Promise
setDisplayName(name) → {Promise}
Set the user's display name
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The new display name |
- Source:
Returns:
- Type
- Promise
setPowerLevel(roomId, target, level) → {Promise}
Set the power level of the given target.
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | The room to set the power level in. |
target |
string | The target user ID |
level |
number | The desired level |
- Source:
Returns:
- Type
- Promise
setRoomName(roomId, name) → {Promise}
Set the name of a room.
This will automatically make the client join the room so they can set the name if they are not already joined. It will also make sure that the client has sufficient power level to do this.Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | The room to send to. |
name |
string | The room name. |
- Source:
Returns:
- Type
- Promise
setRoomTopic(roomId, topic) → {Promise}
Set the topic of a room.
This will automatically make the client join the room so they can set the topic if they are not already joined. It will also make sure that the client has sufficient power level to do this.Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | The room to send to. |
topic |
string | The room topic. |
- Source:
Returns:
- Type
- Promise
unban(roomId, target) → {Promise}
Unban a user from a room.
This will automatically make the client join the room so they can send the unban if they are not already joined.Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | The room to unban the user from. |
target |
string | The target of the unban operation. |
- Source:
Returns:
Resolved when unbanned, else rejected with an error.
- Type
- Promise