mod_poke_strangers/mod_poke_strangers.lua
changeset 5833 1e28f32257d6
parent 2049 0aa8aa6cdb1b
equal deleted inserted replaced
5832:0ee77be396b9 5833:1e28f32257d6
     9 
     9 
    10 local version_id = uuid_generate();
    10 local version_id = uuid_generate();
    11 local disco_id = uuid_generate();
    11 local disco_id = uuid_generate();
    12 
    12 
    13 module:hook("iq-result/host/" .. version_id, function (event)
    13 module:hook("iq-result/host/" .. version_id, function (event)
    14 	module:log("info", "Stranger " .. event.stanza.attr.from .. " version: " .. tostring(event.stanza));
    14 	module:log("info", "Stranger <%s> version: %s", event.stanza.attr.from, event.stanza);
    15 	return true;
    15 	return true;
    16 end);
    16 end);
    17 
    17 
    18 module:hook("iq-result/host/" .. disco_id, function (event)
    18 module:hook("iq-result/host/" .. disco_id, function (event)
    19 	module:log("info", "Stranger " .. event.stanza.attr.from .. " disco: " .. tostring(event.stanza));
    19 	module:log("info", "Stranger <%s> disco: %s", event.stanza.attr.from, event.stanza);
    20 	return true;
    20 	return true;
    21 end);
    21 end);
    22 
    22 
    23 function check_subscribed(event)
    23 function check_subscribed(event)
    24 	local stanza = event.stanza;
    24 	local stanza = event.stanza;
    25 	local local_user_jid = stanza.attr.to;
    25 	local local_user_jid = stanza.attr.to;
    26 	local to_user, to_host, to_resource = jid_split(local_user_jid);
    26 	local to_user, to_host, to_resource = jid_split(local_user_jid);
    27 	local stranger_jid = stanza.attr.from;
    27 	local stranger_jid = stanza.attr.from;
    28 
    28 
    29 	if recently_queried:contains(stranger_jid) then
    29 	if recently_queried:contains(stranger_jid) then
    30 		module:log("debug", "Not re-poking " .. stranger_jid);
    30 		module:log("debug", "Not re-poking <%s>", stranger_jid);
    31 		return nil;
    31 		return nil;
    32 	end
    32 	end
    33 
    33 
    34 	local from_jid = jid_bare(stranger_jid);
    34 	local from_jid = jid_bare(stranger_jid);
    35 
    35