Code cleanup
This commit is contained in:
parent
c33d1e9cb6
commit
e307c24e06
@ -32,7 +32,7 @@ See [Matrix API docs](https://www.matrix.org/docs/guides/client-server-api).
|
|||||||
|
|
||||||
A bit of code comes from [diggers-mt/matrix_chat](https://github.com/diggers-mt/matrix_chat): BSD-2-Clause, Copyright 2017 Jon Neverland (joenas)
|
A bit of code comes from [diggers-mt/matrix_chat](https://github.com/diggers-mt/matrix_chat): BSD-2-Clause, Copyright 2017 Jon Neverland (joenas)
|
||||||
|
|
||||||
GNU AGPL v3, CopyLeft 2022 Pascal Engélibert (tuxmain)
|
GNU AGPL v3, CopyLeft 2022 Pascal Engélibert (tuxmain), scuti
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License.
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License.
|
||||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
||||||
|
11
init.lua
11
init.lua
@ -79,7 +79,7 @@ end
|
|||||||
|
|
||||||
function MatrixChat:sync(timeout)
|
function MatrixChat:sync(timeout)
|
||||||
http.fetch(MatrixChat:get_sync_table(timeout),
|
http.fetch(MatrixChat:get_sync_table(timeout),
|
||||||
function (res)
|
function(res)
|
||||||
if res == nil then -- received nothing from server
|
if res == nil then -- received nothing from server
|
||||||
minetest.log("error", "matrix_bridge - sync response is nil")
|
minetest.log("error", "matrix_bridge - sync response is nil")
|
||||||
elseif res.code == 0 then
|
elseif res.code == 0 then
|
||||||
@ -130,7 +130,7 @@ function MatrixChat:send(msg)
|
|||||||
local h = {"Content-Type: application/json", "Authorization: Bearer " .. self.token}
|
local h = {"Content-Type: application/json", "Authorization: Bearer " .. self.token}
|
||||||
local d = minetest.write_json({msgtype="m.text", body=msg})
|
local d = minetest.write_json({msgtype="m.text", body=msg})
|
||||||
http.fetch({url=u, method="PUT", extra_headers=h, data=d},
|
http.fetch({url=u, method="PUT", extra_headers=h, data=d},
|
||||||
function (res)
|
function(res)
|
||||||
if res.code == 200 then
|
if res.code == 200 then
|
||||||
local data = minetest.parse_json(res.data)
|
local data = minetest.parse_json(res.data)
|
||||||
minetest.log("action", "got " .. data["event_id"])
|
minetest.log("action", "got " .. data["event_id"])
|
||||||
@ -145,10 +145,10 @@ end
|
|||||||
|
|
||||||
-- https://matrix.org/docs/api/client-server/#post-/logout/all
|
-- https://matrix.org/docs/api/client-server/#post-/logout/all
|
||||||
-- POST /logout/all
|
-- POST /logout/all
|
||||||
function MatrixChat:logout ()
|
function MatrixChat:logout()
|
||||||
local u = self.server .."/logout/all"
|
local u = self.server .."/logout/all"
|
||||||
local h = {"Authorization: Bearer " .. self.token}
|
local h = {"Authorization: Bearer " .. self.token}
|
||||||
http.fetch({url=u, method="POST", extra_headers=h, function (res) end})
|
http.fetch({url=u, method="POST", extra_headers=h, function(res) end})
|
||||||
minetest.log("action", "matrix_bridge - signing out.")
|
minetest.log("action", "matrix_bridge - signing out.")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -224,8 +224,7 @@ end)
|
|||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player, timed_out)
|
minetest.register_on_leaveplayer(function(player, timed_out)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
MatrixChat:send("*** "..name.." left the game"..
|
MatrixChat:send("*** "..name.." left the game"..(timed_out and " (Timed out)" or ""))
|
||||||
(timed_out and " (Timed out)" or ""))
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_chat_message(function(name, message)
|
minetest.register_on_chat_message(function(name, message)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user