--- AUTHOR: https://gist.github.com/legastero Lance Stout local jid_split = require "util.jid".split; local whitelist = module:get_option_set("muc_password_whitelist"); local MUC_NS = "http://jabber.org/protocol/muc"; module:hook("muc-occupant-pre-join", function (event) local room, stanza = event.room, event.stanza; local user, domain, res = jid_split(event.stanza.attr.from); --no user object means no way to check whitelist if user == nil then return end if not whitelist then return; end if not whitelist:contains(domain) and not whitelist:contains(user..'@'..domain) then return; end local join = stanza:get_child("x", MUC_NS); if not join then join = stanza:tag("x", { xmlns = MUC_NS }); end local password = join:get_child("password", MUC_NS); if password then -- removes