# HG changeset patch # User Kim Alvefur # Date 1605449124 -3600 # Node ID 6909e479c56b37486bb43c6905dbb34d2ae856e3 # Parent 1783d4226ba16aa3d024725032a1d2a683e39a4b clix.watch_pep: Subscribe to a PEP node diff -r 1783d4226ba1 -r 6909e479c56b clix/watch_pep.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clix/watch_pep.lua Sun Nov 15 15:05:24 2020 +0100 @@ -0,0 +1,32 @@ +local verse = require "verse"; + +return function (opts, arg) + if opts.short_help then + print("Watches PEP notifications from all contacts") + print("clix watch_pep [--node PEP-NODE] [--noempty]") + return; + end + + local function onconnect(conn) + conn:hook_pep(opts.node or "urn:xmpp:microblog:0", function (event) + local payload = event.item; + if not payload then return end + if opts.noempty and not payload[1] then return end + if event.from then + io.stderr:write("# From "..event.from.."\n"); + end + if payload.attr.xmlns == "urn:xmpp:json:0" then + print(payload:get_tex()) + elseif opts.pretty then + print(payload:indent(nil, " ")); + else + print(payload); + end + end); + if not opts.presence then + conn:send(verse.presence()); + end + end + + clix_connect(opts, onconnect, {"pep"}) +end; diff -r 1783d4226ba1 -r 6909e479c56b squishy --- a/squishy Sat Nov 14 15:42:10 2020 +0100 +++ b/squishy Sun Nov 15 15:05:24 2020 +0100 @@ -14,6 +14,7 @@ "sendfile"; "archive"; "presence"; + "watch_pep"; } for _, cmd in ipairs(commands) do