clix/mirror.lua

Mon, 11 Feb 2013 00:00:49 +0100

author
Kim Alvefur <zash@zash.se>
date
Mon, 11 Feb 2013 00:00:49 +0100
changeset 107
a074eaacefe7
parent 27
5b58c002d6ad
permissions
-rw-r--r--

clix.lua: Don't break if the disconnected event has no event data, and don't warn if the stream was closed cleanly

return function (opts, arg)
	if opts.short_help then
		print("Echo received stanzas back to sender");
		return;
	end
	local function on_connect(conn)
		local function on_stanza(stanza)
			if stanza.name == "presence" and opts.presence
				and not opts.mirror_presence then
				return;
			end
			stanza.attr.to, stanza.attr.from = stanza.attr.from, stanza.attr.to;
			conn:send(stanza);
			stanza.attr.to, stanza.attr.from = stanza.attr.from, stanza.attr.to;
		end
		conn:hook("stanza", on_stanza);
	end
	return clix_connect(opts, on_connect);
end

mercurial