diff 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
line wrap: on
line diff
--- a/mod_pastebin/mod_pastebin.lua	Thu Oct 02 14:41:18 2025 +0100
+++ b/mod_pastebin/mod_pastebin.lua	Fri Oct 03 11:24:42 2025 +0100
@@ -50,6 +50,8 @@
 local trigger_string = module:get_option_string("pastebin_trigger");
 trigger_string = (trigger_string and trigger_string .. " ");
 
+local ignore_string = module:get_option_string("pastebin_ignore");
+
 local pastes = {};
 
 local xmlns_xhtmlim = "http://jabber.org/protocol/xhtml-im";
@@ -118,9 +120,10 @@
 
 	--module:log("debug", "Body(%s) length: %d", type(body), #(body or ""));
 
-	if ( #body > length_threshold and utf8_length(body) > length_threshold ) or
+	if (( #body > length_threshold and utf8_length(body) > length_threshold ) or
 		(trigger_string and body:find(trigger_string, 1, true) == 1) or
-		(select(2, body:gsub("\n", "%0")) >= line_threshold)
+		(select(2, body:gsub("\n", "%0")) >= line_threshold)) and
+		(not ignore_string or body:find(ignore_string, 1, true) == nil)
 	then
 		if trigger_string and body:sub(1, #trigger_string) == trigger_string then
 			body = body:sub(#trigger_string+1);