|
1 |
|
2 local lm = require 'lm' |
|
3 local iq_register = require 'iq_register' |
|
4 |
|
5 main.command ( 'register', |
|
6 function ( args ) |
|
7 local who |
|
8 if args and args ~= '' then |
|
9 who = args |
|
10 else |
|
11 who = main.full_jid () |
|
12 end |
|
13 iq_register.register ( lm.connection.bless ( main.connection () ), who, |
|
14 function ( form, submit, reject ) |
|
15 insert_form ( form, |
|
16 function ( form ) |
|
17 submit ( form, |
|
18 function () |
|
19 main.print_info ( who, 'Successfully registered' ) |
|
20 end, |
|
21 function ( mesg ) |
|
22 main.print_info ( who, 'Registration failed: ' .. mesg ) |
|
23 end ) |
|
24 end, |
|
25 function ( form ) |
|
26 reject ( form, |
|
27 function () |
|
28 main.print_info ( who, 'Registration cancelled' ) |
|
29 end, |
|
30 function ( mesg ) |
|
31 main.print_info ( who, 'Registration cancellation failed: ' .. mesg ) |
|
32 end ) |
|
33 end ) |
|
34 end, |
|
35 function ( mesg ) |
|
36 main.print_info ( who, 'Registration failed: ' .. mesg ) |
|
37 end ) |
|
38 end, false, 'jid' ) |
|
39 main.command ( 'cancel', |
|
40 function ( args ) |
|
41 local who |
|
42 if args and args ~= '' then |
|
43 who = args |
|
44 else |
|
45 who = main.full_jid () |
|
46 end |
|
47 iq_register.unregister ( lm.connection.bless ( main.connection () ), who, |
|
48 function ( form, submit, reject ) |
|
49 if not form then |
|
50 main.print_info ( who, 'Successfully unregistered' ) |
|
51 else |
|
52 insert_form ( form, |
|
53 function ( form ) |
|
54 submit ( form, |
|
55 function () |
|
56 main.print_info ( who, 'Successfully unregistered' ) |
|
57 end, |
|
58 function ( mesg ) |
|
59 main.print_info ( who, 'Unregistrering failed: ' .. mesg ) |
|
60 end ) |
|
61 end, |
|
62 function ( form ) |
|
63 reject ( form, |
|
64 function () |
|
65 main.print_info ( who, 'Unregistration cancelled' ) |
|
66 end, |
|
67 function ( mesg ) |
|
68 main.print_info ( who, 'Unregistration cancellation failed: ' .. mesg ) |
|
69 end ) |
|
70 end ) |
|
71 end |
|
72 end, |
|
73 function ( mesg ) |
|
74 main.print_info ( who, 'Unregistering failed: ' .. mesg ) |
|
75 end ) |
|
76 end, false, 'jid' ) |
|
77 |
|
78 commands_help['register'] = "[jid]\n\nSends registration request to jid (or current buddy). You, probably, then will need to fill and send some form." |
|
79 commands_help['cancel'] = "[jid]\n\nSends registration cancellation request to jid (or current buddy). May require a form filling." |
|
80 |
|
81 -- vim: se ts=4: -- |