comparison mod_pastebin/mod_pastebin.lua @ 438:7f0cdde1e42a

mod_pastebin: Add option 'pastebin_private_messages', defaults to false for components and true for other hosts (thanks Kelden/Maranda)
author Matthew Wild <mwild1@gmail.com>
date Thu, 22 Sep 2011 12:47:33 +0100
parents 7a695ee3884b
children 82ccfba5ac2f
comparison
equal deleted inserted replaced
437:78a2a6b2bea3 438:7f0cdde1e42a
3 local httpserver = require "net.httpserver"; 3 local httpserver = require "net.httpserver";
4 local uuid_new = require "util.uuid".generate; 4 local uuid_new = require "util.uuid".generate;
5 local os_time = os.time; 5 local os_time = os.time;
6 local t_insert, t_remove = table.insert, table.remove; 6 local t_insert, t_remove = table.insert, table.remove;
7 local add_task = require "util.timer".add_task; 7 local add_task = require "util.timer".add_task;
8
9 local pastebin_private_messages = module:get_option_boolean("pastebin_private_messages", hosts[module.host].type ~= "component");
8 10
9 local function drop_invalid_utf8(seq) 11 local function drop_invalid_utf8(seq)
10 local start = seq:byte(); 12 local start = seq:byte();
11 module:log("utf8: %d, %d", start, #seq); 13 module:log("utf8: %d, %d", start, #seq);
12 if (start <= 223 and #seq < 2) 14 if (start <= 223 and #seq < 2)
91 stanza[htmlindex or #stanza+1] = html; 93 stanza[htmlindex or #stanza+1] = html;
92 end 94 end
93 end 95 end
94 96
95 module:hook("message/bare", check_message); 97 module:hook("message/bare", check_message);
98 if pastebin_private_messages then
99 module:hook("message/full", check_message);
100 end
96 101
97 function expire_pastes(time) 102 function expire_pastes(time)
98 time = time or os_time(); -- COMPAT with 0.5 103 time = time or os_time(); -- COMPAT with 0.5
99 if pastes[1] then 104 if pastes[1] then
100 pastes[pastes[1]] = nil; 105 pastes[pastes[1]] = nil;