View Source MatrixAppService.Client (MatrixAppService v0.3.1)

Convenience wrapper around Polyjuice.Client.LowLevel.

Library users can use the wrapped functions or call user/1 and pass the returned struct to Polyjuice functions.

Link to this section Summary

Link to this section Types

@type client_options() :: {:base_url, String.t()} | create_options()
@type create_options() :: [
  access_token: String.t() | nil,
  user_id: String.t() | nil,
  device_id: String.t() | nil,
  storage: Polyjuice.Client.Storage.t() | nil
]

Link to this section Functions

Return a client for the application service.

By default, the client gets its homeserver URL and access token from configuration. Different options can be provided to override the defaults, those are:

Link to this function

create_alias(room_id, room_alias, client_options \\ [])

View Source

Create a new alias for a Matrix room.

Arguments:

  1. room_id: room ID
  2. room_alias: room alias
  3. client_options: see client/1 (optional)
Link to this function

create_room(options \\ [], client_options \\ [])

View Source

Create a Matrix room.

Arguments:

  1. options: see Polyjuice.Client.Room.create_room/2
  2. client_options: see client/1 (optional)
Link to this function

get_alias(room_alias, client_options \\ [])

View Source

Get room ID and additional information, given a room's alias

Arguments:

  1. room_alias: the alias to look for
  2. client_options: see client/1 (optional)
Link to this function

get_data(user_id, event_type, client_options \\ [])

View Source

Get the data on an account.

Arguments:

  1. user_id: the ID of the user whose profile should be retrieved. If ommited, it defaults to the user_id represented by the client
  2. event_type: the type of event queried
  3. client_options: see client/1 (optional)
Link to this function

get_profile(user_id \\ nil, client_options \\ [])

View Source

Get user profile.

Arguments:

  1. user_id: the ID of the user whose profile should be retrieved. If ommited, it defaults to the user_id represented by the client
  2. client_options: see client/1 (optional)
Link to this function

get_state(room_id, event_type \\ nil, state_key \\ "", client_options \\ [])

View Source

Get a state event from a room.

Arguments:

  1. room_id: the ID of the user whose profile should be retrieved. If ommited, it defaults to the user_id represented by the client.
  2. event_type: the type of event
  3. state_key: the event state key
  4. client_options: see client/1 (optional)

If event_type is not provided, returns a list of events.

If event_type and state_key are provided, returns an event content. state_key can be omitted but this will return events that have a blank state key, not events that have "any state key".

Link to this function

join(room_id, client_options \\ [])

View Source

Join a room.

Arguments:

  1. room_id: the room ID
  2. client_options: see client/1 (optional)
Link to this function

put_avatar_url(user_id \\ nil, avatar_url, client_options \\ [])

View Source

Modify avatar url for the user.

Arguments:

  1. user_id: the ID of the user whose profile should be retrieved. If ommited, it defaults to the user_id represented by the client
  2. avatar_url: an mxc: URL specifying the location of the new profile
  3. client_options: see client/1 (optional)
Link to this function

put_data(user_id, event_type, data, client_options \\ [])

View Source

Put the data on an account.

Arguments:

  1. user_id: the ID of the user whose profile should be retrieved. If ommited, it defaults to the user_id represented by the client
  2. event_type: the type of event queried
  3. data: the new data
  4. client_options: see client/1 (optional)
Link to this function

put_displayname(user_id, displayname, client_options \\ [])

View Source

Modify display name for the user.

Arguments:

  1. user_id: the ID of the user whose profile should be retrieved. If ommited, it defaults to the user_id represented by the client
  2. displayname: the new displayname
  3. client_options: see client/1 (optional)
Link to this function

redact_message(room_id, event, reason \\ nil, client_options \\ [])

View Source

Send a redact event to a room.

Arguments:

  1. room_id: the ID of the user whose profile should be retrieved. If ommited, it defaults to the user_id represented by the client.
  2. event: the redact event
  3. reason: the reason (optional)
  4. client_options: see client/1 (optional)
Link to this function

register(options \\ [], client_options \\ [])

View Source

Register a new Matrix user.

Arguments:

  1. options: a keyword list that can contain these keys:
  • :inhibit_login: true
  • :device_id: device ID, defaults to "APP_SERVICE"
  • :initial_device_display_name: device name, defaults to "ApplicationService"
  • :kind: kind of account to register, defaults to "user", can also be "guest"
  1. client_options: see client/1 (optional)
Link to this function

search_user(search_term, limit \\ nil, client_options \\ [])

View Source

Search a Matrix user in the User Directory.

Arguments:

  1. search_term: the search term for the user
  2. limit: a search limit number, defaults to false (unlimited)
  3. client_options: see client/1 (optional)
Link to this function

send_message(room_id, msg, client_options \\ [])

View Source

Send a message to a Matrix room.

Arguments:

  1. room_id: room ID
  2. msg: see Polyjuice.Client.Room.send_message/3
  3. client_options: see client/1 (optional)
Link to this function

send_state_event(room_id, event_type, state_key, event_content, client_options \\ [])

View Source

Send a state event to a room.

Arguments:

  1. room_id: the ID of the user whose profile should be retrieved. If ommited, it defaults to the user_id represented by the client.
  2. event_type: the type of event
  3. state_key: the event state key
  4. event_content: the event content
  5. client_options: see client/1 (optional)
Link to this function

upload(data, options, client_options \\ [])

View Source

Upload a file to the media repository.

Arguments:

  1. data: Polyjuice.Client.Media.upload/3
  2. options: Polyjuice.Client.Media.upload/3
  3. client_options: see client/1 (optional)