Mercurial > prosody-modules
changeset 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 | 8a47791338fc |
| children | 1f00618ad3be |
| files | mod_pastebin/README.md mod_pastebin/mod_pastebin.lua |
| diffstat | 2 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_pastebin/README.md Thu Oct 02 14:41:18 2025 +0100 +++ b/mod_pastebin/README.md Fri Oct 03 11:24:42 2025 +0100 @@ -83,6 +83,7 @@ pastebin_threshold Maximum length (in characters) of a message that is allowed to skip the pastebin. (default 500 characters) pastebin_line_threshold The maximum number of lines a message may have before it is sent to the pastebin. (default 4 lines) pastebin_trigger A string of characters (e.g. "!paste ") which if detected at the start of a message, always sends the message to the pastebin, regardless of length. (default: not set) + pastebin_ignore A string of characters (e.g. "!nopaste") which if detected **anywhere** within a message, won't send the message to the pastebin pastebin_expire_after Number of hours after which to expire (remove) a paste, defaults to 24. Set to 0 to store pastes permanently on disk. # Compatibility
--- 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);
