Mercurial > prosody-modules
comparison mod_message_logging/mod_message_logging.lua @ 1343:7dbde05b48a9
all the things: Remove trailing whitespace
| author | Florian Zeitz <florob@babelmonkeys.de> |
|---|---|
| date | Tue, 11 Mar 2014 18:44:01 +0100 |
| parents | ba220790a59c |
| children | 92f3b4d81b52 |
comparison
equal
deleted
inserted
replaced
| 1342:0ae065453dc9 | 1343:7dbde05b48a9 |
|---|---|
| 51 module:hook_global("logging-reloaded", close_open_files); | 51 module:hook_global("logging-reloaded", close_open_files); |
| 52 | 52 |
| 53 local function handle_incoming_message(event) | 53 local function handle_incoming_message(event) |
| 54 local origin, stanza = event.origin, event.stanza; | 54 local origin, stanza = event.origin, event.stanza; |
| 55 local message_type = stanza.attr.type; | 55 local message_type = stanza.attr.type; |
| 56 | 56 |
| 57 if message_type == "error" then return; end | 57 if message_type == "error" then return; end |
| 58 | 58 |
| 59 local from, to = jid_bare(stanza.attr.from), jid_bare(stanza.attr.to); | 59 local from, to = jid_bare(stanza.attr.from), jid_bare(stanza.attr.to); |
| 60 local body = stanza:get_child("body"); | 60 local body = stanza:get_child("body"); |
| 61 if not body then return; end | 61 if not body then return; end |
| 62 body = body:get_text(); | 62 body = body:get_text(); |
| 63 | 63 |
| 64 local f = open_files[to]; | 64 local f = open_files[to]; |
| 65 if not f then return; end | 65 if not f then return; end |
| 66 if message_type == "groupchat" then | 66 if message_type == "groupchat" then |
| 67 -- Add the nickname | 67 -- Add the nickname |
| 68 from = from.." <"..(select(3, jid_split(stanza.attr.from)) or "")..">"; | 68 from = from.." <"..(select(3, jid_split(stanza.attr.from)) or "")..">"; |
| 73 end | 73 end |
| 74 | 74 |
| 75 local function handle_outgoing_message(event) | 75 local function handle_outgoing_message(event) |
| 76 local origin, stanza = event.origin, event.stanza; | 76 local origin, stanza = event.origin, event.stanza; |
| 77 local message_type = stanza.attr.type; | 77 local message_type = stanza.attr.type; |
| 78 | 78 |
| 79 if message_type == "error" or message_type == "groupchat" then return; end | 79 if message_type == "error" or message_type == "groupchat" then return; end |
| 80 | 80 |
| 81 local from, to = jid_bare(stanza.attr.from), jid_bare(stanza.attr.to); | 81 local from, to = jid_bare(stanza.attr.from), jid_bare(stanza.attr.to); |
| 82 local body = stanza:get_child("body"); | 82 local body = stanza:get_child("body"); |
| 83 if not body then return; end | 83 if not body then return; end |
| 84 body = body:get_text(); | 84 body = body:get_text(); |
| 85 | 85 |
| 86 local f = open_files[from]; | 86 local f = open_files[from]; |
| 87 if not f then return; end | 87 if not f then return; end |
| 88 body = body:gsub("\n", "\n "); -- Indent newlines | 88 body = body:gsub("\n", "\n "); -- Indent newlines |
| 89 f:write("SEND: ", to, ": ", body, "\n"); | 89 f:write("SEND: ", to, ": ", body, "\n"); |
| 90 f:flush(); | 90 f:flush(); |
| 98 mkdir(host_base_path); | 98 mkdir(host_base_path); |
| 99 end | 99 end |
| 100 | 100 |
| 101 module:hook("message/bare", handle_incoming_message, 1); | 101 module:hook("message/bare", handle_incoming_message, 1); |
| 102 module:hook("message/full", handle_incoming_message, 1); | 102 module:hook("message/full", handle_incoming_message, 1); |
| 103 | 103 |
| 104 module:hook("pre-message/bare", handle_outgoing_message, 1); | 104 module:hook("pre-message/bare", handle_outgoing_message, 1); |
| 105 module:hook("pre-message/full", handle_outgoing_message, 1); | 105 module:hook("pre-message/full", handle_outgoing_message, 1); |
| 106 module:hook("pre-message/host", handle_outgoing_message, 1); | 106 module:hook("pre-message/host", handle_outgoing_message, 1); |
| 107 | 107 |
| 108 end | 108 end |
| 109 | 109 |
| 110 function module.command(arg) | 110 function module.command(arg) |
| 111 local command = table.remove(arg, 1); | 111 local command = table.remove(arg, 1); |
| 112 if command == "path" then | 112 if command == "path" then |
