11 end |
11 end |
12 if opts["end"] then |
12 if opts["end"] then |
13 opts["end"] = parse_datetime(opts["end"]); |
13 opts["end"] = parse_datetime(opts["end"]); |
14 end |
14 end |
15 local selfjid; |
15 local selfjid; |
16 local function print_message(m) |
16 local function print_message(i) |
17 -- TODO Roster lookup |
17 -- TODO Roster lookup |
18 -- TODO Timestamp |
18 local m = i.message; |
19 local a = m.attr; |
19 local a = m.attr; |
|
20 if i.stamp then |
|
21 print(os.date(nil, i.stamp)); |
|
22 end |
20 if a.to and bare_jid(a.to) ~= selfjid then |
23 if a.to and bare_jid(a.to) ~= selfjid then |
21 print("To ".. bare_jid(a.to)); |
24 print("To ".. bare_jid(a.to)); |
22 end |
25 end |
23 if a.from and bare_jid(a.from) ~= selfjid then |
26 if a.from and bare_jid(a.from) ~= selfjid then |
24 print("From ".. bare_jid(a.from)); |
27 print("From ".. bare_jid(a.from)); |
33 conn:hook("stanza", print); |
36 conn:hook("stanza", print); |
34 end |
37 end |
35 selfjid = bare_jid(conn.jid); |
38 selfjid = bare_jid(conn.jid); |
36 local function handle_results(ok, result) |
39 local function handle_results(ok, result) |
37 for i=1,#result do |
40 for i=1,#result do |
38 print_message(result[i].message); |
41 print_message(result[i]); |
39 end |
42 end |
40 if result.last then |
43 if result.last then |
41 io.stderr:write "--More--" |
44 io.stderr:write "--More--" |
42 if io.read"*l" then |
45 if io.read"*l" then |
43 opts.after = result.last; |
46 opts.after = result.last; |