Software /
code /
clix
Comparison
clix.lua @ 42:4f4fe532a889
clix.lua: clix_connect(): Accept a list of plugins to load for the Verse connection
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 15 Sep 2010 16:40:14 +0100 |
parent | 41:89070edde205 |
child | 43:1ec64b321834 |
comparison
equal
deleted
inserted
replaced
41:89070edde205 | 42:4f4fe532a889 |
---|---|
50 accounts[current_account or "default"][k] = v; | 50 accounts[current_account or "default"][k] = v; |
51 end | 51 end |
52 end | 52 end |
53 end | 53 end |
54 | 54 |
55 function clix_connect(opts, on_connect) | 55 function clix_connect(opts, on_connect, plugins) |
56 local account = accounts[opts.account or "default"]; | 56 local account = accounts[opts.account or "default"]; |
57 if not (account and account.jid) then | 57 if not (account and account.jid) then |
58 io.stderr:write("The specified account (", opts.account or "default", ") wasn't found in the config file\n"); | 58 io.stderr:write("The specified account (", opts.account or "default", ") wasn't found in the config file\n"); |
59 return nil; | 59 return nil; |
60 end | 60 end |
61 verse.set_logger(opts.verbose and verse.logger() or function () end); | 61 verse.set_logger(opts.verbose and verse.logger() or function () end); |
62 local conn = verse.new(verse.logger()); | 62 local conn = verse.new(verse.logger()); |
63 for _, plugin in ipairs(plugins or {}) do | |
64 conn:add_plugin(plugin); | |
65 end | |
63 conn.log.debug = opts.verbose; | 66 conn.log.debug = opts.verbose; |
64 conn:hook("authentication-failure", function (err) | 67 conn:hook("authentication-failure", function (err) |
65 conn:error("Authentication failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); | 68 conn:error("Authentication failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); |
66 conn:close(); | 69 conn:close(); |
67 end); | 70 end); |