# HG changeset patch # User Kim Alvefur # Date 1552620414 -3600 # Node ID 4ddb034a8a03b538597df0664d763e05c8032b94 # Parent e60933722248258041be2f00d668926055fe6ccb mod_pubsub_text_interface: Add command for listing current subscriptions diff -r e60933722248 -r 4ddb034a8a03 mod_pubsub_text_interface/mod_pubsub_text_interface.lua --- a/mod_pubsub_text_interface/mod_pubsub_text_interface.lua Thu Mar 14 01:26:54 2019 +0100 +++ b/mod_pubsub_text_interface/mod_pubsub_text_interface.lua Fri Mar 15 04:26:54 2019 +0100 @@ -11,6 +11,7 @@ - `help` - this help message - `list` - list available nodes +- `subscriptions` - list nodes you are subscribed to - `subscribe node` - subscribe to a node - `unsubscribe node` - unsubscribe from a node]]; if pubsub.get_last_item then -- COMPAT not available in 0.10 @@ -43,6 +44,19 @@ else reply:body(nodes); end + elseif command == "subscriptions" then + local ok, subs = pubsub:get_subscriptions(nil, from, from); + if not ok then + reply:body(subs); + elseif #subs == 0 then + reply:body("You are not subscribed to anything from this pubsub service"); + else + local response = {}; + for i = 1, #subs do + response[i] = string.format("- `%s`", subs[i].node); + end + reply:body(table.concat(response, "\n")); + end elseif command == "subscribe" then local ok, err = pubsub:add_subscription(node_arg, from, jid.bare(from), { ["pubsub#include_body"] = true }); reply:body(ok and "OK" or err);