class Caridina::Connection
- Caridina::Connection
- Reference
- Object
Overview
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.
Included Modules
Defined in:
Constant Summary
-
Log =
Caridina::Log.for(self)
Constructors
-
.new(hs_url : String, access_token : String)
Create a new connection object using an access_token.
Class Method Summary
-
.login(hs_url : String, user_id : String, password : String) : String
Logs in using to a given homeserver and returns the access token.
Instance Method Summary
-
#create_filter(filter) : String
Creates a sync filter and returns its id.
-
#edit_message(room_id : String, event_id : String, message : String, html : String? = nil) : Nil
Edits a message.
-
#join(room_id) : Nil
Joins a room.
-
#send_message(room_id : String, message : String, html : String? = nil) : String
Sends a message to a given room.
-
#sync(channel : Channel(Responses::Sync))
Starts syncing.
-
#user_id : String
Returns the connected account's user_id.
-
#whoami : String
Returns the connected account's user_id.
Instance methods inherited from module Caridina::Modules::Typing
send_typing(room_id : String, timeout = 3000, typing = true) : Nil
send_typing,
typing(room_id : String, &)
typing
Instance methods inherited from module Caridina::Modules::Receipts
send_receipt(room_id : String, event_id : String, type = Type::Read) : Nil
send_receipt
Instance methods inherited from module Caridina::ConnectionInterface
edit_message(room_id : String, event_id : String, message : String, html : String? = nil) : Nil
edit_message,
send_message(room_id : String, message : String, html : String? = nil) : String
send_message
Constructor Detail
Create a new connection object using an access_token.
Class Method Detail
Logs in using to a given homeserver and returns the access token.
Instance Method Detail
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.
Edits a message.
Only m.text
messages are supported for now.
Sends a message to a given room.
Only m.text
messages are supported for now.
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.