fixed bug - multiples of the same message from matrix

This commit is contained in:
- 2022-01-23 14:06:16 -08:00
parent 9b05dd74c0
commit 1aabbeaee3
1 changed files with 10 additions and 8 deletions

View File

@ -21,6 +21,9 @@ local function mchat(data)
if data == nil then if data == nil then
return return
end end
if since == data.next_batch then
return
end
-- lets just get this working -- lets just get this working
if data["rooms"] == nil then if data["rooms"] == nil then
return return
@ -44,6 +47,7 @@ local function mchat(data)
if event.type == "m.room.message" if event.type == "m.room.message"
and event.sender ~= MATRIX_USERNAME_LONG then and event.sender ~= MATRIX_USERNAME_LONG then
local message = event.sender .. ": " .. event.content.body local message = event.sender .. ": " .. event.content.body
minetest.log("action", message)
minetest.chat_send_all(message) minetest.chat_send_all(message)
end end
end end
@ -69,14 +73,12 @@ local function msync(s)
elseif res.code == 0 then elseif res.code == 0 then
minetest.log("info", "matrix_bridge - not found / timeout") minetest.log("info", "matrix_bridge - not found / timeout")
elseif res.code == 404 then elseif res.code == 404 then
minetest.log("error", "matrix_bridge - 404")
minetest.log("action", res.data)
else else
local response = minetest.parse_json(res.data) local response = minetest.parse_json(res.data)
if response ~= nil then if response ~= nil then
mchat(response)
since = response.next_batch since = response.next_batch
last_batch = response.prev_batch last_batch = response.prev_batch
mchat(response)
end end
end end
end end
@ -130,14 +132,14 @@ end
-- end -- end
-- end) -- 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)
-- if GLOBAL_STEPS == 4 then -- if GLOBAL_STEPS == 4 then
-- msync() msync(since)
-- end -- end
-- GLOBAL_STEPS = (GLOBAL_STEPS + 1) % 5 -- GLOBAL_STEPS = (GLOBAL_STEPS + 1) % 5
-- end) end)
minetest.register_chatcommand("msync", { minetest.register_chatcommand("msync", {
privs = { privs = {