Config
This commit is contained in:
parent
5857912e6a
commit
7cb6ac4cbd
|
@ -0,0 +1 @@
|
|||
config.lua
|
24
README.md
24
README.md
|
@ -1,5 +1,29 @@
|
|||
# Minetest Matrix bridge
|
||||
|
||||
This is a server-side mod for Minetest, creating a bridge between a Matrix instant-messaging room and a Minetest server.
|
||||
|
||||
**Early development**, do not use it in production yet.
|
||||
|
||||
This mod does not use any additional lua library, only standard Minetest API.
|
||||
|
||||
## Install
|
||||
|
||||
The mod needs an existing account on the Matrix server, and access to the room.
|
||||
|
||||
Copy the template config to `config.lua`:
|
||||
|
||||
```bash
|
||||
cp config.template.lua config.lua
|
||||
```
|
||||
|
||||
then edit `config.lua`.
|
||||
|
||||
Add `matrix_bridge` to `secure.http_mods` (e.g. in the file `/etc/minetest/minetest.conf`):
|
||||
|
||||
```
|
||||
secure.http_mods = matrix_bridge
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
See [Matrix API docs](https://www.matrix.org/docs/guides/client-server-api).
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
-- Rename `config.template.lua` to `config.lua`
|
||||
-- Please edit only `config.lua`.
|
||||
-- `config.lua` will not be overwritten by updates.
|
||||
|
||||
MATRIX_SERVER = "https://matrix.txmn.tk:8448"
|
||||
MATRIX_ROOM = "!xReNhJbGJeGK4fysJU:matrix.txmn.tk"
|
||||
MATRIX_USERNAME = "minebot"
|
||||
MATRIX_PASSWORD = "PUT-YOUR-PASSWORD-HERE"
|
7
init.lua
7
init.lua
|
@ -1,5 +1,6 @@
|
|||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
dofile(modpath.."/config.lua")
|
||||
dofile(modpath.."/debug.lua")
|
||||
|
||||
local http = minetest.request_http_api()
|
||||
|
@ -13,7 +14,7 @@ local txid = 0
|
|||
function send_message(msg)
|
||||
txid = txid + 1
|
||||
http.fetch({
|
||||
url = "https://matrix.txmn.tk:8448/_matrix/client/r0/rooms/!xReNhJbGJeGK4fysJU:matrix.txmn.tk/send/m.room.message/"..txid.."?access_token="..token,
|
||||
url = MATRIX_SERVER.."/_matrix/client/r0/rooms/"..MATRIX_ROOM.."/send/m.room.message/"..txid.."?access_token="..token,
|
||||
method = "PUT",
|
||||
extra_headers = {"Content-Type: application/json"},
|
||||
data = minetest.write_json({msgtype="m.text", body=msg})
|
||||
|
@ -22,10 +23,10 @@ function send_message(msg)
|
|||
end
|
||||
|
||||
http.fetch({
|
||||
url = "https://matrix.txmn.tk:8448/_matrix/client/r0/login",
|
||||
url = MATRIX_SERVER.."/_matrix/client/r0/login",
|
||||
method = "POST",
|
||||
extra_headers = {"Content-Type: application/json"},
|
||||
data = '{"type":"m.login.password","password":"PUT-PASSWORD-HERE","identifier":{"type":"m.id.user","user":"minebot"}}'
|
||||
data = '{"type":"m.login.password","password":"'..MATRIX_PASSWORD..'","identifier":{"type":"m.id.user","user":"'..MATRIX_USERNAME..'"}}'
|
||||
}, function(res)
|
||||
if res.code == 200 then
|
||||
minetest.log("action", res.data)
|
||||
|
|
Loading…
Reference in New Issue