Move join/leave/chat messages to mod instead of parsing stderr
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user