clix.lua

changeset 23
c5f04bdc7c64
parent 21
cdeb02d9546d
child 28
c2998f70dfd4
equal deleted inserted replaced
22:19c5a66837ed 23:c5f04bdc7c64
7 -- 7 --
8 require "verse" 8 require "verse"
9 require "verse.client" 9 require "verse.client"
10 10
11 -- Global to allow commands to add to it 11 -- Global to allow commands to add to it
12 short_opts = { v = "verbose", t = "to", f = "from", e = "type", a = "account", 12 short_opts = { v = "verbose", q = "quiet", t = "to", f = "from", e = "type",
13 p = "password", r = "resource", o = "presence", c = "chatroom" } 13 a = "account", p = "password", r = "resource", o = "presence", c = "chatroom" }
14 14
15 local command = arg[1]; 15 local command = arg[1];
16 16
17 if not command then 17 if not command then
18 print("Command Line XMPP, available commands:"); 18 print("Command Line XMPP, available commands:");
73 conn:hook("authentication-failure", function (err) 73 conn:hook("authentication-failure", function (err)
74 conn:error("Authentication failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); 74 conn:error("Authentication failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or ""));
75 conn:close(); 75 conn:close();
76 end); 76 end);
77 conn:hook("binding-success", function () 77 conn:hook("binding-success", function ()
78 conn:debug("Connected: "..tostring(conn)); 78 if not opts.quiet then
79 io.stderr:write("clix: connected as ", conn.jid, "\n");
80 end
79 if opts.chatroom then 81 if opts.chatroom then
80 conn:send(verse.presence{to=opts.to.."/"..(opts.nick or "clix")}); 82 conn:send(verse.presence{to=opts.to.."/"..(opts.nick or "clix")});
81 end 83 end
82 if opts.presence then 84 if opts.presence then
83 conn:send(verse.presence()); 85 conn:send(verse.presence());

mercurial