-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathconfig.lua
More file actions
36 lines (27 loc) · 711 Bytes
/
config.lua
File metadata and controls
36 lines (27 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local pcall = pcall
local setfenv = setfenv
local ipairs = ipairs
local loadfile = loadfile
-- reference to IRC module
local irc = irc
module "ircbot"
local function tableField(tbl, name)
tbl[name] = function(t)
tbl[name] = t
end
end
function loadConfigTable(path, tableFields)
local f, err = loadfile(path)
if not f then return nil, err end
-- Make the bold, underline, color, etc functions available for config msgs
local config = {bold = irc.bold, underline = irc.underline, color = irc.color}
if tableFields then
for k, field in ipairs(tableFields) do
tableField(config, field)
end
end
setfenv(f, config)
f, err = pcall(f)
if not f then return nil, err end
return config
end