Sat, 10 Apr 2021 00:13:23 +0200
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!
clix/raw.lua | file | annotate | diff | comparison | revisions |
--- 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