73 if opts.debug then |
73 if opts.debug then |
74 conn:hook("stanza-out", print); |
74 conn:hook("stanza-out", print); |
75 conn:hook("stanza", print); |
75 conn:hook("stanza", print); |
76 end |
76 end |
77 selfjid = bare_jid(conn.jid); |
77 selfjid = bare_jid(conn.jid); |
78 local function handle_results(ok, result) |
78 local function handle_results(result, err) |
|
79 if not result then |
|
80 conn:close(); |
|
81 return; |
|
82 end |
79 for i=1,#result do |
83 for i=1,#result do |
80 print_message(result[i]); |
84 print_message(result[i]); |
81 end |
85 end |
82 if result[reverse and "first" or "last"] then |
86 if result[reverse and "first" or "last"] then |
83 local fetch_next = opts.everything; |
87 local fetch_next = opts.everything; |
97 local whatnext, nextpage = reverse and "before" or "after"; |
101 local whatnext, nextpage = reverse and "before" or "after"; |
98 if reverse then |
102 if reverse then |
99 nextpage = result.first and result.first[1]; |
103 nextpage = result.first and result.first[1]; |
100 else |
104 else |
101 nextpage = result.last; |
105 nextpage = result.last; |
102 end |
106 end |
103 conn:info("Next page: --%s=%s", whatnext, nextpage); |
107 conn:info("Next page: --%s=%s", whatnext, nextpage); |
104 end |
108 end |
105 end |
109 end |
106 if result.count then |
110 if result.count then |
107 conn:info("Total: %d items", result.count); |
111 conn:info("Total: %d items", result.count); |