# HG changeset patch # User Stephen Paul Weber # Date 1676918533 18000 # Node ID dc6a10629670f84e316e75b6c1bd3230f6245807 # Parent 1682166171fffc9988b27b1a1b61a492e94deefc New module, mod_muc_reserve_nick_pattern diff -r 1682166171ff -r dc6a10629670 mod_muc_reserve_nick_pattern/README.markdown --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_muc_reserve_nick_pattern/README.markdown Mon Feb 20 13:42:13 2023 -0500 @@ -0,0 +1,23 @@ +--- +labels: +- 'Stage-Alpha' +summary: 'Require MUC occupant nicknames to no match some patterns' +--- + +Introduction +============ + +This checks the nickname of a joining user against a configurable list of +[Lua patterns](https://www.lua.org/manual/5.2/manual.html#6.4.1), and prevents +them from joining if it matches any of them. + +Configuration +============= + +There is a single configuration option, `muc_reserve_nick_patterns` and the +default is `{}` - i.e. allow everything. + +Compatibility +============= + +Requires Prosody 0.11 or higher. diff -r 1682166171ff -r dc6a10629670 mod_muc_reserve_nick_pattern/mod_muc_reserve_nick_pattern.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_muc_reserve_nick_pattern/mod_muc_reserve_nick_pattern.lua Mon Feb 20 13:42:13 2023 -0500 @@ -0,0 +1,15 @@ +local jid = require "util.jid"; +local st = require "util.stanza"; + +local nick_patterns = module:get_option_array("muc_reserve_nick_patterns", {}); + +module:hook("muc-occupant-pre-join", function (event) + local nick = jid.resource(event.occupant.nick); + for k, nick_pattern in pairs(nick_patterns) do + if nick:match(nick_pattern) then + local reply = st.error_reply(event.stanza, "modify", "conflict", "Unacceptable nickname, please try another"); + module:send(reply); + return true; + end + end +end);