author | Myhailo Danylenko <isbear@ukrpost.net> |
Tue, 07 Aug 2012 02:43:46 +0300 | |
changeset 125 | 3e2421384d7a |
parent 121 | 75a7d595817c |
permissions | -rw-r--r-- |
68 | 1 |
|
2 |
local lm = require 'lm' |
|
3 |
local iq_register = require 'lm.iq_register' |
|
4 |
||
5 |
main.command ( 'register', |
|
6 |
function ( args ) |
|
99
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
7 |
local connection = main.connection () |
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
8 |
if not connection then |
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
9 |
print "You are not online!" |
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
10 |
return |
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
11 |
end |
68 | 12 |
local who |
13 |
if args and args ~= '' then |
|
14 |
who = args |
|
15 |
else |
|
16 |
who = main.full_jid () |
|
17 |
end |
|
99
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
18 |
iq_register.register ( lm.connection.bless ( connection ), who, |
68 | 19 |
function ( form, submit, reject ) |
20 |
insert_form ( form, |
|
21 |
function ( form ) |
|
22 |
submit ( form, |
|
23 |
function () |
|
24 |
main.print_info ( who, 'Successfully registered' ) |
|
25 |
end, |
|
26 |
function ( mesg ) |
|
27 |
main.print_info ( who, 'Registration failed: ' .. mesg ) |
|
28 |
end ) |
|
29 |
end, |
|
30 |
function ( form ) |
|
31 |
reject ( form, |
|
32 |
function () |
|
33 |
main.print_info ( who, 'Registration cancelled' ) |
|
34 |
end, |
|
35 |
function ( mesg ) |
|
36 |
main.print_info ( who, 'Registration cancellation failed: ' .. mesg ) |
|
37 |
end ) |
|
38 |
end ) |
|
39 |
end, |
|
40 |
function ( mesg ) |
|
41 |
main.print_info ( who, 'Registration failed: ' .. mesg ) |
|
42 |
end ) |
|
43 |
end, false, 'jid' ) |
|
44 |
main.command ( 'cancel', |
|
45 |
function ( args ) |
|
99
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
46 |
local connection = main.connection () |
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
47 |
if not connection then |
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
48 |
print "You are not online!" |
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
49 |
return |
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
50 |
end |
68 | 51 |
local who |
52 |
if args and args ~= '' then |
|
53 |
who = args |
|
54 |
else |
|
55 |
who = main.full_jid () |
|
56 |
end |
|
99
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
57 |
iq_register.unregister ( lm.connection.bless ( connection ), who, |
68 | 58 |
function ( form, submit, reject ) |
59 |
if not form then |
|
60 |
main.print_info ( who, 'Successfully unregistered' ) |
|
61 |
else |
|
62 |
insert_form ( form, |
|
63 |
function ( form ) |
|
64 |
submit ( form, |
|
65 |
function () |
|
66 |
main.print_info ( who, 'Successfully unregistered' ) |
|
67 |
end, |
|
68 |
function ( mesg ) |
|
69 |
main.print_info ( who, 'Unregistrering failed: ' .. mesg ) |
|
70 |
end ) |
|
71 |
end, |
|
72 |
function ( form ) |
|
73 |
reject ( form, |
|
74 |
function () |
|
75 |
main.print_info ( who, 'Unregistration cancelled' ) |
|
76 |
end, |
|
77 |
function ( mesg ) |
|
78 |
main.print_info ( who, 'Unregistration cancellation failed: ' .. mesg ) |
|
79 |
end ) |
|
80 |
end ) |
|
81 |
end |
|
82 |
end, |
|
83 |
function ( mesg ) |
|
84 |
main.print_info ( who, 'Unregistering failed: ' .. mesg ) |
|
85 |
end ) |
|
86 |
end, false, 'jid' ) |
|
87 |
||
99
ed4676536ed9
Update most useful scripts
Myhailo Danylenko <isbear@ukrpost.net>
parents:
68
diff
changeset
|
88 |
-- vim: se ts=4 sw=4: -- |