clix.receive: New command to print text of received messages

Thu, 07 Jan 2010 02:31:18 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Thu, 07 Jan 2010 02:31:18 +0000
changeset 12
1793fca3d707
parent 11
a502c905527c
child 13
751db005032e

clix.receive: New command to print text of received messages

clix/receive.lua file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/clix/receive.lua	Thu Jan 07 02:31:18 2010 +0000
@@ -0,0 +1,13 @@
+return function (opts, args)
+	local function on_message(message)
+		local body = message:get_child("body");
+		if body then
+			print(body:get_text());
+		end
+	end
+	local function on_connect(conn)
+		conn:hook("message", on_message);
+		conn:send(verse.presence());
+	end
+	clix_connect(opts, on_connect);
+end

mercurial