Compare commits

..

2 Commits

Author SHA1 Message Date
Ceda EI 31bd289f32 Fail safely if not in secure.http_mods or trusted_mods 2019-01-22 19:05:04 +05:30
Ceda EI 4dee25a43b Add lua mod 2019-01-22 18:59:16 +05:30
1 changed files with 21 additions and 0 deletions

21
chat_mod/init.lua Normal file
View File

@ -0,0 +1,21 @@
function send_messages(res)
for message in string.gmatch(res["data"], "[^\n]+") do
minetest.chat_send_all(message)
end
end
function main(http_api)
port = minetest.settings:get("chat_server_port")
if port == nil then
port = "9876"
end
http_api.fetch({url = "http://localhost:" .. port .. "/get"}, send_messages)
minetest.after(0.5, main, http_api)
end
local http_api = minetest.request_http_api()
if http_api == nil then
minetest.log("error", "Chat Mod is not in secure.http_mods or secure.trusted_mods. Exiting.")
else
main(http_api)
end