clix.lua

changeset 122
1dfd28db10bd
parent 102
f1166645a56c
parent 107
a074eaacefe7
child 127
6a27edf256c3
equal deleted inserted replaced
103:45843df81db0 122:1dfd28db10bd
57 local account = accounts[opts.account or "default"]; 57 local account = accounts[opts.account or "default"];
58 if not (account and account.jid) then 58 if not (account and account.jid) then
59 io.stderr:write("The specified account (", opts.account or "default", ") wasn't found in the config file\n"); 59 io.stderr:write("The specified account (", opts.account or "default", ") wasn't found in the config file\n");
60 return nil; 60 return nil;
61 end 61 end
62 verse.set_log_handler(io.stderr, opts.quiet and {} or not opts.verbose and {"info", "error"}); 62 verse.set_log_handler(io.stderr, opts.quiet and {} or not opts.verbose and {"info", "warn", "error"});
63 local conn = verse.new(verse.new_logger("clix")); 63 local conn = verse.new(verse.new_logger("clix"));
64 if opts.raw then
65 conn:hook("incoming-raw", print, 1000);
66 conn:hook("outgoing-raw", print, 1000);
67 end
64 for _, plugin in ipairs(plugins or {}) do 68 for _, plugin in ipairs(plugins or {}) do
65 conn:add_plugin(plugin); 69 conn:add_plugin(plugin);
66 end 70 end
67 conn:hook("authentication-failure", function (err) 71 conn:hook("authentication-failure", function (err)
68 conn:error("Authentication failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); 72 conn:error("Authentication failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or ""));
81 conn:hook("bind-failure", function (err) 85 conn:hook("bind-failure", function (err)
82 conn:error("Resource binding failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); 86 conn:error("Resource binding failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or ""));
83 conn:close(); 87 conn:close();
84 end); 88 end);
85 conn:hook("disconnected", function (info) 89 conn:hook("disconnected", function (info)
86 if info.reason then 90 if info and info.reason and info.reason ~= "stream closed" then
87 conn:warn("Disconnecting: %s", tostring(info.reason)); 91 conn:warn("Disconnecting: %s", tostring(info.reason));
88 end 92 end
89 verse.quit(); 93 verse.quit();
90 end); 94 end);
91 -- Optional config parameters 95 -- Optional config parameters

mercurial