Comparison

mod_muc_log/mod_muc_log.lua @ 86:fc7055efd568

mod_muc_log: retrieving the room config, is not a kick of a person!! :) (thx again to flo spotting it!)
author Thilo Cestonaro <thilo@cestona.ro>
date Sun, 08 Nov 2009 22:10:42 +0100
parent 85:83494de806a4
child 87:0e639d081ba7
comparison
equal deleted inserted replaced
85:83494de806a4 86:fc7055efd568
302 end 302 end
303 end 303 end
304 304
305 local function parseIqStanza(stanza, timeStuff, nick) 305 local function parseIqStanza(stanza, timeStuff, nick)
306 local text = nil; 306 local text = nil;
307 for _,tag in ipairs(stanza) do 307 local victim = nil;
308 if tag.tag == "query" then 308 if(stanza.attr.type == "set") then
309 for _,item in ipairs(tag) do 309 for _,tag in ipairs(stanza) do
310 if item.tag == "item" then 310 if tag.tag == "query" then
311 for _,reason in ipairs(item) do 311 for _,item in ipairs(tag) do
312 if reason.tag == "reason" then 312 if item.tag == "item" and item.attr.nick ~= nil and tostring(item.attr.role) == 'none' then
313 text = reason[1]; 313 victim = item.attr.nick;
314 break; 314 for _,reason in ipairs(item) do
315 end 315 if reason.tag == "reason" then
316 end 316 text = reason[1];
317 break; 317 break;
318 end 318 end
319 end 319 end
320 break; 320 break;
321 end 321 end
322 end 322 end
323 323 break;
324 if text ~= nil then 324 end
325 text = html.day.reason:gsub("###REASON###", htmlEscape(text)); 325 end
326 else 326 if victim ~= nil then
327 text = ""; 327 if text ~= nil then
328 end 328 text = html.day.reason:gsub("###REASON###", htmlEscape(text));
329 return html.day.kick:gsub("###TIME_STUFF###", timeStuff):gsub("###VICTIM###", nick):gsub("###REASON_STUFF###", text); 329 else
330 text = "";
331 end
332 return html.day.kick:gsub("###TIME_STUFF###", timeStuff):gsub("###VICTIM###", victim):gsub("###REASON_STUFF###", text);
333 end
334 end
335 return;
330 end 336 end
331 337
332 local function parsePresenceStanza(stanza, timeStuff, nick) 338 local function parsePresenceStanza(stanza, timeStuff, nick)
333 local ret = ""; 339 local ret = "";
334 if stanza.attr.type == nil then 340 if stanza.attr.type == nil then
407 local stanza = lom.parse(data[i]); 413 local stanza = lom.parse(data[i]);
408 if stanza ~= nil and stanza.attr ~= nil and stanza.attr.time ~= nil then 414 if stanza ~= nil and stanza.attr ~= nil and stanza.attr.time ~= nil then
409 local timeStuff = html.day.time:gsub("###TIME###", stanza.attr.time); 415 local timeStuff = html.day.time:gsub("###TIME###", stanza.attr.time);
410 if stanza[1] ~= nil then 416 if stanza[1] ~= nil then
411 local nick; 417 local nick;
418 local tmp;
412 419
413 -- grep nick from "from" resource 420 -- grep nick from "from" resource
414 if stanza[1].attr.from ~= nil then -- presence and messages 421 if stanza[1].attr.from ~= nil then -- presence and messages
415 nick = htmlEscape(stanza[1].attr.from:match("/(.+)$")); 422 nick = htmlEscape(stanza[1].attr.from:match("/(.+)$"));
416 elseif stanza[1].attr.to ~= nil then -- iq 423 elseif stanza[1].attr.to ~= nil then -- iq
417 nick = htmlEscape(stanza[1].attr.to:match("/(.+)$")); 424 nick = htmlEscape(stanza[1].attr.to:match("/(.+)$"));
418 end 425 end
419 426
420 if stanza[1].tag == "presence" and nick ~= nil then 427 if stanza[1].tag == "presence" and nick ~= nil then
421 ret = ret .. parsePresenceStanza(stanza[1], timeStuff, nick); 428 tmp = parsePresenceStanza(stanza[1], timeStuff, nick);
422 elseif stanza[1].tag == "message" then 429 elseif stanza[1].tag == "message" then
423 ret = ret .. parseMessageStanza(stanza[1], timeStuff, nick); 430 tmp = parseMessageStanza(stanza[1], timeStuff, nick);
424 elseif stanza[1].tag == "iq" then 431 elseif stanza[1].tag == "iq" then
425 ret = ret .. parseIqStanza(stanza[1], timeStuff, nick); 432 tmp = parseIqStanza(stanza[1], timeStuff, nick);
426 else 433 else
427 module:log("info", "unknown stanza subtag in log found. room: %s; day: %s", bareRoomJid, query.year .. "/" .. query.month .. "/" .. query.day); 434 module:log("info", "unknown stanza subtag in log found. room: %s; day: %s", bareRoomJid, query.year .. "/" .. query.month .. "/" .. query.day);
435 end
436 if tmp ~= nil then
437 ret = ret .. tmp
438 tmp = nil;
428 end 439 end
429 end 440 end
430 end 441 end
431 end 442 end
432 else 443 else