Changeset

150:af9b9acb10d6

clix.raw: Track and print response to iq stanza given as cli argument While fire-and-forget is okay for messages and presence, it's kinda useless for a lot of IQs uses, so this is pretty nice!
author Kim Alvefur <zash@zash.se>
date Sat, 10 Apr 2021 00:13:23 +0200
parents 149:014e73c329c5
children 151:5398623682d7
files clix/raw.lua
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/clix/raw.lua	Sat Apr 10 00:21:05 2021 +0200
+++ b/clix/raw.lua	Sat Apr 10 00:13:23 2021 +0200
@@ -1,4 +1,5 @@
 local verse = require "verse";
+local xml = require "util.xml";
 short_opts.i = "interactive";
 short_opts.e = "echo";
 
@@ -113,8 +114,15 @@
 			if not send_xml then
 				send_xml = table.concat(args, " ");
 			end
-			conn:send(send_xml);
-			conn:close();
+			send_xml = assert(xml.parse(send_xml));
+			if send_xml.name == "iq" then
+				conn:send_iq(send_xml, function ()
+					conn:close();
+				end);
+			else
+				conn:send(send_xml);
+				conn:close();
+			end
 		end
 
 	end