From 7a33519d7771335956b67e2e5e6e1c207cd0d945 Mon Sep 17 00:00:00 2001 From: - <-> Date: Tue, 25 Jan 2022 20:19:39 -0800 Subject: [PATCH] Added logout function and expanded testing command --- init.lua | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/init.lua b/init.lua index aa7e1db..09785d1 100644 --- a/init.lua +++ b/init.lua @@ -140,6 +140,12 @@ end -- end -- end) +function mlogout () + local u = MATRIX_SERVER.."/logout/all" + http.fetch({url=u, method="POST", function (res) end}) + minetest.log("action", "matrix_bridge - signing out.") +end + local GLOBAL_STEPS = 0 minetest.register_globalstep(function(dtine) -- print(GLOBAL_STEPS) @@ -150,27 +156,32 @@ minetest.register_globalstep(function(dtine) GLOBAL_STEPS = (GLOBAL_STEPS + 1) % (GLOBAL_THRESHHOLD+1) end) -minetest.register_chatcommand("msync", { +minetest.register_chatcommand("matrix", { privs = { interact = true }, func = function(name, param) if param == "nil" then -- test sync as called from login msync() - elseif param == "relogin" then + return true, "[matrix_bridge] command: sync(nil)" + elseif param == "logout" then + mlogout() + return true, "[matrix_bridge] command: log out" + elseif param == "login" then mlogin() + return true, "[matrix_bridge] command: log in" elseif #param > 1 then -- test sync with specific 'since' parameter msync(param) + return true, "[matrix_bridge] command: sync("..since..")" else -- test sync with current since parameter msync(since) + return true, "[matrix_bridge] command: sync()" end - return true, "[matrix_bridge] Fetching from matrix..." + end}) minetest.register_on_shutdown(function() - minetest.log("action", "matrix_bridge - signing out.") - local u = MATRIX_SERVER.."/logout/all" - http.fetch({url=u, method="POST", function (res) end}) + mlogout() end) minetest.register_on_joinplayer(function(player)