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" } |
12 short_opts = { v = "verbose", t = "to", f = "from", e = "type", a = "account", p = "password", r = "resource", o = "presence" } |
13 |
13 |
14 local command = arg[1]; |
14 local command = arg[1]; |
15 |
15 |
16 if not command then |
16 if not command then |
17 print("Command Line XMPP, available commands:"); |
17 print("Command Line XMPP, available commands:"); |
65 conn.log.debug = opts.verbose; |
65 conn.log.debug = opts.verbose; |
66 conn:hook("authentication-failure", function (err) |
66 conn:hook("authentication-failure", function (err) |
67 conn:error("Authentication failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); |
67 conn:error("Authentication failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); |
68 conn:close(); |
68 conn:close(); |
69 end); |
69 end); |
70 conn:hook("binding-success", function () conn:debug("Connected: "..tostring(conn)); return on_connect(conn); end); |
70 conn:hook("binding-success", function () |
|
71 conn:debug("Connected: "..tostring(conn)); |
|
72 if opts.presence then |
|
73 conn:send(verse.presence()); |
|
74 end |
|
75 return on_connect(conn); |
|
76 end); |
71 conn:hook("binding-failure", function (err) |
77 conn:hook("binding-failure", function (err) |
72 conn:error("Resource binding failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); |
78 conn:error("Resource binding failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); |
73 conn:close(); |
79 conn:close(); |
74 end); |
80 end); |
75 conn:hook("disconnected", function (info) |
81 conn:hook("disconnected", function (info) |