Changeset

4041:cb5ea9d25cb2

mod_pubsub_text_interface: Hint at possible commands using XEP-0439: Quick Response
author Kim Alvefur <zash@zash.se>
date Wed, 10 Jun 2020 12:15:11 +0200
parents 4040:e17c937a71b3
children 4042:78ac5500a844
files mod_pubsub_text_interface/mod_pubsub_text_interface.lua
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_pubsub_text_interface/mod_pubsub_text_interface.lua	Wed Jun 10 12:12:47 2020 +0200
+++ b/mod_pubsub_text_interface/mod_pubsub_text_interface.lua	Wed Jun 10 12:15:11 2020 +0200
@@ -4,6 +4,7 @@
 
 local pubsub = module:depends "pubsub".service;
 
+local xmlns_quick_resp = "urn:xmpp:tmp:quick-response";
 local name = module:get_option_string("name", "PubSub Service on "..module.host);
 local help = name..[[
 
@@ -33,6 +34,8 @@
 
 	if command == "help" then
 		reply:body(help);
+		reply:tag("response", { xmlns = xmlns_quick_resp, value = "list", }):up();
+		reply:tag("response", { xmlns = xmlns_quick_resp, value = "subscriptions", }):up();
 	elseif command == "list" then
 		local ok, nodes = pubsub:get_nodes(from);
 		if ok then
@@ -54,6 +57,8 @@
 			local response = {};
 			for i = 1, #subs do
 				response[i] = string.format("- `%s`", subs[i].node);
+				reply:tag("response", { xmlns = xmlns_quick_resp, value = "unsubscribe "..subs[i].node, }):up();
+				reply:tag("response", { xmlns = xmlns_quick_resp, value = "last "..subs[i].node, }):up();
 			end
 			reply:body(table.concat(response, "\n"));
 		end
@@ -77,6 +82,7 @@
 		end
 	else
 		reply:body("Unknown command. `help` to list commands.");
+		reply:tag("response", { xmlns = xmlns_quick_resp, value = "help", }):up();
 	end
 	reply:reset();