# HG changeset patch # User Florian Zeitz # Date 1274628249 -7200 # Node ID b51741b7e86d3f48657a5f83cc4ff805d12423e8 # Parent 7a037cb5ab9e79eaeb9d8d425e3f0c0afd507dae mod_pastebin: Optionally bin if message starts with a configurable trigger string diff -r 7a037cb5ab9e -r b51741b7e86d mod_pastebin/mod_pastebin.lua --- a/mod_pastebin/mod_pastebin.lua Fri May 21 19:24:57 2010 +0200 +++ b/mod_pastebin/mod_pastebin.lua Sun May 23 17:24:09 2010 +0200 @@ -13,6 +13,9 @@ -- Seconds a paste should live for in seconds (config is in hours), default 24 hours local expire_after = math.floor((config.get(module.host, "core", "pastebin_expire_after") or 24) * 3600); +local trigger_string = config.get(module.host, "core", "pastebin_trigger"); +trigger_string = (trigger_string and trigger_string .. " ") or ""; + local pastes = {}; local default_headers = { ["Content-Type"] = "text/plain; charset=utf-8" }; @@ -57,7 +60,8 @@ --module:log("debug", "Body(%s) length: %d", type(body), #(body or "")); - if body and #body > length_threshold then + if body and ((#body > length_threshold) or (body:find(trigger_string, 1, true) == 1)) then + body = body:gsub("^" .. trigger_string, "", 1); local url = pastebin_text(body); module:log("debug", "Pasted message as %s", url); --module:log("debug", " stanza[bodyindex] = %q", tostring( stanza[bodyindex]));