Diff

mod_pastebin/mod_pastebin.lua @ 3345:4a12abccdbaf

mod_pastebin: Advertise a disco feature and current thresholds
author Kim Alvefur <zash@zash.se>
date Wed, 03 Oct 2018 12:59:04 +0200
parent 3196:01503000d2f1
child 3346:03cbffd807bb
line wrap: on
line diff
--- a/mod_pastebin/mod_pastebin.lua	Tue Oct 02 16:09:17 2018 +0100
+++ b/mod_pastebin/mod_pastebin.lua	Wed Oct 03 12:59:04 2018 +0200
@@ -152,6 +152,15 @@
 	module:hook("message/full", check_message);
 end
 
+module:hook("muc-disco#info", function (event)
+	local reply, form, formdata = event.reply, event.form, event.formdata;
+	reply:tag("feature", { var = "https://modules.prosody.im/mod_pastebin" }):up();
+	table.insert(form, { name = "https://modules.prosody.im/mod_pastebin#max_lines", datatype = "xs:integer" });
+	table.insert(form, { name = "https://modules.prosody.im/mod_pastebin#max_characters", datatype = "xs:integer" });
+	formdata["https://modules.prosody.im/mod_pastebin#max_lines"] = line_threshold;
+	formdata["https://modules.prosody.im/mod_pastebin#max_characters"] = length_threshold;
+end);
+
 function expire_pastes(time)
 	time = time or os_time(); -- COMPAT with 0.5
 	if pastes[1] then