This commit is contained in:
AliasAlreadyTaken 2024-12-26 09:21:33 +01:00
parent 6ae8ccda85
commit 120ec6ed5d
3 changed files with 62 additions and 3 deletions

View File

@ -30,6 +30,8 @@ Download and install [matterbridge](https://github.com/42wim/matterbridge)
## Configuration
### Matterbridge
Create a config for [matterbridge](https://github.com/42wim/matterbridge) and the chat protocols you want to use.
* https://github.com/42wim/matterbridge/wiki/How-to-create-your-config
@ -55,6 +57,48 @@ account="api.mt"
channel="api"
```
### Minetest
See also [settingtypes.txt](settingtypes.txt)
On top of adding `yl_matterbridge` to http_mods, there are settings to add to minetest.conf:
```
yl_matterbridge.address = 127.0.0.1
```
The address or IP to the matterbridge server
```
yl_matterbridge.port = 4242
```
The port the matterbridge server listens on
```
yl_matterbridge.gateway = default
```
The name of the gateway of the matterbridge server
```
yl_matterbridge.token
```
A secret token string to identify yourself towards the matterbridge server
```
yl_matterbridge.debug = false
```
Set this to true to enable debugging
```
yl_matterbridge.fetch_interval = 0.0
```
Specifies the interval (in seconds) at which a new query is sent to the bridge.
## Modmakers
API: Overwrite these function in your chat mod, if you want to handle messages yourself

View File

@ -34,6 +34,7 @@ settings.port = core.settings:get("yl_matterbridge.port") or "4242"
settings.gateway = core.settings:get("yl_matterbridge.gateway") or "default"
settings.token = core.settings:get("yl_matterbridge.token") or ""
settings.debug = core.settings:get_bool("yl_matterbridge.debug", false) or false
settings.fetch_interval = core.settings:get("yl_matterbridge.fetch_interval") or "0.0"
local http = core.request_http_api()
@ -85,13 +86,22 @@ local function send(user_name, message_text, gateway)
end)
end
local function receive()
local timer = 0
local function receive(dtime)
if yl_matterbridge.enabled == false then
return false
end
if settings.debug then
core.log("action", "[MOD] yl_matterbridge : receive")
end
timer = timer + dtime
if timer <= settings.fetch_interval then
return false
end
timer = 0
local timeout = 0
http.fetch({

View File

@ -8,7 +8,7 @@
# Defaults to 127.0.0.1
yl_matterbridge.address (Bridge IP address or URL) string 127.0.0.1
# The port the matterbridge server listens to
# The port the matterbridge server listens on
# You need to set this to the port of the API connection, which you configured in the toml
# Defaults to 4242
yl_matterbridge.port (Bridge port) string 4242
@ -26,4 +26,9 @@ yl_matterbridge.token (Bridge token) string
# Whether or not debugging messages are enabled
# If set to true, the mod will write every send and receive to the log, among other debug messages.
# Optional, default false
yl_matterbridge.debug (Debug mode) bool false
yl_matterbridge.debug (Debug mode) bool false
# Fetch/Receive interval
# Specifies the interval (in seconds) at which a new query is sent to the bridge. A value of 0.0 means queries are sent on every server step.
# Optional, defaults to 0.0
yl_matterbridge.fetch_interval (Fetch/Receive interval) float 0.0 0.0 30.0