Software /
code /
clix
File
clix/watch_pep.lua @ 145:6e05b25c2669
clix.watch_pep: Move invocation syntax out of short help
So it doesn't clutter the command listing
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 23 Nov 2020 23:52:31 +0100 |
parent | 144:febc3992bee6 |
line wrap: on
line source
local verse = require "verse"; local well_known = { geoloc = "http://jabber.org/protocol/geoloc"; -- XEP-0080 avatar = "urn:xmpp:avatar:metadata"; -- XEP-0084 mood = "http://jabber.org/protocol/mood"; -- XEP-0107 activity = "http://jabber.org/protocol/activity"; -- XEP-0108 tune = "http://jabber.org/protocol/tune"; -- XEP-0118 nick = "http://jabber.org/protocol/nick"; -- XEP-0172 chatting = "urn:xmpp:chatting:0"; -- XEP-0194 browsing = "urn:xmpp:browsing:0"; -- XEP-0195 gaming = "urn:xmpp:gaming:0"; -- XEP-0196 viewing = "urn:xmpp:viewing:0"; -- XEP-0197 vcard4 = "urn:xmpp:vcard4"; -- XEP-0292 }; return function (opts, arg) if opts.short_help then print("Watches PEP notifications from all contacts") return; end if opts.help or not arg[1] then print("clix watch_pep [--noempty] PEP-NODE+") return; end local function handle_notification(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 if payload.indent then print(payload:indent(nil, " "):pretty_print()); else print(payload:pretty_print()); end else print(payload); end end local function onconnect(conn) for _, node in ipairs(arg) do conn:hook_pep(well_known[node] or node, handle_notification); end if not opts.presence then conn:send(verse.presence()); end end clix_connect(opts, onconnect, {"pep"}) end;