From 1a34cd0fce49991ba0888029f0a42fd5f730a997 Mon Sep 17 00:00:00 2001 From: olive Date: Sat, 12 Sep 2026 16:21:14 +0100 Subject: remove old hardcoded config from main.lua and add example conf --- config.lua | 2 +- main.lua | 38 ++++---------------------------------- wilson.ini.example | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 35 deletions(-) create mode 100644 wilson.ini.example diff --git a/config.lua b/config.lua index c19a087..cba0d0c 100644 --- a/config.lua +++ b/config.lua @@ -11,7 +11,7 @@ local function tuple_syntax(pattern) return function(block,line) local matches = {line:match(pattern)} assert(matches[1], "syntax error in tuple line: "..line) table.insert(block, matches) -end end +end end local schema = { pylon = kv_syntax, diff --git a/main.lua b/main.lua index fd0d146..cba7080 100644 --- a/main.lua +++ b/main.lua @@ -9,20 +9,20 @@ local pylon_classes = { } local Wilson = {} -function Wilson.make(config) +function Wilson.make(conf) local self = { pylons={}, busses={}, cq = cqueues.new(), } - for name, pylon_conf in pairs(config.pylon) do + for name, pylon_conf in pairs(conf.pylon) do pylon_conf.name = name local pylon_class = pylon_classes[pylon_conf.type] assert(pylon_class, "no such pylon type "..pylon_conf.type) self.pylons[name] = pylon_class.make(self, pylon_conf) print("constructed pylon",name,pylon_conf.type) end - for name, bus_conf in pairs(config.bus) do + for name, bus_conf in pairs(conf.bus) do local bus = {} for _, item in ipairs(bus_conf) do local pylon_name, channel_descriptor = item[1], item[2] @@ -61,38 +61,8 @@ function Wilson.run(self) print('toplevel',self.cq:loop()) end -local config_file = io.open("wilson.ini","r") +local config_file = assert(io.open("wilson.ini","r")) local conf = config.parse(config_file) config_file:close() local wilson = Wilson.make(conf) wilson:run() - - - - --- local pylon_confs = { --- xmpp_ubq323 = { --- type='xmpp', --- jid='wilson@ubq323.website', --- server='localhost', --- component='wilson.ubq323.website', --- component_secret='super_secret_wilson_password', --- resource='wilson', --- }, --- irc_local = { --- type='irc', --- host='localhost', --- port=6667, --- password='mypassword', --- nodename='wilson.ubq323', --- }, --- } --- local bus_confs = { --- d = { --- {'xmpp_ubq323', 'd@conference.ubq323.website'}, --- {'irc_local', '#test'}, --- }, --- } - --- local the_network = Wilson.make(pylon_confs, bus_confs) --- the_network:run() diff --git a/wilson.ini.example b/wilson.ini.example new file mode 100644 index 0000000..8a06b03 --- /dev/null +++ b/wilson.ini.example @@ -0,0 +1,24 @@ +[pylon xmpp-barbaz] +type=xmpp +; port 5222 +server=boingsrv.example.org +component=barbaz.boingsrv.example.org +component_secret=seeeeeecret_password_here + +[pylon irc-boopbanana] +type=irc +host=localhost +port=6667 +password=seeeeeecret_password_here +nodename=boopbanana.boing + +[pylon discord-foobar] +type=discord +token=bot_token_here +temp_wh=webhook_here + + +[bus test] +xmpp-barbaz test@conference.example.org +irc-boopbanana #test +discord-foobar channel_id_here -- cgit v1.2.3