Software /
code /
prosody-modules
Comparison
mod_muc_log/mod_muc_log.lua @ 1452:097c6af98d0a
Merge
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 25 Jun 2014 20:46:35 +0200 |
parent | 1450:5107278268ae |
child | 1544:814398c7139b |
comparison
equal
deleted
inserted
replaced
1446:843769eb40c3 | 1452:097c6af98d0a |
---|---|
14 | 14 |
15 local log_presences = module:get_option_boolean("muc_log_presences", true); | 15 local log_presences = module:get_option_boolean("muc_log_presences", true); |
16 | 16 |
17 -- Module Definitions | 17 -- Module Definitions |
18 | 18 |
19 local function get_room_from_jid(jid) | |
20 local node, host = split_jid(jid); | |
21 local component = hosts[host]; | |
22 if component then | |
23 local muc = component.modules.muc | |
24 if muc and rawget(muc,"rooms") then | |
25 -- We're running 0.9.x or 0.10 (old MUC API) | |
26 return muc.rooms[jid]; | |
27 elseif muc and rawget(muc,"get_room_from_jid") then | |
28 -- We're running >0.10 (new MUC API) | |
29 return muc.get_room_from_jid(jid); | |
30 else | |
31 return | |
32 end | |
33 end | |
34 end | |
35 | |
19 function log_if_needed(event) | 36 function log_if_needed(event) |
20 local stanza = event.stanza; | 37 local stanza = event.stanza; |
21 | 38 |
22 if (stanza.name == "presence") or | 39 if (stanza.name == "presence") or |
23 (stanza.name == "iq") or | 40 (stanza.name == "iq") or |
24 (stanza.name == "message" and tostring(stanza.attr.type) == "groupchat") | 41 (stanza.name == "message" and tostring(stanza.attr.type) == "groupchat") |
25 then | 42 then |
26 local node, host = split_jid(stanza.attr.to); | 43 local node, host = split_jid(stanza.attr.to); |
27 local muc = hosts[host].muc; | |
28 if node and host then | 44 if node and host then |
29 local bare = node .. "@" .. host; | 45 local bare = node .. "@" .. host; |
30 if muc and muc.rooms[bare] then | 46 if get_room_from_jid(bare) then |
31 local room = muc.rooms[bare] | 47 local room = get_room_from_jid(bare) |
32 local today = os.date("%y%m%d"); | 48 |
33 local now = os.date("%X") | 49 local today = os.date("!%y%m%d"); |
50 local now = os.date("!%X") | |
51 | |
34 local muc_to = nil | 52 local muc_to = nil |
35 local muc_from = nil; | 53 local muc_from = nil; |
36 local already_joined = false; | 54 local already_joined = false; |
37 | 55 |
38 if room._data.hidden then -- do not log any data of private rooms | 56 if room._data.hidden then -- do not log any data of private rooms |