Go to file
Adrian Perez de Castro 2946b55810
Make :sync() always add a "since" query parameter if available
...which ensures that multiple consecutive requests to /sync paginate
properly.
2017-02-05 14:11:55 +01:00
examples client-cqchat.lua: Actually exit when Ctrl-D is entered 2016-07-09 01:01:31 +03:00
matrix Make :sync() always add a "since" query parameter if available 2017-02-05 14:11:55 +01:00
spec Import a few unit test specs for matrix.room 2016-07-10 02:39:13 +03:00
.busted Give more details on unit test output 2016-07-10 01:48:37 +03:00
.travis.yml CI: Correct cjson -> lua-cjson 2016-07-10 02:47:04 +03:00
README.md Add echobot.lua example 2016-07-05 01:15:23 +03:00
matrix.lua Make it possible to import "matrix" directly 2016-06-23 03:55:09 +03:00

README.md

Matrix Client-Server API for Lua

Build Status Coverage Status

This is closely modelled after the official matrix-python-sdk.

Requirements

  • Lua 5.1, 5.2, 5.3, or LuaJIT — development and testing is only being done with 5.3, YMMV!
  • The cjson module.
  • One of the supported HTTP client libraries:

If you use LuaRocks, you can get the dependencies installed using the following commands:

luarocks install --server=http://luarocks.org/dev http
luarocks install lua-cjson

Self-promotion bit: If you use the Z shell and want something like virtualenv for Lua, please do try RockZ.

Usage

The library provides two levels of abstraction. The low-level layer wraps the raw HTTP API. The high-level layer wraps the low-level layer and provides an object model to perform actions on.

High-level matrix.client interface:

local client = require("matrix").client("http://localhost:8008")
local token = client:register_with_password("jdoe", "sup3rsecr1t")
local room = client:create_room("my_room_alias")
room:send_text("Hello!")

Low-level matrix.api interface:

local matrix = require("matrix")
local api = matrix.api("http://localhost:8080")
local response = api:register("m.login.password",
  { user = "jdoe", password = "sup3rsecr1t" })
api.token = response.token
handle_events(api:sync())
response = api:create_room({ alias = "my_room_alias" })
api:send_text(response.room_id, "Hello!")

More Examples

For the low-level matrix.api:

For the high-level matrix.client:

More examples can be found in the examples subdirectory.