clix.lua

changeset 21
cdeb02d9546d
parent 20
80cc61512f10
child 23
c5f04bdc7c64
equal deleted inserted replaced
20:80cc61512f10 21:cdeb02d9546d
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", p = "password", r = "resource", o = "presence" } 12 short_opts = { v = "verbose", t = "to", f = "from", e = "type", a = "account",
13 p = "password", r = "resource", o = "presence", c = "chatroom" }
13 14
14 local command = arg[1]; 15 local command = arg[1];
15 16
16 if not command then 17 if not command then
17 print("Command Line XMPP, available commands:"); 18 print("Command Line XMPP, available commands:");
73 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 ""));
74 conn:close(); 75 conn:close();
75 end); 76 end);
76 conn:hook("binding-success", function () 77 conn:hook("binding-success", function ()
77 conn:debug("Connected: "..tostring(conn)); 78 conn:debug("Connected: "..tostring(conn));
79 if opts.chatroom then
80 conn:send(verse.presence{to=opts.to.."/"..(opts.nick or "clix")});
81 end
78 if opts.presence then 82 if opts.presence then
79 conn:send(verse.presence()); 83 conn:send(verse.presence());
80 end 84 end
81 return on_connect(conn); 85 return on_connect(conn);
82 end); 86 end);

mercurial