Added logout function and expanded testing command
This commit is contained in:
parent
704fe630cc
commit
7a33519d77
23
init.lua
23
init.lua
|
@ -140,6 +140,12 @@ end
|
||||||
-- end
|
-- 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
|
local GLOBAL_STEPS = 0
|
||||||
minetest.register_globalstep(function(dtine)
|
minetest.register_globalstep(function(dtine)
|
||||||
-- print(GLOBAL_STEPS)
|
-- print(GLOBAL_STEPS)
|
||||||
|
@ -150,27 +156,32 @@ minetest.register_globalstep(function(dtine)
|
||||||
GLOBAL_STEPS = (GLOBAL_STEPS + 1) % (GLOBAL_THRESHHOLD+1)
|
GLOBAL_STEPS = (GLOBAL_STEPS + 1) % (GLOBAL_THRESHHOLD+1)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_chatcommand("msync", {
|
minetest.register_chatcommand("matrix", {
|
||||||
privs = {
|
privs = {
|
||||||
interact = true
|
interact = true
|
||||||
},
|
},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
if param == "nil" then -- test sync as called from login
|
if param == "nil" then -- test sync as called from login
|
||||||
msync()
|
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()
|
mlogin()
|
||||||
|
return true, "[matrix_bridge] command: log in"
|
||||||
elseif #param > 1 then -- test sync with specific 'since' parameter
|
elseif #param > 1 then -- test sync with specific 'since' parameter
|
||||||
msync(param)
|
msync(param)
|
||||||
|
return true, "[matrix_bridge] command: sync("..since..")"
|
||||||
else -- test sync with current since parameter
|
else -- test sync with current since parameter
|
||||||
msync(since)
|
msync(since)
|
||||||
|
return true, "[matrix_bridge] command: sync(<current>)"
|
||||||
end
|
end
|
||||||
return true, "[matrix_bridge] Fetching from matrix..."
|
|
||||||
end})
|
end})
|
||||||
|
|
||||||
minetest.register_on_shutdown(function()
|
minetest.register_on_shutdown(function()
|
||||||
minetest.log("action", "matrix_bridge - signing out.")
|
mlogout()
|
||||||
local u = MATRIX_SERVER.."/logout/all"
|
|
||||||
http.fetch({url=u, method="POST", function (res) end})
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
|
Loading…
Reference in New Issue