Added logout function and expanded testing command

This commit is contained in:
- 2022-01-25 20:19:39 -08:00
parent 704fe630cc
commit 7a33519d77
1 changed files with 17 additions and 6 deletions

View File

@ -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(<current>)"
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)