examples/xep0047.lua
changeset 24 25552b21d3fb
parent 10 73f4c12b6ffb
child 27 92b254b64360
--- a/examples/xep0047.lua	Sun Mar 15 15:03:51 2009 +0200
+++ b/examples/xep0047.lua	Sun Mar 15 20:45:24 2009 +0200
@@ -168,35 +168,37 @@
 main.command ( 'ibb',
 	function ( args )
 		args = parse_args ( args )
-		if args[1] == 'send' then
+		local action = args[1]
+		if action == 'send' then
 			local who
 			if args.t then
 				who = args.t
-				args.t = nil
 			else
 				who = main.full_jid ()
 			end
-			args[1] = nil
-			send_file ( who, rebuild_args_string ( args ) )
-		elseif args[1] == 'accept' then
+			send_file ( who, args[2] )
+		elseif action == 'accept' then
 			local id = args[2]
-			args[1] = nil
-			args[2] = nil
 			if receiving_files[id] then
-				receiving_files[id].accept ( rebuild_args_string ( args ) )
+				receiving_files[id].accept ( args[3] )
 			end
-		elseif args[1] == 'reject' then
+		elseif action == 'reject' then
 			local id = args[2]
 			if receiving_files[id] then
 				receiving_files[id].reject ()
 			end
-		elseif args[1] == 'del' then
+		elseif action == 'del' then
 			local id = args[2]
 			receiving_files[id] = nil
 		else
-			print ( 'List of incoming streams:' )
+			local text = ''
 			for sid, data in pairs ( receiving_files ) do
-				print ( sid .. ': ' .. ( data.name or '(not set)' ) .. ' [' .. data.status .. ']' )
+				text = text .. '\n' ..  sid .. ': ' .. ( data.name or '(not set)' ) .. ' [' .. data.status .. ']'
+			end
+			if text ~= '' then
+				print ( 'List of incoming streams:' .. text )
+			else
+				print ( 'No streams' )
 			end
 		end
 	end, { "send", "accept", "reject", "del" } )