/matrix-erlang-sdk

Primary LanguageErlangApache License 2.0Apache-2.0

matrix-erlang-sdk

A simple REST wrapper for Matrix.org for Erlang development.

Status

Early development. Essentially a "hello world" library at the moment.

Usage (module: matrix)

Hello Matrix!

matrix:helloMatrix("https://myhomeserv.er:port", "myusername", "mypassword", "#someroom:myhomeserv.er").

Initiate:

Homeserver = "http://theserver.domain:port"
matrix:init().

Log in with password:

{ok, AccessToken} = matrix:login("username", "password", Homeserver).

Join room:

{ok, RoomID} = matrix:joinRoom("#room:domain.asd", AccessToken, Homeserver).

Leave room:

matrix:partRoom("#room:domain.asd", AccessToken, Homeserver).

Send a message:

matrix:sendTextMessage("The message", RoomID, AccessToken, Homeserver).

Listen for text messages (runs forever, will not terminate!)

matrix:listen(RoomID, AccessToken, Homeserver).

Note

Depends on Jiffy (https://github.com/davisp/jiffy) for JSON-handling. Install with rebar get-deps or apt-get install erlang-jiffy.