class

Caridina::Connection

Inherits Caridina::Modules::Typing < Caridina::Modules::Receipts < Caridina::ConnectionInterface < Reference < Object

A Matrix connection.

This is the main entrypoint for this library. You will find here all methods to interact with the Matrix API.

Those methods handle retrying when the connection is being rate limited. If there is another error, an ExecError while be returned.

Constants

Log = Caridina::Log.for(self)

Constructors

new(hs_url : String, access_token : String)

Create a new connection object using an access_token.

Source

Class methods

login(hs_url : String, user_id : String, password : String) : String

Logs in using to a given homeserver and returns the access token.

Matrix API

Source

Instance methods

create_filter(filter) : String

Creates a sync filter and returns its id.

The filter parameter must be a JSON serializable object.

TODO: This should be implement with a proper model object.

Matrix API

Source
edit_message(room_id : String, event_id : String, message : String, html : String | Nil = nil) : Nil

Edits a message.

Only m.text messages are supported for now.

Source
join(room_id) : Nil

Joins a room.

Matrix API

Source
send_message(room_id : String, message : String, html : String | Nil = nil) : String

Sends a message to a given room.

Only m.text messages are supported for now.

Source
sync(channel : Channel(Responses::Sync))

Starts syncing.

This method starts a new fiber wich will run sync queries, and send received events in channel.

It uses a filter to limit the received events to supported ones.

When called, it will first do an inital sync. This first sync may return events you already seen in a previous sync. You should handle this in your code, either by skipping the first sync or by storing the id of the events you processed.

TODO: accept an next_batch parameter to skip the initial sync.

Matrix API

Source
user_id

Returns the connected account's user_id.

Source
whoami

Returns the connected account's user_id.

You probably should use user_id which already store that information.

Matrix API

Source