--- a/examples/register.lua Wed Mar 31 00:28:04 2010 +0300
+++ b/examples/register.lua Wed Mar 31 01:25:19 2010 +0300
@@ -4,13 +4,18 @@
main.command ( 'register',
function ( args )
+ local connection = main.connection ()
+ if not connection then
+ print "You are not online!"
+ return
+ end
local who
if args and args ~= '' then
who = args
else
who = main.full_jid ()
end
- iq_register.register ( lm.connection.bless ( main.connection () ), who,
+ iq_register.register ( lm.connection.bless ( connection ), who,
function ( form, submit, reject )
insert_form ( form,
function ( form )
@@ -38,13 +43,18 @@
end, false, 'jid' )
main.command ( 'cancel',
function ( args )
+ local connection = main.connection ()
+ if not connection then
+ print "You are not online!"
+ return
+ end
local who
if args and args ~= '' then
who = args
else
who = main.full_jid ()
end
- iq_register.unregister ( lm.connection.bless ( main.connection () ), who,
+ iq_register.unregister ( lm.connection.bless ( connection ), who,
function ( form, submit, reject )
if not form then
main.print_info ( who, 'Successfully unregistered' )
@@ -78,4 +88,4 @@
commands_help['register'] = "[jid]\n\nSends registration request to jid (or current buddy). You, probably, then will need to fill and send some form."
commands_help['cancel'] = "[jid]\n\nSends registration cancellation request to jid (or current buddy). May require a form filling."
--- vim: se ts=4: --
+-- vim: se ts=4 sw=4: --