Changeset

21:cdeb02d9546d

clix, clix.send: Support for chatrooms (-c/--chatroom with --nick=somenick)
author Matthew Wild <mwild1@gmail.com>
date Thu, 07 Jan 2010 21:22:27 +0000
parents 20:80cc61512f10
children 22:19c5a66837ed
files clix.lua clix/send.lua
diffstat 2 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/clix.lua	Thu Jan 07 20:59:15 2010 +0000
+++ b/clix.lua	Thu Jan 07 21:22:27 2010 +0000
@@ -9,7 +9,8 @@
 require "verse.client"
 
 -- Global to allow commands to add to it
-short_opts = { v = "verbose", t = "to", f = "from", e = "type", a = "account", p = "password", r = "resource", o = "presence" }
+short_opts = { v = "verbose", t = "to", f = "from", e = "type", a = "account",
+	p = "password", r = "resource", o = "presence", c = "chatroom" }
 
 local command = arg[1];
 
@@ -75,6 +76,9 @@
 	end);
 	conn:hook("binding-success", function ()
 		conn:debug("Connected: "..tostring(conn));
+		if opts.chatroom then
+			conn:send(verse.presence{to=opts.to.."/"..(opts.nick or "clix")});
+		end
 		if opts.presence then
 			conn:send(verse.presence());
 		end
--- a/clix/send.lua	Thu Jan 07 20:59:15 2010 +0000
+++ b/clix/send.lua	Thu Jan 07 21:22:27 2010 +0000
@@ -7,7 +7,9 @@
 	end
 	local function on_connect(conn)
 		local function send_message(text)
-			conn:send(verse.message({ to = opts.to, type = opts.type or "chat" }):body(text));
+			conn:send(verse.message({ to = opts.to,
+				type = opts.type or (opts.chatroom and "groupchat") or "chat" })
+				:body(text));
 		end
 		if opts.interactive or opts.stdin then
 			-- Fake socket object around stdin