Mercurial > prosody-modules
comparison mod_pastebin/mod_pastebin.lua @ 3030:4a7f08fe793c
mod_pastebin: Remove redundant check for non-empty body since it returns earlier in that case
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 20 May 2018 17:54:47 +0200 |
| parents | 7878dc2dbf59 |
| children | 040eaa3844f4 |
comparison
equal
deleted
inserted
replaced
| 3029:7878dc2dbf59 | 3030:4a7f08fe793c |
|---|---|
| 105 | 105 |
| 106 if not body then return; end | 106 if not body then return; end |
| 107 | 107 |
| 108 --module:log("debug", "Body(%s) length: %d", type(body), #(body or "")); | 108 --module:log("debug", "Body(%s) length: %d", type(body), #(body or "")); |
| 109 | 109 |
| 110 if body and ( | 110 if ( #body > length_threshold and utf8_length(body) > length_threshold ) or |
| 111 ((#body > length_threshold) | |
| 112 and (utf8_length(body) > length_threshold)) or | |
| 113 (trigger_string and body:find(trigger_string, 1, true) == 1) or | 111 (trigger_string and body:find(trigger_string, 1, true) == 1) or |
| 114 (select(2, body:gsub("\n", "%0")) >= line_threshold) | 112 (select(2, body:gsub("\n", "%0")) >= line_threshold) |
| 115 ) then | 113 then |
| 116 if trigger_string and body:sub(1, #trigger_string) == trigger_string then | 114 if trigger_string and body:sub(1, #trigger_string) == trigger_string then |
| 117 body = body:sub(#trigger_string+1); | 115 body = body:sub(#trigger_string+1); |
| 118 end | 116 end |
| 119 local url = pastebin_text(body); | 117 local url = pastebin_text(body); |
| 120 module:log("debug", "Pasted message as %s", url); | 118 module:log("debug", "Pasted message as %s", url); |
