Comparison

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
comparison
equal deleted inserted replaced
3344:0ce475235ae1 3345:4a12abccdbaf
149 149
150 module:hook("message/bare", check_message); 150 module:hook("message/bare", check_message);
151 if pastebin_private_messages then 151 if pastebin_private_messages then
152 module:hook("message/full", check_message); 152 module:hook("message/full", check_message);
153 end 153 end
154
155 module:hook("muc-disco#info", function (event)
156 local reply, form, formdata = event.reply, event.form, event.formdata;
157 reply:tag("feature", { var = "https://modules.prosody.im/mod_pastebin" }):up();
158 table.insert(form, { name = "https://modules.prosody.im/mod_pastebin#max_lines", datatype = "xs:integer" });
159 table.insert(form, { name = "https://modules.prosody.im/mod_pastebin#max_characters", datatype = "xs:integer" });
160 formdata["https://modules.prosody.im/mod_pastebin#max_lines"] = line_threshold;
161 formdata["https://modules.prosody.im/mod_pastebin#max_characters"] = length_threshold;
162 end);
154 163
155 function expire_pastes(time) 164 function expire_pastes(time)
156 time = time or os_time(); -- COMPAT with 0.5 165 time = time or os_time(); -- COMPAT with 0.5
157 if pastes[1] then 166 if pastes[1] then
158 pastes[pastes[1]] = nil; 167 pastes[pastes[1]] = nil;