Move join/leave/chat messages to mod instead of parsing stderr

This commit is contained in:
2019-01-29 09:57:16 +05:30
parent bb9a9f7a9b
commit 7bdebb7fd3
2 changed files with 20 additions and 21 deletions

View File

@@ -36,9 +36,29 @@ function dead(player)
" died."}})
end
function join(player)
http_api.fetch_async({url = "http://localhost:" .. port .. "/sendCode",
post_data = {message = player.get_player_name(player) ..
" joined the server."}})
end
function left(player)
http_api.fetch_async({url = "http://localhost:" .. port .. "/sendCode",
post_data = {message = player.get_player_name(player) ..
" left the server."}})
end
function chat(name, message)
http_api.fetch_async({url = "http://localhost:" .. port .. "/send",
post_data = {message = "<" .. name .. "> " .. message}})
end
if http_api == nil then
minetest.log("error", "Chat Mod is not in secure.http_mods or secure.trusted_mods. Exiting.")
else
main()
end
minetest.register_on_dieplayer(dead)
minetest.register_on_joinplayer(join)
minetest.register_on_leaveplayer(left)
minetest.register_on_chat_message(chat)