diff options
author | Kim Alvefur <zash@zash.se> | 2018-09-22 13:50:00 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-09-22 13:50:00 +0200 |
commit | f0d8e7a60136734a0c165299081cbca668eb2d4e (patch) | |
tree | 41be46f5ab2ef3de0a03cafd78c5dc2b0d304677 /plugins | |
parent | 42cc508a5d9b018d5a93649f54150d4446922b6c (diff) | |
download | prosody-f0d8e7a60136734a0c165299081cbca668eb2d4e.tar.gz prosody-f0d8e7a60136734a0c165299081cbca668eb2d4e.zip |
mod_scansion_record: Unfinished code dump from Matthew
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_scansion_record.lua | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/plugins/mod_scansion_record.lua b/plugins/mod_scansion_record.lua new file mode 100644 index 00000000..47a33e34 --- /dev/null +++ b/plugins/mod_scansion_record.lua @@ -0,0 +1,54 @@ +local names = { "Romeo", "Juliet", "Mercutio", "Tybalt", "Benvolio" }; +local devices = { "", "phone", "laptop", "tablet", "toaster", "fridge", "shoe" }; +local users = {}; + +local full_jids = {}; + +local id = require "util.id"; + +local record_file = + +local function record(string) + + +local function record_event(session, event) +end + +local function record_stanza(stanza, session, verb) + record(session.scansion_id.." "..verb..":\n\t"..tostring(stanza).."\n\n"; +end + +local function record_stanza_in(stanza, session) +end + +local function record_stanza_out(stanza, session) +end + +module:hook("resource-bind", function (event) + local session = event.session; + if not users[session.username] then + users[session.username] = { + character = table.remove(names, 1) or id.short(); + devices = {}; + n_devices = 0; + }; + end + local user = users[session.username]; + local device = user.devices[event.resource]; + if not device then + user.n_devices = user.n_devices + 1; + device = devices[user.n_devices] or ("device"..id.short()); + user.devices[event.resource] = device; + end + session.scansion_character = user.character; + session.scansion_device = device; + session.scansion_id = user.character..(device ~= "" and "'s "..device" or device); + + full_jids[session.full_jid] = session.scansion_id; + + module:log("warn", "Connected: %s's %s", user.character, device); + + filters.add_filter(session, "stanzas/in", record_stanza_in); + filters.add_filter(session, "stanzas/out", record_stanza_out); +end); + |