author | Tero Marttila <terom@fixme.fi> |
Thu, 02 Apr 2009 03:02:54 +0300 | |
changeset 115 | 2d74b38b56de |
parent 106 | f00661136ac2 |
child 134 | 978041c1c04d |
permissions | -rw-r--r-- |
106
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
1 |
local conf = { |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
log_level = "DEBUG", |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
|
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
4 |
name = { |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
5 |
nickname = "SpBotDev", |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
6 |
username = "spbot-dev", |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
7 |
realname = "SpBot (development version)" |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
8 |
}, |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
9 |
|
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
10 |
networks = { |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
11 |
PVLNet = { |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
12 |
hostname = "irc.fixme.fi", |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
13 |
|
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
14 |
channels = { |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
15 |
"#test" |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
16 |
} |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
17 |
}, |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
18 |
}, |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
19 |
|
115
2d74b38b56de
implement modules:path for config.lua
Tero Marttila <terom@fixme.fi>
parents:
106
diff
changeset
|
20 |
modules_path = "src/modules", |
2d74b38b56de
implement modules:path for config.lua
Tero Marttila <terom@fixme.fi>
parents:
106
diff
changeset
|
21 |
|
106
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
22 |
modules = { |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
23 |
irc_log = { |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
24 |
conf = { |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
25 |
db_info = "dbname=spbot", |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
26 |
channel = "PVLNet/#test", |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
27 |
} |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
28 |
} |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
29 |
}, |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
30 |
} |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
31 |
|
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
32 |
-- apply general |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
33 |
log_level(conf.log_level) |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
34 |
|
115
2d74b38b56de
implement modules:path for config.lua
Tero Marttila <terom@fixme.fi>
parents:
106
diff
changeset
|
35 |
-- apply conf.name |
106
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
36 |
client:set_defaults(conf.name.nickname, conf.name.username, conf.name.realname) |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
37 |
|
115
2d74b38b56de
implement modules:path for config.lua
Tero Marttila <terom@fixme.fi>
parents:
106
diff
changeset
|
38 |
-- apply conf.networks |
106
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
39 |
for network, settings in pairs(conf.networks) do |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
40 |
-- establish the irc_net |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
41 |
net = client:connect(network, settings.hostname) |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
42 |
|
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
43 |
-- join each channel |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
44 |
for i, channel in ipairs(settings.channels) do |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
45 |
net:join(channel) |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
46 |
end |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
47 |
end |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
48 |
|
115
2d74b38b56de
implement modules:path for config.lua
Tero Marttila <terom@fixme.fi>
parents:
106
diff
changeset
|
49 |
-- apply conf.modules_path |
2d74b38b56de
implement modules:path for config.lua
Tero Marttila <terom@fixme.fi>
parents:
106
diff
changeset
|
50 |
if conf.modules_path then |
2d74b38b56de
implement modules:path for config.lua
Tero Marttila <terom@fixme.fi>
parents:
106
diff
changeset
|
51 |
modules:path(conf.modules_path) |
2d74b38b56de
implement modules:path for config.lua
Tero Marttila <terom@fixme.fi>
parents:
106
diff
changeset
|
52 |
end |
2d74b38b56de
implement modules:path for config.lua
Tero Marttila <terom@fixme.fi>
parents:
106
diff
changeset
|
53 |
|
2d74b38b56de
implement modules:path for config.lua
Tero Marttila <terom@fixme.fi>
parents:
106
diff
changeset
|
54 |
-- apply conf.modules |
106
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
55 |
for name, settings in pairs(conf.modules) do |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
56 |
-- load the module |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
57 |
module = modules:load(name, settings.path) |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
58 |
|
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
59 |
-- apply confs |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
60 |
for key, value in pairs(settings.conf) do |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
61 |
module:conf(key, value) |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
62 |
end |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
63 |
end |
f00661136ac2
add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
64 |