1 local verse = require "verse"; |
1 local verse = require "verse"; |
2 |
2 |
3 return function (opts, arg) |
3 return function (opts, arg) |
4 if opts.short_help then |
4 if opts.short_help or not arg[1] then |
5 print("Watches PEP notifications from all contacts") |
5 print("Watches PEP notifications from all contacts") |
6 print("clix watch_pep [--node PEP-NODE] [--noempty]") |
6 print("clix watch_pep [--noempty] PEP-NODE") |
7 return; |
7 return; |
8 end |
8 end |
9 |
9 |
10 local function onconnect(conn) |
10 local function onconnect(conn) |
11 conn:hook_pep(opts.node or "urn:xmpp:microblog:0", function (event) |
11 conn:hook_pep(arg[1], function (event) |
12 local payload = event.item; |
12 local payload = event.item; |
13 if not payload then return end |
13 if not payload then return end |
14 if opts.noempty and not payload[1] then return end |
14 if opts.noempty and not payload[1] then return end |
15 if event.from then |
15 if event.from then |
16 io.stderr:write("# From "..event.from.."\n"); |
16 io.stderr:write("# From "..event.from.."\n"); |