Finale
This commit is contained in:
parent
62b3444c10
commit
e384d8b09d
2
init.lua
2
init.lua
|
@ -21,8 +21,6 @@ yl_matterbridge.information.name = "yl_matterbridge"
|
|||
yl_matterbridge.information.additional = "Additional information"
|
||||
|
||||
dofile(yl_matterbridge.modpath .. "config.lua")
|
||||
--dofile(yl_matterbridge.modpath .. "internal.lua")
|
||||
--dofile(yl_matterbridge.modpath .. "globalsteps.lua")
|
||||
|
||||
local http = minetest.request_http_api()
|
||||
|
||||
|
|
37
internal.lua
37
internal.lua
|
@ -1,37 +0,0 @@
|
|||
local http = minetest.request_http_api()
|
||||
|
||||
function yl_matterbridge.send(user_name, message_text)
|
||||
local url = "http://" .. yl_matterbridge.address .. ":" .. yl_matterbridge.port .. "/api/message"
|
||||
local post_headers = {"Content-Type: application/json"}
|
||||
local timeout = 10
|
||||
local data = {
|
||||
text = message_text,
|
||||
username = user_name,
|
||||
gateway = yl_matterbridge.gateway
|
||||
}
|
||||
|
||||
http.fetch(
|
||||
{
|
||||
url = url,
|
||||
extra_headers = post_headers,
|
||||
timeout = timeout,
|
||||
post_data = minetest.write_json(data)
|
||||
},
|
||||
function(result)
|
||||
if result.succeeded then
|
||||
local data = minetest.parse_json(result.data)
|
||||
core.log("action", "[MOD] yl_matterbridge : Posted " .. dump(data))
|
||||
else
|
||||
minetest.log("error", "[yl_matterbridge] " .. dump(result))
|
||||
minetest.chat_send_player(user_name, "We were not able to send your text.")
|
||||
return false
|
||||
end
|
||||
end
|
||||
)
|
||||
return true
|
||||
end
|
||||
|
||||
minetest.register_on_chat_message(function(name, message)
|
||||
yl_matterbridge.send(user_name, message_text)
|
||||
end
|
||||
)
|
Loading…
Reference in New Issue