Compare commits
No commits in common. "502a9404ed27f80e1de7fe71f62507fd880efe25" and "8b635781bfb9d97916c40bbb4e3fdf6a8063f7bf" have entirely different histories.
502a9404ed
...
8b635781bf
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "lua-json"]
|
||||||
|
path = lua-json
|
||||||
|
url = https://git.noordstar.me/Bram/lua-json.git
|
|
@ -7,7 +7,7 @@ This repository serves as a bridge between Matrix and Minetest servers.
|
||||||
1. Clone this repository into your Minetest mods folder:
|
1. Clone this repository into your Minetest mods folder:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://git.noordstar.me/Bram/mt-matrix.git
|
git clone --recursive https://git.noordstar.me/Bram/mt-matrix.git
|
||||||
```
|
```
|
||||||
|
|
||||||
2. To access the Matrix homeserver, this mod needs access to HTTP calls. Add this mod to your `minetest.conf` settings at the field `secure.http_mods`:
|
2. To access the Matrix homeserver, this mod needs access to HTTP calls. Add this mod to your `minetest.conf` settings at the field `secure.http_mods`:
|
||||||
|
|
11
init.lua
11
init.lua
|
@ -17,6 +17,13 @@ end
|
||||||
-- Load standard configuration
|
-- Load standard configuration
|
||||||
load("config")
|
load("config")
|
||||||
|
|
||||||
|
-- Load JSON module
|
||||||
|
json = nil
|
||||||
|
load("lua-json/json")
|
||||||
|
if json == nil then
|
||||||
|
error("Failed to load JSON module")
|
||||||
|
end
|
||||||
|
|
||||||
-- Load Matrix modules
|
-- Load Matrix modules
|
||||||
matrix = {}
|
matrix = {}
|
||||||
load("lua/send")
|
load("lua/send")
|
||||||
|
@ -65,6 +72,9 @@ if awards then
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- As long as the Minetest Lua API has a bug, this cannot be enabled
|
||||||
|
-- See issue #14394: https://github.com/minetest/minetest/issues/14394
|
||||||
|
if false then
|
||||||
-- Start Matrix sync
|
-- Start Matrix sync
|
||||||
local names = {}
|
local names = {}
|
||||||
|
|
||||||
|
@ -97,3 +107,4 @@ matrix.sync_forever(http_api, function(event)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
end
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 261adde7a76687db142641d50cf4ed29873ec476
|
|
@ -8,7 +8,7 @@ function matrix.send_message(http_api, body, formatted_body, callback, txnId)
|
||||||
config.url .. "/_matrix/client/v3/rooms/" .. config.room_id ..
|
config.url .. "/_matrix/client/v3/rooms/" .. config.room_id ..
|
||||||
"/send/m.room.message/" .. txnId
|
"/send/m.room.message/" .. txnId
|
||||||
),
|
),
|
||||||
data = minetest.write_json({
|
data = json.encode({
|
||||||
msgtype = "m.text",
|
msgtype = "m.text",
|
||||||
body = body,
|
body = body,
|
||||||
format = "org.matrix.custom.html",
|
format = "org.matrix.custom.html",
|
||||||
|
@ -22,7 +22,7 @@ function matrix.send_message(http_api, body, formatted_body, callback, txnId)
|
||||||
minetest.debug(result.data)
|
minetest.debug(result.data)
|
||||||
else
|
else
|
||||||
if callback ~= nil then
|
if callback ~= nil then
|
||||||
callback(minetest.parse_json(result.data))
|
callback(json.decode(result.data))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -22,7 +22,7 @@ function matrix.sync(http_api, callback, global_callback)
|
||||||
minetest.debug("Failed to sync with Matrix server; received code " .. result.code)
|
minetest.debug("Failed to sync with Matrix server; received code " .. result.code)
|
||||||
minetest.debug(result.data)
|
minetest.debug(result.data)
|
||||||
else
|
else
|
||||||
local answer = minetest.parse_json(result.data)
|
local answer = json.decode(result.data)
|
||||||
|
|
||||||
if answer.next_batch ~= nil then
|
if answer.next_batch ~= nil then
|
||||||
sync_so_far = answer.next_batch
|
sync_so_far = answer.next_batch
|
||||||
|
|
Loading…
Reference in New Issue