Comparison

plugins/mod_scansion_record.lua @ 9368:0c5177738ffd

mod_scansion_record: Record connected clients as scansion Objects declarations
author Kim Alvefur <zash@zash.se>
date Sat, 22 Sep 2018 18:32:22 +0200
parent 9367:577c3a7f5045
child 9369:dd452f932b67
comparison
equal deleted inserted replaced
9367:577c3a7f5045 9368:0c5177738ffd
19 scan:write(string); 19 scan:write(string);
20 end 20 end
21 21
22 local function record_header(string) 22 local function record_header(string)
23 head:write(string); 23 head:write(string);
24 end
25
26 local function record_object(class, name, props)
27 head:write(("[%s] %s\n"):format(class, name));
28 for k,v in pairs(props) do
29 head:write(("\t%s: %s\n"):format(k, v));
30 end
31 head:write("\n");
24 end 32 end
25 33
26 local function record_event(session, event) 34 local function record_event(session, event)
27 record(session.scansion_id.." "..event.."\n\n"); 35 record(session.scansion_id.." "..event.."\n\n");
28 end 36 end
65 end 73 end
66 session.scansion_character = user.character; 74 session.scansion_character = user.character;
67 session.scansion_device = device; 75 session.scansion_device = device;
68 session.scansion_id = user.character..(device ~= "" and "'s "..device or device); 76 session.scansion_id = user.character..(device ~= "" and "'s "..device or device);
69 77
78 record_object("Client", user.character, {
79 jid = session.full_jid,
80 password = "password",
81 });
82
70 module:log("warn", "Connected: %s's %s", user.character, device); 83 module:log("warn", "Connected: %s's %s", user.character, device);
71 record_event(session, "connects"); 84 record_event(session, "connects");
72 85
73 filters.add_filter(session, "stanzas/in", record_stanza_in); 86 filters.add_filter(session, "stanzas/in", record_stanza_in);
74 filters.add_filter(session, "stanzas/out", record_stanza_out); 87 filters.add_filter(session, "stanzas/out", record_stanza_out);