Do not run globalstep when no player or no token

This commit is contained in:
Pascal Engélibert 2022-01-31 14:57:52 +01:00
parent 5dfcf905f4
commit 1df668e6dc
Signed by: tuxmain
GPG Key ID: 3504BC6D362F7DCA
1 changed files with 4 additions and 1 deletions

View File

@ -172,11 +172,14 @@ end
local INTERVAL = 60
local HANDLE = nil
minetest.register_globalstep(function(dtime)
if MatrixChat.token == nil or #minetest.get_connected_players() == 0 then
return
end
if HANDLE == nil then
local request = MatrixChat:get_sync_table(INTERVAL * 1000)
request.timeout = INTERVAL
HANDLE = http.fetch_async(request)
elseif HANDLE ~= nil then
else
local result = http.fetch_async_get(HANDLE)
if result.completed then
if result.code == 200 then