comparison mod_pastebin/mod_pastebin.lua @ 6334:ad9026b6a714

mod_pastebin: Add pastebin_ignore option, to allow suppressing pastebin behaviour (thanks Zaak)
author Matthew Wild <mwild1@gmail.com>
date Fri, 03 Oct 2025 11:24:42 +0100
parents 8aec430ba205
children
comparison
equal deleted inserted replaced
6333:8a47791338fc 6334:ad9026b6a714
47 -- Seconds a paste should live for in seconds (config is in hours), default 24 hours 47 -- Seconds a paste should live for in seconds (config is in hours), default 24 hours
48 local expire_after = math.floor(module:get_option_number("pastebin_expire_after", 24) * 3600); 48 local expire_after = math.floor(module:get_option_number("pastebin_expire_after", 24) * 3600);
49 49
50 local trigger_string = module:get_option_string("pastebin_trigger"); 50 local trigger_string = module:get_option_string("pastebin_trigger");
51 trigger_string = (trigger_string and trigger_string .. " "); 51 trigger_string = (trigger_string and trigger_string .. " ");
52
53 local ignore_string = module:get_option_string("pastebin_ignore");
52 54
53 local pastes = {}; 55 local pastes = {};
54 56
55 local xmlns_xhtmlim = "http://jabber.org/protocol/xhtml-im"; 57 local xmlns_xhtmlim = "http://jabber.org/protocol/xhtml-im";
56 local xmlns_xhtml = "http://www.w3.org/1999/xhtml"; 58 local xmlns_xhtml = "http://www.w3.org/1999/xhtml";
116 118
117 if not body then return; end 119 if not body then return; end
118 120
119 --module:log("debug", "Body(%s) length: %d", type(body), #(body or "")); 121 --module:log("debug", "Body(%s) length: %d", type(body), #(body or ""));
120 122
121 if ( #body > length_threshold and utf8_length(body) > length_threshold ) or 123 if (( #body > length_threshold and utf8_length(body) > length_threshold ) or
122 (trigger_string and body:find(trigger_string, 1, true) == 1) or 124 (trigger_string and body:find(trigger_string, 1, true) == 1) or
123 (select(2, body:gsub("\n", "%0")) >= line_threshold) 125 (select(2, body:gsub("\n", "%0")) >= line_threshold)) and
126 (not ignore_string or body:find(ignore_string, 1, true) == nil)
124 then 127 then
125 if trigger_string and body:sub(1, #trigger_string) == trigger_string then 128 if trigger_string and body:sub(1, #trigger_string) == trigger_string then
126 body = body:sub(#trigger_string+1); 129 body = body:sub(#trigger_string+1);
127 end 130 end
128 local url = pastebin_text(body); 131 local url = pastebin_text(body);