Mercurial > prosody-modules
comparison mod_pastebin/mod_pastebin.lua @ 3029:7878dc2dbf59
mod_pastebin: Avoid using pattern matching facilities for simple prefix removal
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 20 May 2018 17:51:08 +0200 |
parents | ded630a87563 |
children | 4a7f08fe793c |
comparison
equal
deleted
inserted
replaced
3028:ded630a87563 | 3029:7878dc2dbf59 |
---|---|
111 ((#body > length_threshold) | 111 ((#body > length_threshold) |
112 and (utf8_length(body) > length_threshold)) or | 112 and (utf8_length(body) > length_threshold)) or |
113 (trigger_string and body:find(trigger_string, 1, true) == 1) or | 113 (trigger_string and body:find(trigger_string, 1, true) == 1) or |
114 (select(2, body:gsub("\n", "%0")) >= line_threshold) | 114 (select(2, body:gsub("\n", "%0")) >= line_threshold) |
115 ) then | 115 ) then |
116 if trigger_string then | 116 if trigger_string and body:sub(1, #trigger_string) == trigger_string then |
117 body = body:gsub("^" .. trigger_string, "", 1); | 117 body = body:sub(#trigger_string+1); |
118 end | 118 end |
119 local url = pastebin_text(body); | 119 local url = pastebin_text(body); |
120 module:log("debug", "Pasted message as %s", url); | 120 module:log("debug", "Pasted message as %s", url); |
121 --module:log("debug", " stanza[bodyindex] = %q", tostring( stanza[bodyindex])); | 121 --module:log("debug", " stanza[bodyindex] = %q", tostring( stanza[bodyindex])); |
122 local summary = (body:sub(1, max_summary_length):gsub(utf8_pattern, drop_invalid_utf8) or ""):match("[^\n]+") or ""; | 122 local summary = (body:sub(1, max_summary_length):gsub(utf8_pattern, drop_invalid_utf8) or ""):match("[^\n]+") or ""; |