matrix_chat/config.lua
joenas c3c6731d8b Breaking changes:
Removed port setting (fixes #9)
Throw errors when weird/faulty matrix url (work on #10)
Added neturl for url parsing
2017-09-12 11:30:03 +02:00

33 lines
1013 B
Lua

-- This file is licensed under the terms of the BSD 2-clause license.
-- See LICENSE.txt for details.
matrix.config = {}
local function setting(stype, name, default, required)
local value
if stype == "bool" then
value = minetest.setting_getbool("matrix."..name)
elseif stype == "string" then
value = minetest.setting_get("matrix."..name)
elseif stype == "number" then
value = tonumber(minetest.setting_get("matrix."..name))
end
if value == nil then
if required then
error("Required configuration option matrix."..
name.." missing.")
end
value = default
end
matrix.config[name] = value
end
-------------------------
-- BASIC USER SETTINGS --
-------------------------
setting("string", "user", nil, true) -- User name, fe @digbot:matrix.org
setting("string", "server", nil, true) -- Server address to connect to
setting("string", "room_id", nil, true) -- Channel to join (not needed?)
setting("string", "password", nil, true) -- Server password