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)
|
||||
|
||||
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 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)
|
||||
http.fetch(MatrixChat:get_sync_table(timeout),
|
||||
function (res)
|
||||
function(res)
|
||||
if res == nil then -- received nothing from server
|
||||
minetest.log("error", "matrix_bridge - sync response is nil")
|
||||
elseif res.code == 0 then
|
||||
@ -130,7 +130,7 @@ function MatrixChat:send(msg)
|
||||
local h = {"Content-Type: application/json", "Authorization: Bearer " .. self.token}
|
||||
local d = minetest.write_json({msgtype="m.text", body=msg})
|
||||
http.fetch({url=u, method="PUT", extra_headers=h, data=d},
|
||||
function (res)
|
||||
function(res)
|
||||
if res.code == 200 then
|
||||
local data = minetest.parse_json(res.data)
|
||||
minetest.log("action", "got " .. data["event_id"])
|
||||
@ -145,10 +145,10 @@ end
|
||||
|
||||
-- https://matrix.org/docs/api/client-server/#post-/logout/all
|
||||
-- POST /logout/all
|
||||
function MatrixChat:logout ()
|
||||
function MatrixChat:logout()
|
||||
local u = self.server .."/logout/all"
|
||||
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.")
|
||||
end
|
||||
|
||||
@ -224,8 +224,7 @@ end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player, timed_out)
|
||||
local name = player:get_player_name()
|
||||
MatrixChat:send("*** "..name.." left the game"..
|
||||
(timed_out and " (Timed out)" or ""))
|
||||
MatrixChat:send("*** "..name.." left the game"..(timed_out and " (Timed out)" or ""))
|
||||
end)
|
||||
|
||||
minetest.register_on_chat_message(function(name, message)
|
||||
|
Loading…
x
Reference in New Issue
Block a user