Software /
code /
prosody-modules
Comparison
mod_pastebin/mod_pastebin.lua @ 76:1fc4e8dc66a6
mod_pastebin: Send Content-Type header to specify plain UTF-8 text
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 01 Nov 2009 01:24:27 +0000 |
parent | 75:3c7189e26848 |
child | 156:b51741b7e86d |
comparison
equal
deleted
inserted
replaced
75:3c7189e26848 | 76:1fc4e8dc66a6 |
---|---|
12 | 12 |
13 -- Seconds a paste should live for in seconds (config is in hours), default 24 hours | 13 -- Seconds a paste should live for in seconds (config is in hours), default 24 hours |
14 local expire_after = math.floor((config.get(module.host, "core", "pastebin_expire_after") or 24) * 3600); | 14 local expire_after = math.floor((config.get(module.host, "core", "pastebin_expire_after") or 24) * 3600); |
15 | 15 |
16 local pastes = {}; | 16 local pastes = {}; |
17 local default_headers = { ["Content-Type"] = "text/plain; charset=utf-8" }; | |
17 | 18 |
18 local xmlns_xhtmlim = "http://jabber.org/protocol/xhtml-im"; | 19 local xmlns_xhtmlim = "http://jabber.org/protocol/xhtml-im"; |
19 local xmlns_xhtml = "http://www.w3.org/1999/xhtml"; | 20 local xmlns_xhtml = "http://www.w3.org/1999/xhtml"; |
20 | 21 |
21 function pastebin_text(text) | 22 function pastebin_text(text) |
22 local uuid = uuid_new(); | 23 local uuid = uuid_new(); |
23 pastes[uuid] = { text = text, time = os_time() }; | 24 pastes[uuid] = { body = text, time = os_time(), headers = default_headers }; |
24 pastes[#pastes+1] = uuid; | 25 pastes[#pastes+1] = uuid; |
25 if not pastes[2] then -- No other pastes, give the timer a kick | 26 if not pastes[2] then -- No other pastes, give the timer a kick |
26 add_task(expire_after, expire_pastes); | 27 add_task(expire_after, expire_pastes); |
27 end | 28 end |
28 return base_url..uuid; | 29 return base_url..uuid; |
34 return "Invalid paste id, perhaps it expired?"; | 35 return "Invalid paste id, perhaps it expired?"; |
35 end | 36 end |
36 | 37 |
37 --module:log("debug", "Received request, replying: %s", pastes[pasteid].text); | 38 --module:log("debug", "Received request, replying: %s", pastes[pasteid].text); |
38 | 39 |
39 return pastes[pasteid].text; | 40 return pastes[pasteid]; |
40 end | 41 end |
41 | 42 |
42 function check_message(data) | 43 function check_message(data) |
43 local origin, stanza = data.origin, data.stanza; | 44 local origin, stanza = data.origin, data.stanza; |
44 | 45 |