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" } |
12 short_opts = { v = "verbose", t = "to", f = "from", e = "type", a = "account", p = "password", r = "resource" } |
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:"); |
77 verse.quit(); |
77 verse.quit(); |
78 end); |
78 end); |
79 -- Optional config parameters |
79 -- Optional config parameters |
80 conn.connect_host = account.address; |
80 conn.connect_host = account.address; |
81 conn.connect_port = account.port; |
81 conn.connect_port = account.port; |
|
82 |
82 -- Connect! |
83 -- Connect! |
83 conn:connect_client(account.jid, account.password); |
84 conn:connect_client(account.jid, account.password); |
|
85 |
|
86 if type(opts.resource) == "string" then |
|
87 conn.resource = opts.resource; |
|
88 end |
84 |
89 |
85 local ok, ret = pcall(verse.loop); |
90 local ok, ret = pcall(verse.loop); |
86 if not ok and not ret:match("interrupted!$") then |
91 if not ok and not ret:match("interrupted!$") then |
87 io.stderr:write("Fatal error: ", ret, "\n"); |
92 io.stderr:write("Fatal error: ", ret, "\n"); |
88 return 1; |
93 return 1; |