Mercurial > prosody-modules
diff mod_muc_limits/mod_muc_limits.lua @ 3968:bf5d91769f99
Merge commit
author | tmolitor <thilo@eightysoft.de> |
---|---|
date | Sun, 05 Apr 2020 23:39:08 +0200 |
parents | 2b10e51d85a6 |
children | 731ba9400c10 |
line wrap: on
line diff
--- a/mod_muc_limits/mod_muc_limits.lua Sun Apr 05 23:37:17 2020 +0200 +++ b/mod_muc_limits/mod_muc_limits.lua Sun Apr 05 23:39:08 2020 +0200 @@ -13,6 +13,7 @@ local burst = math.max(module:get_option_number("muc_burst_factor", 6), 1); local max_nick_length = module:get_option_number("muc_max_nick_length", 23); -- Default chosen through scientific methods +local join_only = module:get_option_boolean("muc_limit_joins_only", false); local dropped_count = 0; local dropped_jids; @@ -74,17 +75,21 @@ if rooms then function module.unload() - for room_jid, room in pairs(rooms) do + for room_jid, room in pairs(rooms) do --luacheck: ignore 213/room_jid room.throttle = nil; end end - module:hook("message/bare", handle_stanza, 501); - module:hook("message/full", handle_stanza, 501); - module:hook("presence/bare", handle_stanza, 501); module:hook("presence/full", handle_stanza, 501); + if not join_only then + module:hook("message/bare", handle_stanza, 501); + module:hook("message/full", handle_stanza, 501); + module:hook("presence/bare", handle_stanza, 501); + end else module:hook("muc-occupant-pre-join", handle_stanza); - module:hook("muc-occupant-pre-change", handle_stanza); - module:hook("muc-occupant-groupchat", handle_stanza); + if not join_only then + module:hook("muc-occupant-pre-change", handle_stanza); + module:hook("muc-occupant-groupchat", handle_stanza); + end end