examples/xep0077.lua
changeset 8 fc9060b9b7cc
parent 7 eb6d89bf1fbf
child 9 c2517f8bf647
equal deleted inserted replaced
7:eb6d89bf1fbf 8:fc9060b9b7cc
    18 			end
    18 			end
    19 			table.insert ( form.val, { type = 'text-single', var = name, value = { field:value () or '' } } )
    19 			table.insert ( form.val, { type = 'text-single', var = name, value = { field:value () or '' } } )
    20 		end
    20 		end
    21 		field = field:next ()
    21 		field = field:next ()
    22 	end
    22 	end
    23 	table.insert ( forms, form )
    23 	return insert_form ( form )
    24 	return #forms
       
    25 end
    24 end
    26 
    25 
    27 function format_iq_register ( fields )
    26 function format_iq_register ( fields )
    28 	local result = { xmlns = 'jabber:iq:register' }
    27 	local result = { xmlns = 'jabber:iq:register' }
    29 	for index, field in ipairs ( fields ) do
    28 	for index, field in ipairs ( fields ) do
   144 end
   143 end
   145 
   144 
   146 main.command ( 'register',
   145 main.command ( 'register',
   147 	function ( args )
   146 	function ( args )
   148 		local who
   147 		local who
   149 		if args[1] then
   148 		if args and args ~= '' then
   150 			who = rebuild_args_string ( args )
   149 			who = args
   151 		else
   150 		else
   152 			who = full_current_jid ()
   151 			who = full_current_jid ()
   153 		end
   152 		end
   154 		register_to ( who )
   153 		register_to ( who )
   155 	end )
   154 	end, 0x2 )
   156 
   155 
   157 main.command ( 'cancel',
   156 main.command ( 'cancel',
   158 	function ( args )
   157 	function ( args )
   159 		local who
   158 		local who
   160 		if args and args ~= '' then
   159 		if args and args ~= '' then
   161 			who = args
   160 			who = args
   162 		else
   161 		else
   163 			who = full_current_jid ()
   162 			who = full_current_jid ()
   164 		end
   163 		end
   165 		unregister_from ( who )
   164 		unregister_from ( who )
   166 	end )
   165 	end, 0x2 )
   167 
   166 
   168 commands_help['register'] = "[jid]\n\nSends registration request to jid (or current buddy). You, probably, then will need to fill and send some form."
   167 commands_help['register'] = "[jid]\n\nSends registration request to jid (or current buddy). You, probably, then will need to fill and send some form."
   169 commands_help['cancel'] = "[jid]\n\nSends registration cancellation request to jid (or current buddy). May require a form filling."
   168 commands_help['cancel'] = "[jid]\n\nSends registration cancellation request to jid (or current buddy). May require a form filling."
   170 
   169 
   171 -- vim: se ts=4: --
   170 -- vim: se ts=4: --