clix, clix.send: Support for chatrooms (-c/--chatroom with --nick=somenick)

Thu, 07 Jan 2010 21:22:27 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Thu, 07 Jan 2010 21:22:27 +0000
changeset 21
cdeb02d9546d
parent 20
80cc61512f10
child 22
19c5a66837ed

clix, clix.send: Support for chatrooms (-c/--chatroom with --nick=somenick)

clix.lua file | annotate | diff | comparison | revisions
clix/send.lua file | annotate | diff | comparison | revisions
--- 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

mercurial