mod_pastebin/mod_pastebin.lua
changeset 5876 8aec430ba205
parent 4704 f821eeac0e50
--- a/mod_pastebin/mod_pastebin.lua	Sun Mar 17 15:05:29 2024 +0100
+++ b/mod_pastebin/mod_pastebin.lua	Thu Mar 21 19:44:27 2024 +0100
@@ -100,8 +100,6 @@
 	end
 end
 
-local line_count_pattern = string.rep("[^\n]*\n", line_threshold + 1):sub(1,-2);
-
 function check_message(data)
 	local stanza = data.stanza;
 
@@ -122,7 +120,8 @@
 
 	if ( #body > length_threshold and utf8_length(body) > length_threshold ) or
 		(trigger_string and body:find(trigger_string, 1, true) == 1) or
-		body:find(line_count_pattern) then
+		(select(2, body:gsub("\n", "%0")) >= line_threshold)
+	then
 		if trigger_string and body:sub(1, #trigger_string) == trigger_string then
 			body = body:sub(#trigger_string+1);
 		end