adv_chat/conf.lua

124 lines
4.3 KiB
Lua
Raw Normal View History

2019-11-23 09:17:10 -08:00
local schemedef={children={
2019-10-31 13:54:15 -07:00
message_prefix={type="string"},
mention_prefix={type="string"},
mention_delim={type="string"},
content_prefix={type="string"},
message_suffix={type="string"},
2019-11-23 09:17:10 -08:00
}}
2019-07-13 11:03:35 -07:00
local conf_spec={type="table", children={
2019-10-31 13:54:15 -07:00
schemes={type="table", required_children={
2019-07-13 11:03:35 -07:00
minetest=schemedef
}, possible_children={
2019-10-31 13:54:15 -07:00
irc=schemedef,
discord=schemedef
2019-07-13 11:03:35 -07:00
}},
bridges={
type="table",
possible_children={
2019-10-31 13:54:15 -07:00
irc={type="table", required_children={
port={type="number", range={0, 65535}},
network={type="string"},
nickname={type="string"},
channelname={type="string"},
ssl={type="boolean"},
prefix={type="string"},
minetest_prefix={type="string"}
},
possible_children={
bridge={type="string", possible_values={"files", "sockets"}},
convert_minetest_colors={type="string", possible_values={"disabled", "hex", "safer", "safest"}},
handle_discord_markdown={type="boolean"},
handle_minetest_markdown={type="boolean"}
}},
2019-07-13 11:03:35 -07:00
discord={type="table", required_children={
token={type="string"},
channelname={type="string"},
prefix={type="string"},
minetest_prefix={type="string"}
},
possible_children={
blacklist={type="table", keys={type="string"}},
whitelist={type="table", keys={type="string"}},
2019-10-31 13:54:15 -07:00
guild_id={type="string"},
bridge={type="string", possible_values={"files", "sockets"}},
convert_internal_markdown={type="boolean"},
convert_minetest_markdown={type="boolean"},
handle_irc_styles={type="string", possible_values={"escape_markdown", "convert", "disabled"}}
2019-07-13 11:03:35 -07:00
}
2019-10-31 13:54:15 -07:00
},
command_blacklist={type="table", keys={type="number"}, values={type="string"}},
command_whitelist={type="table", keys={type="number"}, values={type="string"}}
2019-07-13 11:03:35 -07:00
}
}
2020-04-01 04:07:02 -07:00
}, possible_children={
roles_case_insensitive={type="boolean"}
2019-07-13 11:03:35 -07:00
}}
2020-02-29 03:55:23 -08:00
local config=modlib.conf.import("adv_chat", conf_spec)
modlib.table.add_all(getfenv(1), config)
2019-07-13 11:03:35 -07:00
2019-10-31 13:54:15 -07:00
function load_schemes()
for k, v in pairs(schemes.minetest) do
schemes.minetest[k] = colorize_message(v)
end
for _,s in pairs({"irc", "discord"}) do
if not schemes[s] then
schemes[s] = {}
for k, v in pairs(schemes.minetest) do
schemes[s][k] = minetest.strip_colors(v)
end
end
end
load_schemes = nil
end
2019-11-05 10:44:51 -08:00
if bridges.irc and not bridges.irc.style_conversion then
2019-10-31 13:54:15 -07:00
bridges.irc.style_conversion={}
if not bridges.irc.style_conversion.colors then
bridges.irc.style_conversion.colors="disabled"
end
end
2019-07-13 11:03:35 -07:00
if bridges.discord then
2020-02-29 03:55:23 -08:00
local blacklist_empty=modlib.table.is_empty(bridges.discord.blacklist or {})
local whitelist_empty=modlib.table.is_empty(bridges.discord.whitelist or {})
2019-07-13 11:03:35 -07:00
if blacklist_empty then
if not whitelist_empty then
bridges.discord.blacklist=setmetatable(bridges.discord.blacklist, {__index=function(value)
if bridges.discord.whitelist[value] then
return nil
end
return true
end})
end
else
if not whitelist_empty then
bridges.discord.blacklist={}
end
end
2019-10-31 13:54:15 -07:00
end
if bridges.discord or bridges.irc then
2020-02-29 03:55:23 -08:00
bridges.command_blacklist = modlib.table.set(bridges.command_blacklist or {})
bridges.command_whitelist = modlib.table.set(bridges.command_whitelist or {})
local blacklist_empty=modlib.table.is_empty(bridges.command_blacklist)
local whitelist_empty=modlib.table.is_empty(bridges.command_whitelist or {})
2019-10-31 13:54:15 -07:00
if blacklist_empty then
if not whitelist_empty then
bridges.command_blacklist=setmetatable(bridges.command_blacklist, {__index=function(value)
if bridges.command_whitelist[value] then
return nil
end
return true
end})
end
end
2019-11-23 09:17:10 -08:00
end